2 -----------------------------------------------------------------------------
4 -- Module : Compat.Directory
5 -- Copyright : (c) The University of Glasgow 2001-2004
6 -- License : BSD-style (see the file libraries/base/LICENSE)
8 -- Maintainer : libraries@haskell.org
9 -- Stability : provisional
10 -- Portability : portable
12 -- Functions from System.Directory that aren't present in older versions
15 -----------------------------------------------------------------------------
17 module Compat.Directory (
18 getAppUserDataDirectory,
21 #if __GLASGOW_HASKELL__ < 603
25 #if !defined(mingw32_TARGET_OS)
26 import System.Environment (getEnv)
32 getAppUserDataDirectory :: String -> IO FilePath
33 getAppUserDataDirectory appName = do
34 #if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
35 allocaBytes long_path_size $ \pPath -> do
36 r <- c_SHGetFolderPath nullPtr csidl_APPDATA nullPtr 0 pPath
37 s <- peekCString pPath
38 return (s++'\\':appName)
41 return (path++'/':'.':appName)
44 #if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
45 foreign import stdcall unsafe "SHGetFolderPathA"
46 c_SHGetFolderPath :: Ptr ()
53 foreign import ccall unsafe "__hscore_long_path_size"
56 foreign import ccall unsafe "__hscore_CSIDL_APPDATA" csidl_APPDATA :: CInt