fix for py/rna mesh.materials[:] where empty materials exist, would raise a runtime...
[blender.git] / intern / ghost / intern / GHOST_SystemPathsWin32.cpp
1 /**
2  * $Id: GHOST_SystemWin32.cpp 30060 2010-07-06 20:31:55Z elubie $
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2011 Blender Foundation.
20  * All rights reserved.
21  * 
22  * Contributor(s): Blender Foundation
23  *                 Andrea Weikert
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 #include "GHOST_SystemPathsWin32.h"
29
30 #define WIN32_LEAN_AND_MEAN
31 #ifdef _WIN32_IE
32 #undef _WIN32_IE
33 #endif
34 #define _WIN32_IE 0x0501
35 #include <windows.h>
36 #include <shlobj.h>
37
38
39 GHOST_SystemPathsWin32::GHOST_SystemPathsWin32()
40 {
41 }
42
43 GHOST_SystemPathsWin32::~GHOST_SystemPathsWin32()
44 {
45 }
46
47 const GHOST_TUns8* GHOST_SystemPathsWin32::getSystemDir() const
48 {
49         static char knownpath[MAX_PATH];
50         HRESULT hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
51
52         if (hResult == S_OK)
53         {
54                 return (GHOST_TUns8*)knownpath;
55         }
56
57         return NULL;
58 }
59
60 const GHOST_TUns8* GHOST_SystemPathsWin32::getUserDir() const
61 {
62         static char knownpath[MAX_PATH];
63         HRESULT hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
64
65         if (hResult == S_OK)
66         {
67                 return (GHOST_TUns8*)knownpath;
68         }
69
70         return NULL;
71 }
72
73 const GHOST_TUns8* GHOST_SystemPathsWin32::getBinaryDir() const
74 {
75         static char fullname[MAX_PATH];
76         if(GetModuleFileName(0, fullname, MAX_PATH)) {
77                 return (GHOST_TUns8*)fullname;
78         }
79
80         return NULL;
81 }