hsfm-gtk

Safe HaskellNone
LanguageHaskell2010

HSFM.FileSystem.FileType

Description

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.

Synopsis

Documentation

data File a Source

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.

Constructors

Dir 

Fields

path :: !(Path Abs)
 
fvar :: a
 
RegFile 

Fields

path :: !(Path Abs)
 
fvar :: a
 
SymLink 

Fields

path :: !(Path Abs)
 
fvar :: a
 
sdest :: Maybe (File a)

symlink madness, we need to know where it points to

rawdest :: !ByteString
 
BlockDev 

Fields

path :: !(Path Abs)
 
fvar :: a
 
CharDev 

Fields

path :: !(Path Abs)
 
fvar :: a
 
NamedPipe 

Fields

path :: !(Path Abs)
 
fvar :: a
 
Socket 

Fields

path :: !(Path Abs)
 
fvar :: a
 

Instances

Eq a => Eq (File a) Source 
Ord (File FileInfo) Source

First compare constructors: Failed < Dir < File... Then compare name... Then compare free variable parameter of File constructors

Show a => Show (File a) Source 

data FileInfo Source

Low-level file information.

Instances

Eq FileInfo Source 
Ord FileInfo Source 
Show FileInfo Source 
Ord (File FileInfo) Source

First compare constructors: Failed < Dir < File... Then compare name... Then compare free variable parameter of File constructors

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 BrokenSymlink :: File FileInfo -> File FileInfo Source

Matches on broken symbolic links.

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.

readDirectoryContents Source

Arguments

:: (Path Abs -> IO a)

fills free a variable

-> Path Abs

path to read

-> IO [File a] 

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.

goUp :: File FileInfo -> IO (File FileInfo) Source

Go up one directory in the filesystem hierarchy.

goUp' :: Path Abs -> IO (File FileInfo) Source

Go up one directory in the filesystem hierarchy.

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.

packPermissions :: File FileInfo -> String Source

Pack the permissions into a string, similar to what "ls -l" does.