From b4222d807a49109c613c00f82ce95f9d50bef854 Mon Sep 17 00:00:00 2001 From: simonpj Date: Fri, 12 Nov 2004 13:27:54 +0000 Subject: [PATCH] [project @ 2004-11-12 13:27:54 by simonpj] add bits required for Compat.Directory on Windows --- ghc/lib/compat/Compat/Directory.hs | 10 ++++++- ghc/lib/compat/cbits/directory.c | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 ghc/lib/compat/cbits/directory.c diff --git a/ghc/lib/compat/Compat/Directory.hs b/ghc/lib/compat/Compat/Directory.hs index 6ec4af5..74baec8 100644 --- a/ghc/lib/compat/Compat/Directory.hs +++ b/ghc/lib/compat/Compat/Directory.hs @@ -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 index 0000000..713911b --- /dev/null +++ b/ghc/lib/compat/cbits/directory.c @@ -0,0 +1,54 @@ +#if __GLASGOW_HASKELL__ < 603 +#include "config.h" +#else +#include "ghcconfig.h" +#endif + +#include "HsFFI.h" + +#if HAVE_LIMITS_H +#include +#endif +#if HAVE_WINDOWS_H +#include +#endif + +#define INLINE /* nothing */ + +/* + * Following code copied from libraries/base/includes/HsBase.h + */ + +#ifdef PATH_MAX +/* A size that will contain many path names, but not necessarily all + * (PATH_MAX is not defined on systems with unlimited path length, + * e.g. the Hurd). + */ +INLINE HsInt __hscore_long_path_size() { return PATH_MAX; } +#else +INLINE HsInt __hscore_long_path_size() { return 4096; } +#endif + +#if defined(mingw32_TARGET_OS) + +/* Make sure we've got the reqd CSIDL_ constants in scope; + * w32api header files are lagging a bit in defining the full set. + */ +#if !defined(CSIDL_APPDATA) +#define CSIDL_APPDATA 0x001a +#endif +#if !defined(CSIDL_PERSONAL) +#define CSIDL_PERSONAL 0x0005 +#endif +#if !defined(CSIDL_PROFILE) +#define CSIDL_PROFILE 0x0028 +#endif +#if !defined(CSIDL_WINDOWS) +#define CSIDL_WINDOWS 0x0024 +#endif + +INLINE int __hscore_CSIDL_PROFILE() { return CSIDL_PROFILE; } +INLINE int __hscore_CSIDL_APPDATA() { return CSIDL_APPDATA; } +INLINE int __hscore_CSIDL_WINDOWS() { return CSIDL_WINDOWS; } +INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; } +#endif -- 1.7.10.4