e5c4fb39211e6c03751707196056dd9b25013e35
[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 #ifdef __NHC__
13 #include "Nhc98BaseConfig.h"
14 #else
15 #include "HsDirectoryConfig.h"
16 #endif
17 // Otherwise these clash with similar definitions from other packages:
18 #undef PACKAGE_BUGREPORT
19 #undef PACKAGE_NAME
20 #undef PACKAGE_STRING
21 #undef PACKAGE_TARNAME
22 #undef PACKAGE_VERSION
23
24 #if HAVE_SYS_TYPES_H
25 #include <sys/types.h>
26 #endif
27 #if HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
30 #if HAVE_SYS_STAT_H
31 #include <sys/stat.h>
32 #endif
33
34 #include "HsFFI.h"
35
36 #if defined(__MINGW32__)
37 #include <shlobj.h>
38 #endif
39
40 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
41 extern int __hscore_getFolderPath(HWND hwndOwner,
42                   int nFolder,
43                   HANDLE hToken,
44                   DWORD dwFlags,
45                   char*  pszPath);
46 #endif
47
48 /* -----------------------------------------------------------------------------
49    INLINE functions.
50
51    These functions are given as inlines here for when compiling via C,
52    but we also generate static versions into the cbits library for
53    when compiling to native code.
54    -------------------------------------------------------------------------- */
55
56 #ifndef INLINE
57 # if defined(_MSC_VER)
58 #  define INLINE extern __inline
59 # else
60 #  define INLINE static inline
61 # endif
62 #endif
63
64 /* A size that will contain many path names, but not necessarily all
65  * (PATH_MAX is not defined on systems with unlimited path length,
66  * e.g. the Hurd).
67  */
68 INLINE HsInt __hscore_long_path_size() {
69 #ifdef PATH_MAX
70     return PATH_MAX;
71 #else
72     return 4096;
73 #endif
74 }
75
76 INLINE int __hscore_R_OK() { return R_OK; }
77 INLINE int __hscore_W_OK() { return W_OK; }
78 INLINE int __hscore_X_OK() { return X_OK; }
79
80 INLINE mode_t __hscore_S_IRUSR() { return S_IRUSR; }
81 INLINE mode_t __hscore_S_IWUSR() { return S_IWUSR; }
82 INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
83 INLINE mode_t __hscore_S_IFDIR() { return S_IFDIR; }
84
85 #if defined(__MINGW32__)
86
87 /* Make sure we've got the reqd CSIDL_ constants in scope;
88  * w32api header files are lagging a bit in defining the full set.
89  */
90 #if !defined(CSIDL_APPDATA)
91 #define CSIDL_APPDATA 0x001a
92 #endif
93 #if !defined(CSIDL_PERSONAL)
94 #define CSIDL_PERSONAL 0x0005
95 #endif
96 #if !defined(CSIDL_PROFILE)
97 #define CSIDL_PROFILE 0x0028
98 #endif
99 #if !defined(CSIDL_WINDOWS)
100 #define CSIDL_WINDOWS 0x0024
101 #endif
102
103 INLINE int __hscore_CSIDL_PROFILE()  { return CSIDL_PROFILE;  }
104 INLINE int __hscore_CSIDL_APPDATA()  { return CSIDL_APPDATA;  }
105 INLINE int __hscore_CSIDL_WINDOWS()  { return CSIDL_WINDOWS;  }
106 INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }
107 #endif
108
109 #endif /* __HSDIRECTORY_H__ */
110