3 #include "../../../includes/ghcconfig.h"
11 #include "directory.h"
13 #define INLINE /* nothing */
16 * Following code copied from libraries/base/includes/HsBase.h
20 /* A size that will contain many path names, but not necessarily all
21 * (PATH_MAX is not defined on systems with unlimited path length,
24 INLINE int __compat_long_path_size() { return PATH_MAX; }
26 INLINE int __compat_long_path_size() { return 4096; }
29 #if defined(mingw32_HOST_OS)
30 #if __GLASGOW_HASKELL__ < 604
32 /* Make sure we've got the reqd CSIDL_ constants in scope;
33 * w32api header files are lagging a bit in defining the full set.
35 #if !defined(CSIDL_APPDATA)
36 #define CSIDL_APPDATA 0x001a
38 #if !defined(CSIDL_PERSONAL)
39 #define CSIDL_PERSONAL 0x0005
41 #if !defined(CSIDL_PROFILE)
42 #define CSIDL_PROFILE 0x0028
44 #if !defined(CSIDL_WINDOWS)
45 #define CSIDL_WINDOWS 0x0024
48 INLINE int __hscore_CSIDL_PROFILE() { return CSIDL_PROFILE; }
49 INLINE int __hscore_CSIDL_APPDATA() { return CSIDL_APPDATA; }
50 INLINE int __hscore_CSIDL_WINDOWS() { return CSIDL_WINDOWS; }
51 INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }
54 * Function: __hscore_getFolderPath()
56 * Late-bound version of SHGetFolderPath(), coping with OS versions
57 * that have shell32's lacking that particular API.
60 typedef HRESULT (*HSCORE_GETAPPFOLDERFUNTY)(HWND,int,HANDLE,DWORD,char*);
62 __hscore_getFolderPath(HWND hwndOwner,
68 static int loaded_dll = 0;
69 static HMODULE hMod = (HMODULE)NULL;
70 static HSCORE_GETAPPFOLDERFUNTY funcPtr = NULL;
71 /* The DLLs to try loading entry point from */
72 char* dlls[] = { "shell32.dll", "shfolder.dll" };
76 } else if (loaded_dll == 0) {
78 for(i=0;i < sizeof(dlls); i++) {
79 hMod = LoadLibrary(dlls[i]);
81 (funcPtr = (HSCORE_GETAPPFOLDERFUNTY)GetProcAddress(hMod, "SHGetFolderPathA")) ) {
86 if (loaded_dll == 0) {
91 /* OK, if we got this far the function has been bound */
92 return (int)funcPtr(hwndOwner,nFolder,hToken,dwFlags,pszPath);
93 /* ToDo: unload the DLL on shutdown? */
95 #endif /* __GLASGOW_HASKELL__ < 604 */
96 #endif /* mingw32_HOST_OS */