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

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

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

ioeAddLocation :: IOError -> String -> IOError Source #

data FileType Source #

Constructors

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

Instances

Bounded FileType # |
Instance details Methods minBound :: FileType Source # maxBound :: FileType Source #
Enum FileType # |
Instance details 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 Methods (==) :: FileType -> FileType -> Bool # (/=) :: FileType -> FileType -> Bool #
Ord FileType # |
Instance details 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 Methods readsPrec :: Int -> ReadS FileType Source # readList :: ReadS [FileType] Source # readPrec :: ReadPrec FileType Source # readListPrec :: ReadPrec [FileType] Source #
Show FileType # |
Instance details Methods showsPrec :: Int -> FileType -> ShowS Source # show :: FileType -> String Source # showList :: [FileType] -> ShowS Source #

fileTypeIsDirectory :: FileType -> Bool Source #

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 Source #

Constructors

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

Instances

Eq Permissions # |
Instance details Methods (==) :: Permissions -> Permissions -> Bool # (/=) :: Permissions -> Permissions -> Bool #
Ord Permissions # |
Instance details 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 Methods readsPrec :: Int -> ReadS Permissions Source # readList :: ReadS [Permissions] Source # readPrec :: ReadPrec Permissions Source # readListPrec :: ReadPrec [Permissions] Source #
Show Permissions # |
Instance details Methods showsPrec :: Int -> Permissions -> ShowS Source # show :: Permissions -> String Source # showList :: [Permissions] -> ShowS Source #

getCurrentDirectory :: IO FilePath Source #

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 Source #

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

c_PATH_MAX :: Maybe Int Source #

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

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

type Metadata = FileStatus Source #

getSymbolicLinkMetadata :: FilePath -> IO Metadata Source #

getFileMetadata :: FilePath -> IO Metadata Source #

fileTypeFromMetadata :: Metadata -> FileType Source #

fileSizeFromMetadata :: Metadata -> Integer Source #

accessTimeFromMetadata :: Metadata -> UTCTime Source #

modificationTimeFromMetadata :: Metadata -> UTCTime Source #

posix_accessTimeHiRes :: FileStatus -> POSIXTime Source #

posix_modificationTimeHiRes :: FileStatus -> POSIXTime Source #

type Mode = FileMode Source #

modeFromMetadata :: Metadata -> Mode Source #

allWriteMode :: FileMode Source #

hasWriteMode :: Mode -> Bool Source #

setWriteMode :: Bool -> Mode -> Mode Source #

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

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

getAccessPermissions :: FilePath -> IO Permissions Source #

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

data CTimeSpec Source #

Constructors

CTimeSpec EpochTime CLong |

Instances

Storable CTimeSpec # |
Instance details 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 Source #

utimeOmit :: CTimeSpec Source #

toCTimeSpec :: POSIXTime -> CTimeSpec Source #

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