[project @ 2004-11-12 13:27:54 by simonpj]
authorsimonpj <unknown>
Fri, 12 Nov 2004 13:27:54 +0000 (13:27 +0000)
committersimonpj <unknown>
Fri, 12 Nov 2004 13:27:54 +0000 (13:27 +0000)
add bits required for Compat.Directory on Windows

ghc/lib/compat/Compat/Directory.hs
ghc/lib/compat/cbits/directory.c [new file with mode: 0644]

index 6ec4af5..74baec8 100644 (file)
@@ -24,6 +24,9 @@ module Compat.Directory (
 
 #if !defined(mingw32_TARGET_OS)
 import System.Environment (getEnv)
+#else
+import Foreign
+import Foreign.C
 #endif
 
 getAppUserDataDirectory :: String -> IO FilePath
@@ -39,11 +42,16 @@ getAppUserDataDirectory appName = do
 #endif
 
 #if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
-foreign import stdcall unsafe "SHGetFolderPath" 
+foreign import stdcall unsafe "SHGetFolderPathA"
             c_SHGetFolderPath :: Ptr () 
                               -> CInt 
                               -> Ptr () 
                               -> CInt 
                               -> CString 
                               -> IO CInt
+
+foreign import ccall unsafe "__hscore_long_path_size"
+  long_path_size :: Int
+
+foreign import ccall unsafe "__hscore_CSIDL_APPDATA"  csidl_APPDATA  :: CInt
 #endif
diff --git a/ghc/lib/compat/cbits/directory.c b/ghc/lib/compat/cbits/directory.c
new file mode 100644 (file)
index 0000000..713911b
--- /dev/null
@@ -0,0 +1,54 @@
+#if __GLASGOW_HASKELL__ < 603\r
+#include "config.h"\r
+#else\r
+#include "ghcconfig.h"\r
+#endif\r
+\r
+#include "HsFFI.h"\r
+\r
+#if HAVE_LIMITS_H\r
+#include <limits.h>\r
+#endif\r
+#if HAVE_WINDOWS_H\r
+#include <windows.h>\r
+#endif\r
+\r
+#define INLINE /* nothing */\r
+\r
+/*\r
+ * Following code copied from libraries/base/includes/HsBase.h\r
+ */\r
+\r
+#ifdef PATH_MAX\r
+/* A size that will contain many path names, but not necessarily all\r
+ * (PATH_MAX is not defined on systems with unlimited path length,\r
+ * e.g. the Hurd).\r
+ */\r
+INLINE HsInt __hscore_long_path_size() { return PATH_MAX; }\r
+#else\r
+INLINE HsInt __hscore_long_path_size() { return 4096; }\r
+#endif\r
+\r
+#if defined(mingw32_TARGET_OS)\r
+\r
+/* Make sure we've got the reqd CSIDL_ constants in scope;\r
+ * w32api header files are lagging a bit in defining the full set.\r
+ */\r
+#if !defined(CSIDL_APPDATA)\r
+#define CSIDL_APPDATA 0x001a\r
+#endif\r
+#if !defined(CSIDL_PERSONAL)\r
+#define CSIDL_PERSONAL 0x0005\r
+#endif\r
+#if !defined(CSIDL_PROFILE)\r
+#define CSIDL_PROFILE 0x0028\r
+#endif\r
+#if !defined(CSIDL_WINDOWS)\r
+#define CSIDL_WINDOWS 0x0024\r
+#endif\r
+\r
+INLINE int __hscore_CSIDL_PROFILE()  { return CSIDL_PROFILE;  }\r
+INLINE int __hscore_CSIDL_APPDATA()  { return CSIDL_APPDATA;  }\r
+INLINE int __hscore_CSIDL_WINDOWS()  { return CSIDL_WINDOWS;  }\r
+INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }\r
+#endif\r