Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides a data type for representing directories/files in a well-typed and convenient way. This is useful to gather and save information about a file, so the information can be easily processed in e.g. a GUI.
However, it's not meant to be used to interact with low-level functions that copy files etc, since there's no guarantee that the in-memory representation of the type still matches what is happening on filesystem level.
If you interact with low-level libraries, you must not pattern
match on the `File a` type. Instead, you should only use the saved
path
and make no assumptions about the file the path might or
might not point to.
- data File a
- data FileInfo = FileInfo {
- deviceID :: !DeviceID
- fileID :: !FileID
- fileMode :: !FileMode
- linkCount :: !LinkCount
- fileOwner :: !UserID
- fileGroup :: !GroupID
- specialDeviceID :: !DeviceID
- fileSize :: !FileOffset
- accessTime :: !EpochTime
- modificationTime :: !EpochTime
- statusChangeTime :: !EpochTime
- accessTimeHiRes :: !POSIXTime
- modificationTimeHiRes :: !POSIXTime
- statusChangeTimeHiRes :: !POSIXTime
- sfileLike :: File FileInfo -> (Bool, File FileInfo)
- fileLike :: File FileInfo -> (Bool, File FileInfo)
- sdir :: File FileInfo -> (Bool, File FileInfo)
- pattern FileLike :: File FileInfo -> File FileInfo
- pattern DirList :: [File FileInfo] -> [File FileInfo]
- pattern FileLikeList :: [File FileInfo] -> [File FileInfo]
- brokenSymlink :: File FileInfo -> (Bool, File FileInfo)
- fileLikeSym :: File FileInfo -> (Bool, File FileInfo)
- dirSym :: File FileInfo -> (Bool, File FileInfo)
- pattern FileLikeSym :: File FileInfo -> File FileInfo
- pattern BrokenSymlink :: File FileInfo -> File FileInfo
- pattern DirOrSym :: File FileInfo -> File FileInfo
- pattern DirSym :: File FileInfo -> File FileInfo
- pattern FileLikeOrSym :: File FileInfo -> File FileInfo
- readFile :: (Path Abs -> IO a) -> Path Abs -> IO (File a)
- readDirectoryContents :: (Path Abs -> IO a) -> Path Abs -> IO [File a]
- getContents :: (Path Abs -> IO a) -> File FileInfo -> IO [File a]
- goUp :: File FileInfo -> IO (File FileInfo)
- goUp' :: Path Abs -> IO (File FileInfo)
- comparingConstr :: File FileInfo -> File FileInfo -> Ordering
- isFileC :: File a -> Bool
- isDirC :: File a -> Bool
- isSymC :: File a -> Bool
- isBlockC :: File a -> Bool
- isCharC :: File a -> Bool
- isNamedC :: File a -> Bool
- isSocketC :: File a -> Bool
- getFileInfo :: Path Abs -> IO FileInfo
- isBrokenSymlink :: File FileInfo -> Bool
- packModTime :: File FileInfo -> String
- packAccessTime :: File FileInfo -> String
- epochToString :: EpochTime -> String
- packPermissions :: File FileInfo -> String
- packFileType :: File a -> String
- packLinkDestination :: File a -> Maybe ByteString
- getFPasStr :: File a -> String
Documentation
The String in the path field is always a full path. The free type variable is used in the File/Dir constructor and can hold Handles, Strings representing a file's contents or anything else you can think of.
Low-level file information.
FileInfo | |
|
pattern FileLike :: File FileInfo -> File FileInfo Source
Matches on any non-directory kind of files, excluding symlinks.
pattern DirList :: [File FileInfo] -> [File FileInfo] Source
Matches a list of directories or symlinks pointing to directories.
pattern FileLikeList :: [File FileInfo] -> [File FileInfo] Source
Matches a list of any non-directory kind of files or symlinks pointing to such.
pattern FileLikeSym :: File FileInfo -> File FileInfo Source
Matches on symlinks pointing to file-like files only.
pattern DirOrSym :: File FileInfo -> File FileInfo Source
Matches on directories or symlinks pointing to directories. If the symlink is pointing to a symlink pointing to a directory, then it will return True, but also return the first element in the symlink- chain, not the last.
pattern DirSym :: File FileInfo -> File FileInfo Source
Matches on symlinks pointing to directories only.
pattern FileLikeOrSym :: File FileInfo -> File FileInfo Source
Matches on any non-directory kind of files or symlinks pointing to such. If the symlink is pointing to a symlink pointing to such a file, then it will return True, but also return the first element in the symlink- chain, not the last.
readFile :: (Path Abs -> IO a) -> Path Abs -> IO (File a) Source
Reads a file or directory Path into an AnchoredFile
, filling the free
variables via the given function.
Get the contents of a given directory and return them as a list
of AnchoredFile
.
getContents :: (Path Abs -> IO a) -> File FileInfo -> IO [File a] Source
A variant of readDirectoryContents
where the second argument
is a File
. If a non-directory is passed returns an empty list.
getFileInfo :: Path Abs -> IO FileInfo Source
Gets all file information.
isBrokenSymlink :: File FileInfo -> Bool Source
Checks if a symlink is broken by examining the constructor of the symlink destination.
When called on a non-symlink, returns False.
packModTime :: File FileInfo -> String Source
Pack the modification time into a string.
packAccessTime :: File FileInfo -> String Source
Pack the modification time into a string.
epochToString :: EpochTime -> String Source
packPermissions :: File FileInfo -> String Source
Pack the permissions into a string, similar to what "ls -l" does.
packFileType :: File a -> String Source
packLinkDestination :: File a -> Maybe ByteString Source
getFPasStr :: File a -> String Source