From d8cde19805cd0ee6460b5a4d47e23a10adc7d261 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 11 Nov 2004 17:21:02 +0000 Subject: [PATCH] [project @ 2004-11-11 17:21:02 by simonmar] add missing file --- ghc/lib/compat/Compat/Directory.hs | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 ghc/lib/compat/Compat/Directory.hs diff --git a/ghc/lib/compat/Compat/Directory.hs b/ghc/lib/compat/Compat/Directory.hs new file mode 100644 index 0000000..6ec4af5 --- /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 -- 1.7.10.4