Blender  V2.59
GHOST_SystemPathsWin32.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_SystemPathsWin32.cpp 38908 2011-08-02 04:28:05Z merwin $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2011 Blender Foundation.
00020  * All rights reserved.
00021  * 
00022  * Contributor(s): Blender Foundation
00023  *                 Andrea Weikert
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #include "GHOST_SystemPathsWin32.h"
00034 
00035 #ifndef _WIN32_IE
00036 #define _WIN32_IE 0x0501
00037 #endif
00038 #include <shlobj.h>
00039 
00040 #if defined(__MINGW32__) || defined(__CYGWIN__)
00041 
00042 #if !defined(SHARD_PIDL)
00043 #define SHARD_PIDL      0x00000001L
00044 #endif
00045 
00046 #if !defined(SHARD_PATHA)
00047 #define SHARD_PATHA     0x00000002L
00048 #endif
00049 
00050 #if !defined(SHARD_PATHA)
00051 #define SHARD_PATHW     0x00000003L
00052 #endif
00053 
00054 #if !defined(SHARD_PATH)
00055 #ifdef UNICODE
00056 #define SHARD_PATH  SHARD_PATHW
00057 #else
00058 #define SHARD_PATH  SHARD_PATHA
00059 #endif
00060 #endif
00061 
00062 #endif
00063 
00064 GHOST_SystemPathsWin32::GHOST_SystemPathsWin32()
00065 {
00066 }
00067 
00068 GHOST_SystemPathsWin32::~GHOST_SystemPathsWin32()
00069 {
00070 }
00071 
00072 const GHOST_TUns8* GHOST_SystemPathsWin32::getSystemDir() const
00073 {
00074         static char knownpath[MAX_PATH];
00075         HRESULT hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
00076 
00077         if (hResult == S_OK)
00078         {
00079                 return (GHOST_TUns8*)knownpath;
00080         }
00081 
00082         return NULL;
00083 }
00084 
00085 const GHOST_TUns8* GHOST_SystemPathsWin32::getUserDir() const
00086 {
00087         static char knownpath[MAX_PATH];
00088         HRESULT hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
00089 
00090         if (hResult == S_OK)
00091         {
00092                 return (GHOST_TUns8*)knownpath;
00093         }
00094 
00095         return NULL;
00096 }
00097 
00098 const GHOST_TUns8* GHOST_SystemPathsWin32::getBinaryDir() const
00099 {
00100         static char fullname[MAX_PATH];
00101         if(GetModuleFileName(0, fullname, MAX_PATH)) {
00102                 return (GHOST_TUns8*)fullname;
00103         }
00104 
00105         return NULL;
00106 }
00107 
00108 void GHOST_SystemPathsWin32::addToSystemRecentFiles(const char* filename) const
00109 {
00110         /* SHARD_PATH resolves to SHARD_PATHA for non-UNICODE build */
00111         SHAddToRecentDocs(SHARD_PATH,filename);
00112 }