System.Directory.Internal

directory-1.3.3.0: Platform-agnostic library for filesystem operations

Stability | unstable
Portability | unportable
Safe Haskell | Safe
Language | Haskell2010

System.Directory.Internal

Description

Internal modules are always subject to change from version to version. The contents of this module are also platform-dependent, hence what is shown in the Hackage documentation may differ from what is actually available on your system.

Synopsis

- newtype ListT m a = ListT {
  - unListT :: m (Maybe (a, ListT m a))
  }
- emptyListT :: Applicative m => ListT m a
- maybeToListT :: Applicative m => m (Maybe a) -> ListT m a
- listToListT :: Applicative m => [a] -> ListT m a
- liftJoinListT :: Monad m => m (ListT m a) -> ListT m a
- listTHead :: Functor m => ListT m a -> m (Maybe a)
- listTToList :: Monad m => ListT m a -> m [a]
- andM :: Monad m => m Bool -> m Bool -> m Bool
- sequenceWithIOErrors_ :: [IO ()] -> IO ()
- tryIOErrorType :: (IOError -> Bool) -> IO a -> IO (Either IOError a)
- ignoreIOExceptions :: IO () -> IO ()
- specializeErrorString :: String -> (IOError -> Bool) -> IO a -> IO a
- ioeAddLocation :: IOError -> String -> IOError
- data FileType
  - = File
  - | SymbolicLink
  - | Directory
  - | DirectoryLink
- fileTypeIsDirectory :: FileType -> Bool
- fileTypeIsLink :: FileType -> Bool
- data Permissions = Permissions {
  - readable :: Bool
  - writable :: Bool
  - executable :: Bool
  - searchable :: Bool
  }
- prependCurrentDirectoryWith :: IO FilePath -> FilePath -> IO FilePath
- copyFileContents :: FilePath -> FilePath -> IO ()
- copyFileToHandle :: FilePath -> Handle -> IO ()
- copyHandleData :: Handle -> Handle -> IO ()
- data XdgDirectory
  - = XdgData
  - | XdgConfig
  - | XdgCache
- data XdgDirectoryList
  - = XdgDataDirs
  - | XdgConfigDirs
- createDirectoryInternal :: FilePath -> IO ()
- removePathInternal :: Bool -> FilePath -> IO ()
- renamePathInternal :: FilePath -> FilePath -> IO ()
- c_free :: Ptr a -> IO ()
- c_PATH_MAX :: Maybe Int
- c_realpath :: CString -> CString -> IO CString
- withRealpath :: CString -> (CString -> IO a) -> IO a
- canonicalizePathWith :: ((FilePath -> IO FilePath) -> FilePath -> IO FilePath) -> FilePath -> IO FilePath
- canonicalizePathSimplify :: FilePath -> IO FilePath
- findExecutablesLazyInternal :: ([FilePath] -> String -> ListT IO FilePath) -> String -> ListT IO FilePath
- exeExtensionInternal :: String
- getDirectoryContentsInternal :: FilePath -> IO [FilePath]
- getCurrentDirectoryInternal :: IO FilePath
- prependCurrentDirectory :: FilePath -> IO FilePath
- setCurrentDirectoryInternal :: FilePath -> IO ()
- linkToDirectoryIsDirectory :: Bool
- createSymbolicLink :: Bool -> FilePath -> FilePath -> IO ()
- readSymbolicLink :: FilePath -> IO FilePath
- type Metadata = FileStatus
- getSymbolicLinkMetadata :: FilePath -> IO Metadata
- getFileMetadata :: FilePath -> IO Metadata
- fileTypeFromMetadata :: Metadata -> FileType
- fileSizeFromMetadata :: Metadata -> Integer
- accessTimeFromMetadata :: Metadata -> UTCTime
- modificationTimeFromMetadata :: Metadata -> UTCTime
- posix_accessTimeHiRes :: FileStatus -> POSIXTime
- posix_modificationTimeHiRes :: FileStatus -> POSIXTime
- type Mode = FileMode
- modeFromMetadata :: Metadata -> Mode
- allWriteMode :: FileMode
- hasWriteMode :: Mode -> Bool
- setWriteMode :: Bool -> Mode -> Mode
- setFileMode :: FilePath -> Mode -> IO ()
- setFilePermissions :: FilePath -> Mode -> IO ()
- getAccessPermissions :: FilePath -> IO Permissions
- setAccessPermissions :: FilePath -> Permissions -> IO ()
- copyOwnerFromStatus :: FileStatus -> FilePath -> IO ()
- copyGroupFromStatus :: FileStatus -> FilePath -> IO ()
- tryCopyOwnerAndGroupFromStatus :: FileStatus -> FilePath -> IO ()
- copyFileWithMetadataInternal :: (Metadata -> FilePath -> IO ()) -> (Metadata -> FilePath -> IO ()) -> FilePath -> FilePath -> IO ()
- setTimes :: FilePath -> (Maybe POSIXTime, Maybe POSIXTime) -> IO ()
- getPath :: IO [FilePath]
- getHomeDirectoryInternal :: IO FilePath
- getXdgDirectoryInternal :: IO FilePath -> XdgDirectory -> IO FilePath
- getXdgDirectoryListInternal :: XdgDirectoryList -> IO [FilePath]
- getAppUserDataDirectoryInternal :: FilePath -> IO FilePath
- getUserDocumentsDirectoryInternal :: IO FilePath
- getTemporaryDirectoryInternal :: IO FilePath

# Documentation

newtype ListT m a #

A generator with side-effects.

Constructors

ListT |
Fields unListT :: m (Maybe (a, ListT m a))

emptyListT :: Applicative m => ListT m a #

maybeToListT :: Applicative m => m (Maybe a) -> ListT m a #

listToListT :: Applicative m => [a] -> ListT m a #

liftJoinListT :: Monad m => m (ListT m a) -> ListT m a #

listTHead :: Functor m => ListT m a -> m (Maybe a) #

listTToList :: Monad m => ListT m a -> m [a] #

andM :: Monad m => m Bool -> m Bool -> m Bool #

sequenceWithIOErrors_ :: [IO ()] -> IO () #

tryIOErrorType :: (IOError -> Bool) -> IO a -> IO (Either IOError a) #

Similar to `try` but only catches a specify kind of `IOError` as specified by the predicate.

ignoreIOExceptions :: IO () -> IO () #

Attempt to perform the given action, silencing any IO exception thrown by it.

specializeErrorString :: String -> (IOError -> Bool) -> IO a -> IO a #

ioeAddLocation :: IOError -> String -> IOError #

data FileType #

Constructors

File |
SymbolicLink | POSIX: either file or directory link; Windows: file link
Directory |
DirectoryLink | Windows only: directory link

Instances

Bounded FileType # |
Instance details Defined in System.Directory.Internal.Common Methods minBound :: FileType Source # maxBound :: FileType Source #
Enum FileType # |
Instance details Defined in System.Directory.Internal.Common Methods succ :: FileType -> FileType Source # pred :: FileType -> FileType Source # toEnum :: Int -> FileType Source # fromEnum :: FileType -> Int Source # enumFrom :: FileType -> [FileType] Source # enumFromThen :: FileType -> FileType -> [FileType] Source # enumFromTo :: FileType -> FileType -> [FileType] Source # enumFromThenTo :: FileType -> FileType -> FileType -> [FileType] Source #
Eq FileType # |
Instance details Defined in System.Directory.Internal.Common Methods (==) :: FileType -> FileType -> Bool # (/=) :: FileType -> FileType -> Bool #
Ord FileType # |
Instance details Defined in System.Directory.Internal.Common Methods compare :: FileType -> FileType -> Ordering # (<) :: FileType -> FileType -> Bool # (<=) :: FileType -> FileType -> Bool # (>) :: FileType -> FileType -> Bool # (>=) :: FileType -> FileType -> Bool # max :: FileType -> FileType -> FileType # min :: FileType -> FileType -> FileType #
Read FileType # |
Instance details Defined in System.Directory.Internal.Common Methods readsPrec :: Int -> ReadS FileType Source # readList :: ReadS [FileType] Source # readPrec :: ReadPrec FileType Source # readListPrec :: ReadPrec [FileType] Source #
Show FileType # |
Instance details Defined in System.Directory.Internal.Common Methods showsPrec :: Int -> FileType -> ShowS Source # show :: FileType -> String Source # showList :: [FileType] -> ShowS Source #

fileTypeIsDirectory :: FileType -> Bool #

Check whether the given `FileType` is considered a directory by the operating system. This affects the choice of certain functions e.g. `removeDirectory` vs `removeFile`.

fileTypeIsLink :: FileType -> Bool #

Return whether the given `FileType` is a link.

data Permissions #

Constructors

Permissions |
Fields readable :: Bool writable :: Bool executable :: Bool searchable :: Bool

Instances

Eq Permissions # |
Instance details Defined in System.Directory.Internal.Common Methods (==) :: Permissions -> Permissions -> Bool # (/=) :: Permissions -> Permissions -> Bool #
Ord Permissions # |
Instance details Defined in System.Directory.Internal.Common Methods compare :: Permissions -> Permissions -> Ordering # (<) :: Permissions -> Permissions -> Bool # (<=) :: Permissions -> Permissions -> Bool # (>) :: Permissions -> Permissions -> Bool # (>=) :: Permissions -> Permissions -> Bool # max :: Permissions -> Permissions -> Permissions # min :: Permissions -> Permissions -> Permissions #
Read Permissions # |
Instance details Defined in System.Directory.Internal.Common Methods readsPrec :: Int -> ReadS Permissions Source # readList :: ReadS [Permissions] Source # readPrec :: ReadPrec Permissions Source # readListPrec :: ReadPrec [Permissions] Source #
Show Permissions # |
Instance details Defined in System.Directory.Internal.Common Methods showsPrec :: Int -> Permissions -> ShowS Source # show :: Permissions -> String Source # showList :: [Permissions] -> ShowS Source #

prependCurrentDirectoryWith :: IO FilePath -> FilePath -> IO FilePath #

Convert a path into an absolute path. If the given path is relative, the current directory is prepended. If the path is already absolute, the path is returned unchanged. The function preserves the presence or absence of the trailing path separator.

If the path is already absolute, the operation never fails. Otherwise, the operation may fail with the same exceptions as `getCurrentDirectory`.

(internal API)

copyFileContents #

Arguments

:: FilePath | Source filename
-> FilePath | Destination filename
-> IO () |

Truncate the destination file and then copy the contents of the source file to the destination file. If the destination file already exists, its attributes shall remain unchanged. Otherwise, its attributes are reset to the defaults.

copyFileToHandle #

Arguments

:: FilePath | Source file
-> Handle | Destination handle
-> IO () |

Copy all data from a file to a handle.

copyHandleData #

Arguments

:: Handle | Source handle
-> Handle | Destination handle
-> IO () |

Copy data from one handle to another until end of file.

data XdgDirectory #

Special directories for storing user-specific application data, configuration, and cache files, as specified by the XDG Base Directory Specification.

Note: On Windows, `XdgData` and `XdgConfig` map to the same directory.

Since: directory-1.2.3.0

Constructors

XdgData | For data files (e.g. images). Defaults to `~/.local/share` and can be overridden by the `XDG_DATA_HOME` environment variable. On Windows, it is `%APPDATA%` (e.g. `C:/Users/<user>/AppData/Roaming`). Can be considered as the user-specific equivalent of `/usr/share`.
XdgConfig | For configuration files. Defaults to `~/.config` and can be overridden by the `XDG_CONFIG_HOME` environment variable. On Windows, it is `%APPDATA%` (e.g. `C:/Users/<user>/AppData/Roaming`). Can be considered as the user-specific equivalent of `/etc`.
XdgCache | For non-essential files (e.g. cache). Defaults to `~/.cache` and can be overridden by the `XDG_CACHE_HOME` environment variable. On Windows, it is `%LOCALAPPDATA%` (e.g. `C:/Users/<user>/AppData/Local`). Can be considered as the user-specific equivalent of `/var/cache`.

Instances

Bounded XdgDirectory # |
Instance details Defined in System.Directory.Internal.Common Methods minBound :: XdgDirectory Source # maxBound :: XdgDirectory Source #
Enum XdgDirectory # |
Instance details Defined in System.Directory.Internal.Common Methods succ :: XdgDirectory -> XdgDirectory Source # pred :: XdgDirectory -> XdgDirectory Source # toEnum :: Int -> XdgDirectory Source # fromEnum :: XdgDirectory -> Int Source # enumFrom :: XdgDirectory -> [XdgDirectory] Source # enumFromThen :: XdgDirectory -> XdgDirectory -> [XdgDirectory] Source # enumFromTo :: XdgDirectory -> XdgDirectory -> [XdgDirectory] Source # enumFromThenTo :: XdgDirectory -> XdgDirectory -> XdgDirectory -> [XdgDirectory] Source #
Eq XdgDirectory # |
Instance details Defined in System.Directory.Internal.Common Methods (==) :: XdgDirectory -> XdgDirectory -> Bool # (/=) :: XdgDirectory -> XdgDirectory -> Bool #
Ord XdgDirectory # |
Instance details Defined in System.Directory.Internal.Common Methods compare :: XdgDirectory -> XdgDirectory -> Ordering # (<) :: XdgDirectory -> XdgDirectory -> Bool # (<=) :: XdgDirectory -> XdgDirectory -> Bool # (>) :: XdgDirectory -> XdgDirectory -> Bool # (>=) :: XdgDirectory -> XdgDirectory -> Bool # max :: XdgDirectory -> XdgDirectory -> XdgDirectory # min :: XdgDirectory -> XdgDirectory -> XdgDirectory #
Read XdgDirectory # |
Instance details Defined in System.Directory.Internal.Common Methods readsPrec :: Int -> ReadS XdgDirectory Source # readList :: ReadS [XdgDirectory] Source # readPrec :: ReadPrec XdgDirectory Source # readListPrec :: ReadPrec [XdgDirectory] Source #
Show XdgDirectory # |
Instance details Defined in System.Directory.Internal.Common Methods showsPrec :: Int -> XdgDirectory -> ShowS Source # show :: XdgDirectory -> String Source # showList :: [XdgDirectory] -> ShowS Source #

data XdgDirectoryList #

Search paths for various application data, as specified by the XDG Base Directory Specification.

Note: On Windows, `XdgDataDirs` and `XdgConfigDirs` yield the same result.

Since: directory-1.3.2.0

Constructors

XdgDataDirs | For data files (e.g. images). Defaults to `usrlocalshare` and `usrshare/` and can be overridden by the `XDG_DATA_DIRS` environment variable. On Windows, it is `%PROGRAMDATA%` or `%ALLUSERSPROFILE%` (e.g. `C:/ProgramData`).
XdgConfigDirs | For configuration files. Defaults to `etcxdg` and can be overridden by the `XDG_CONFIG_DIRS` environment variable. On Windows, it is `%PROGRAMDATA%` or `%ALLUSERSPROFILE%` (e.g. `C:/ProgramData`).

Instances

Bounded XdgDirectoryList # |
Instance details Defined in System.Directory.Internal.Common Methods minBound :: XdgDirectoryList Source # maxBound :: XdgDirectoryList Source #
Enum XdgDirectoryList # |
Instance details Defined in System.Directory.Internal.Common Methods succ :: XdgDirectoryList -> XdgDirectoryList Source # pred :: XdgDirectoryList -> XdgDirectoryList Source # toEnum :: Int -> XdgDirectoryList Source # fromEnum :: XdgDirectoryList -> Int Source # enumFrom :: XdgDirectoryList -> [XdgDirectoryList] Source # enumFromThen :: XdgDirectoryList -> XdgDirectoryList -> [XdgDirectoryList] Source # enumFromTo :: XdgDirectoryList -> XdgDirectoryList -> [XdgDirectoryList] Source # enumFromThenTo :: XdgDirectoryList -> XdgDirectoryList -> XdgDirectoryList -> [XdgDirectoryList] Source #
Eq XdgDirectoryList # |
Instance details Defined in System.Directory.Internal.Common Methods (==) :: XdgDirectoryList -> XdgDirectoryList -> Bool # (/=) :: XdgDirectoryList -> XdgDirectoryList -> Bool #
Ord XdgDirectoryList # |
Instance details Defined in System.Directory.Internal.Common Methods compare :: XdgDirectoryList -> XdgDirectoryList -> Ordering # (<) :: XdgDirectoryList -> XdgDirectoryList -> Bool # (<=) :: XdgDirectoryList -> XdgDirectoryList -> Bool # (>) :: XdgDirectoryList -> XdgDirectoryList -> Bool # (>=) :: XdgDirectoryList -> XdgDirectoryList -> Bool # max :: XdgDirectoryList -> XdgDirectoryList -> XdgDirectoryList # min :: XdgDirectoryList -> XdgDirectoryList -> XdgDirectoryList #
Read XdgDirectoryList # |
Instance details Defined in System.Directory.Internal.Common Methods readsPrec :: Int -> ReadS XdgDirectoryList Source # readList :: ReadS [XdgDirectoryList] Source # readPrec :: ReadPrec XdgDirectoryList Source # readListPrec :: ReadPrec [XdgDirectoryList] Source #
Show XdgDirectoryList # |
Instance details Defined in System.Directory.Internal.Common Methods showsPrec :: Int -> XdgDirectoryList -> ShowS Source # show :: XdgDirectoryList -> String Source # showList :: [XdgDirectoryList] -> ShowS Source #

createDirectoryInternal :: FilePath -> IO () #

removePathInternal :: Bool -> FilePath -> IO () #

renamePathInternal :: FilePath -> FilePath -> IO () #

c_free :: Ptr a -> IO () #

c_PATH_MAX :: Maybe Int #

c_realpath :: CString -> CString -> IO CString #

withRealpath :: CString -> (CString -> IO a) -> IO a #

canonicalizePathWith :: ((FilePath -> IO FilePath) -> FilePath -> IO FilePath) -> FilePath -> IO FilePath #

canonicalizePathSimplify :: FilePath -> IO FilePath #

findExecutablesLazyInternal :: ([FilePath] -> String -> ListT IO FilePath) -> String -> ListT IO FilePath #

exeExtensionInternal :: String #

getDirectoryContentsInternal :: FilePath -> IO [FilePath] #

getCurrentDirectoryInternal :: IO FilePath #

prependCurrentDirectory :: FilePath -> IO FilePath #

setCurrentDirectoryInternal :: FilePath -> IO () #

linkToDirectoryIsDirectory :: Bool #

createSymbolicLink :: Bool -> FilePath -> FilePath -> IO () #

readSymbolicLink :: FilePath -> IO FilePath #

type Metadata = FileStatus #

getSymbolicLinkMetadata :: FilePath -> IO Metadata #

getFileMetadata :: FilePath -> IO Metadata #

fileTypeFromMetadata :: Metadata -> FileType #

fileSizeFromMetadata :: Metadata -> Integer #

accessTimeFromMetadata :: Metadata -> UTCTime #

modificationTimeFromMetadata :: Metadata -> UTCTime #

posix_accessTimeHiRes :: FileStatus -> POSIXTime #

posix_modificationTimeHiRes :: FileStatus -> POSIXTime #

type Mode = FileMode #

modeFromMetadata :: Metadata -> Mode #

allWriteMode :: FileMode #

hasWriteMode :: Mode -> Bool #

setWriteMode :: Bool -> Mode -> Mode #

setFileMode :: FilePath -> Mode -> IO () #

setFilePermissions :: FilePath -> Mode -> IO () #

getAccessPermissions :: FilePath -> IO Permissions #

setAccessPermissions :: FilePath -> Permissions -> IO () #

copyOwnerFromStatus :: FileStatus -> FilePath -> IO () #

copyGroupFromStatus :: FileStatus -> FilePath -> IO () #

tryCopyOwnerAndGroupFromStatus :: FileStatus -> FilePath -> IO () #

copyFileWithMetadataInternal :: (Metadata -> FilePath -> IO ()) -> (Metadata -> FilePath -> IO ()) -> FilePath -> FilePath -> IO () #

setTimes :: FilePath -> (Maybe POSIXTime, Maybe POSIXTime) -> IO () #

getPath :: IO [FilePath] #

Get the contents of the `PATH` environment variable.

getHomeDirectoryInternal :: IO FilePath #

getXdgDirectoryInternal :: IO FilePath -> XdgDirectory -> IO FilePath #

getXdgDirectoryListInternal :: XdgDirectoryList -> IO [FilePath] #

getAppUserDataDirectoryInternal :: FilePath -> IO FilePath #

getUserDocumentsDirectoryInternal :: IO FilePath #

getTemporaryDirectoryInternal :: IO FilePath #