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 HsInt __compat_long_path_size() { return PATH_MAX; }
26 INLINE HsInt __compat_long_path_size() { return 4096; }
29 #if defined(mingw32_HOST_OS)
31 /* Make sure we've got the reqd CSIDL_ constants in scope;
32 * w32api header files are lagging a bit in defining the full set.
34 #if !defined(CSIDL_APPDATA)
35 #define CSIDL_APPDATA 0x001a
37 #if !defined(CSIDL_PERSONAL)
38 #define CSIDL_PERSONAL 0x0005
40 #if !defined(CSIDL_PROFILE)
41 #define CSIDL_PROFILE 0x0028
43 #if !defined(CSIDL_WINDOWS)
44 #define CSIDL_WINDOWS 0x0024
47 INLINE int __hscore_CSIDL_PROFILE() { return CSIDL_PROFILE; }
48 INLINE int __hscore_CSIDL_APPDATA() { return CSIDL_APPDATA; }
49 INLINE int __hscore_CSIDL_WINDOWS() { return CSIDL_WINDOWS; }
50 INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }
52 #if __GLASGOW_HASKELL__ < 604
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 */