System.Directory.Internal

directory-1.3.1.5: 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

- tryIOErrorType :: (IOError -> Bool) -> IO a -> IO (Either IOError a)
- specializeErrorString :: String -> (IOError -> Bool) -> IO a -> IO a
- ioeAddLocation :: IOError -> String -> IOError
- data FileType
  - = File
  - | SymbolicLink
  - | Directory
  - | DirectoryLink
- fileTypeIsDirectory :: FileType -> Bool
- data Permissions = Permissions {
  - readable :: Bool
  - writable :: Bool
  - executable :: Bool
  - searchable :: Bool
  }
- getCurrentDirectory :: IO FilePath
- prependCurrentDirectory :: FilePath -> IO FilePath
- c_free :: Ptr a -> IO ()
- c_PATH_MAX :: Maybe Int
- c_realpath :: CString -> CString -> IO CString
- withRealpath :: CString -> (CString -> IO a) -> IO a
- 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 ()
- data CTimeSpec = CTimeSpec EpochTime CLong
- c_AT_FDCWD :: CInt
- utimeOmit :: CTimeSpec
- toCTimeSpec :: POSIXTime -> CTimeSpec
- c_utimensat :: CInt -> CString -> Ptr CTimeSpec -> CInt -> IO CInt

# Documentation

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.

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

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`.

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 #

getCurrentDirectory :: IO FilePath #

Obtain the current working directory as an absolute path.

In a multithreaded program, the current working directory is a global state shared among all threads of the process. Therefore, when performing filesystem operations from multiple threads, it is highly recommended to use absolute rather than relative paths (see: `makeAbsolute`).

The operation may fail with:

- `HardwareFault` A physical I/O error has occurred. `[EIO]`
- `isDoesNotExistError` or `NoSuchThing` There is no path referring to the working directory. `[EPERM, ENOENT, ESTALE...]`
- `isPermissionError` or `PermissionDenied` The process has insufficient privileges to perform the operation. `[EACCES]`
- `ResourceExhausted` Insufficient resources are available to perform the operation.
- `UnsupportedOperation` The operating system has no notion of current working directory.

prependCurrentDirectory :: 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)

c_free :: Ptr a -> IO () #

c_PATH_MAX :: Maybe Int #

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

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

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 () #

data CTimeSpec #

Constructors

CTimeSpec EpochTime CLong |

Instances

Storable CTimeSpec # |
Instance details Defined in System.Directory.Internal.C_utimensat Methods sizeOf :: CTimeSpec -> Int Source # alignment :: CTimeSpec -> Int Source # peekElemOff :: Ptr CTimeSpec -> Int -> IO CTimeSpec Source # pokeElemOff :: Ptr CTimeSpec -> Int -> CTimeSpec -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTimeSpec Source # pokeByteOff :: Ptr b -> Int -> CTimeSpec -> IO () Source # peek :: Ptr CTimeSpec -> IO CTimeSpec Source # poke :: Ptr CTimeSpec -> CTimeSpec -> IO () Source #

c_AT_FDCWD :: CInt #

utimeOmit :: CTimeSpec #

toCTimeSpec :: POSIXTime -> CTimeSpec #

c_utimensat :: CInt -> CString -> Ptr CTimeSpec -> CInt -> IO CInt #