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)
29 getAppUserDataDirectory :: String -> IO FilePath
30 getAppUserDataDirectory appName = do
31 #if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
32 allocaBytes long_path_size $ \pPath -> do
33 r <- c_SHGetFolderPath nullPtr csidl_APPDATA nullPtr 0 pPath
34 s <- peekCString pPath
35 return (s++'\\':appName)
38 return (path++'/':'.':appName)
41 #if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
42 foreign import stdcall unsafe "SHGetFolderPath"
43 c_SHGetFolderPath :: Ptr ()