Need shlobj.h on Windows
[haskell-directory.git] / include / HsDirectory.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The University of Glasgow 2001-2004
4  *
5  * Definitions for package `directory' which are visible in Haskell land.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef __HSDIRECTORY_H__
10 #define __HSDIRECTORY_H__
11
12 #include "HsDirectoryConfig.h"
13
14 #if HAVE_SYS_TYPES_H
15 #include <sys/types.h>
16 #endif
17 #if HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20 #if HAVE_SYS_STAT_H
21 #include <sys/stat.h>
22 #endif
23
24 #include "HsFFI.h"
25
26 #if defined(__MINGW32__)
27 #include <shlobj.h>
28 #endif
29
30 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
31 extern int __hscore_getFolderPath(HWND hwndOwner,
32                   int nFolder,
33                   HANDLE hToken,
34                   DWORD dwFlags,
35                   char*  pszPath);
36 #endif
37
38 /* -----------------------------------------------------------------------------
39    INLINE functions.
40
41    These functions are given as inlines here for when compiling via C,
42    but we also generate static versions into the cbits library for
43    when compiling to native code.
44    -------------------------------------------------------------------------- */
45
46 #ifndef INLINE
47 # if defined(_MSC_VER)
48 #  define INLINE extern __inline
49 # else
50 #  define INLINE static inline
51 # endif
52 #endif
53
54 /* A size that will contain many path names, but not necessarily all
55  * (PATH_MAX is not defined on systems with unlimited path length,
56  * e.g. the Hurd).
57  */
58 INLINE HsInt __hscore_long_path_size() {
59 #ifdef PATH_MAX
60     return PATH_MAX;
61 #else
62     return 4096;
63 #endif
64 }
65
66 #ifdef __GLASGOW_HASKELL__
67 INLINE int __hscore_R_OK() { return R_OK; }
68 INLINE int __hscore_W_OK() { return W_OK; }
69 INLINE int __hscore_X_OK() { return X_OK; }
70
71 INLINE mode_t __hscore_S_IRUSR() { return S_IRUSR; }
72 INLINE mode_t __hscore_S_IWUSR() { return S_IWUSR; }
73 INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
74 #endif
75
76 #if defined(__MINGW32__)
77
78 /* Make sure we've got the reqd CSIDL_ constants in scope;
79  * w32api header files are lagging a bit in defining the full set.
80  */
81 #if !defined(CSIDL_APPDATA)
82 #define CSIDL_APPDATA 0x001a
83 #endif
84 #if !defined(CSIDL_PERSONAL)
85 #define CSIDL_PERSONAL 0x0005
86 #endif
87 #if !defined(CSIDL_PROFILE)
88 #define CSIDL_PROFILE 0x0028
89 #endif
90 #if !defined(CSIDL_WINDOWS)
91 #define CSIDL_WINDOWS 0x0024
92 #endif
93
94 INLINE int __hscore_CSIDL_PROFILE()  { return CSIDL_PROFILE;  }
95 INLINE int __hscore_CSIDL_APPDATA()  { return CSIDL_APPDATA;  }
96 INLINE int __hscore_CSIDL_WINDOWS()  { return CSIDL_WINDOWS;  }
97 INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }
98 #endif
99
100 #endif /* __HSDIRECTORY_H__ */
101