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