summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorsimonmar <unknown>2004-11-11 17:21:02 +0000
committersimonmar <unknown>2004-11-11 17:21:02 +0000
commitd8cde19805cd0ee6460b5a4d47e23a10adc7d261 (patch)
tree38124cf9c68d856416d42b6f8d59e129aeb34b93 /ghc
parenta97485bf60621de28bf828d20a5de265cc2de882 (diff)
downloadhaskell-d8cde19805cd0ee6460b5a4d47e23a10adc7d261.tar.gz
[project @ 2004-11-11 17:21:02 by simonmar]
add missing file
Diffstat (limited to 'ghc')
-rw-r--r--ghc/lib/compat/Compat/Directory.hs49
1 files changed, 49 insertions, 0 deletions
diff --git a/ghc/lib/compat/Compat/Directory.hs b/ghc/lib/compat/Compat/Directory.hs
new file mode 100644
index 0000000000..6ec4af54cc
--- /dev/null
+++ b/ghc/lib/compat/Compat/Directory.hs
@@ -0,0 +1,49 @@
+{-# OPTIONS -cpp #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module : Compat.Directory
+-- Copyright : (c) The University of Glasgow 2001-2004
+-- License : BSD-style (see the file libraries/base/LICENSE)
+--
+-- Maintainer : libraries@haskell.org
+-- Stability : provisional
+-- Portability : portable
+--
+-- Functions from System.Directory that aren't present in older versions
+-- of that library.
+--
+-----------------------------------------------------------------------------
+
+module Compat.Directory (
+ getAppUserDataDirectory,
+ ) where
+
+#if __GLASGOW_HASKELL__ < 603
+#include "config.h"
+#endif
+
+#if !defined(mingw32_TARGET_OS)
+import System.Environment (getEnv)
+#endif
+
+getAppUserDataDirectory :: String -> IO FilePath
+getAppUserDataDirectory appName = do
+#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+ allocaBytes long_path_size $ \pPath -> do
+ r <- c_SHGetFolderPath nullPtr csidl_APPDATA nullPtr 0 pPath
+ s <- peekCString pPath
+ return (s++'\\':appName)
+#else
+ path <- getEnv "HOME"
+ return (path++'/':'.':appName)
+#endif
+
+#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+foreign import stdcall unsafe "SHGetFolderPath"
+ c_SHGetFolderPath :: Ptr ()
+ -> CInt
+ -> Ptr ()
+ -> CInt
+ -> CString
+ -> IO CInt
+#endif