Blender V2.61 - r43446

GHOST_SystemPathsWin32.cpp

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