{-# LINE 1 "System\\Win32\\WindowsString\\Info.hsc" #-}----------------------------------------------------------------------------- -- | -- Module : System.Win32.Info -- Copyright : (c) Alastair Reid, 1997-2003 -- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : Esa Ilari Vuokko <ei@vuokko.info> -- Stability : provisional -- Portability : portable -- -- A collection of FFI declarations for interfacing with Win32. -- ----------------------------------------------------------------------------- moduleSystem.Win32.WindowsString.Info(moduleSystem.Win32.WindowsString.Info,moduleSystem.Win32.Info)whereimportSystem.Win32.Info.InternalimportSystem.Win32.Infohiding(getSystemDirectory,getWindowsDirectory,getCurrentDirectory,getTemporaryDirectory,getFullPathName,getLongPathName,getShortPathName,searchPath,getUserName)importControl.Exception(catch)importForeign.Marshal.Alloc(alloca)importForeign.Marshal.Utils(with,maybeWith)importForeign.Marshal.Array(allocaArray)importForeign.Ptr(nullPtr)importForeign.Storable(Storable(..))importSystem.IO.Error(isDoesNotExistError)importSystem.Win32.WindowsString.Types(failIfFalse_,peekTStringLen,withTString,try)importSystem.OsPath.Windows{-# LINE 45 "System\\Win32\\WindowsString\\Info.hsc" #-} #include "windows_cconv.h" ---------------------------------------------------------------- -- Standard Directories ---------------------------------------------------------------- getSystemDirectory::IOWindowsStringgetSystemDirectory=try"GetSystemDirectory"c_getSystemDirectory512getWindowsDirectory::IOWindowsStringgetWindowsDirectory=try"GetWindowsDirectory"c_getWindowsDirectory512getCurrentDirectory::IOWindowsStringgetCurrentDirectory=try"GetCurrentDirectory"(flipc_getCurrentDirectory)512getTemporaryDirectory::IOWindowsStringgetTemporaryDirectory=try"GetTempPath"(flipc_getTempPath)512getFullPathName::WindowsPath->IOWindowsPathgetFullPathNamename=dowithTStringname$\c_name->try"getFullPathName"(\buflen->c_GetFullPathNamec_namelenbufnullPtr)512getLongPathName::WindowsPath->IOWindowsPathgetLongPathNamename=dowithTStringname$\c_name->try"getLongPathName"(c_GetLongPathNamec_name)512getShortPathName::WindowsPath->IOWindowsPathgetShortPathNamename=dowithTStringname$\c_name->try"getShortPathName"(c_GetShortPathNamec_name)512searchPath::MaybeWindowsString->WindowsPath->MaybeWindowsString->IO(MaybeWindowsPath)searchPathpathfilenameext=maybe($nullPtr)withTStringpath$\p_path->withTStringfilename$\p_filename->maybeWithwithTStringext$\p_ext->alloca$\ppFilePart->(dos<-try"searchPath"(\buflen->c_SearchPathp_pathp_filenamep_extlenbufppFilePart)512return(Justs))`catch`\e->ifisDoesNotExistErrorethenreturnNothingelseioErrore---------------------------------------------------------------- -- User name ---------------------------------------------------------------- -- %fun GetUserName :: IO String getUserName::IOWindowsStringgetUserName=allocaArray512$\c_str->with512$\c_len->dofailIfFalse_"GetUserName"$c_GetUserNamec_strc_lenlen<-peekc_lenpeekTStringLen(c_str,fromIntegrallen-1)---------------------------------------------------------------- -- End ----------------------------------------------------------------