#if !defined(mingw32_TARGET_OS)
import System.Environment (getEnv)
+#else
+import Foreign
+import Foreign.C
#endif
getAppUserDataDirectory :: String -> IO FilePath
#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
--- /dev/null
+#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