Module FileGoodies

A collection of useful operations when dealing with files.

Author: Michael Hanus, Bernd Brassel

Version: June 2009

Summary of exported operations:

separatorChar :: Char   
The character for separating hierarchies in file names.
pathSeparatorChar :: Char   
The character for separating names in path expressions.
suffixSeparatorChar :: Char   
The character for separating suffixes in file names.
isAbsolute :: String -> Bool   
Is the argument an absolute name?
dirName :: String -> String   
Extracts the directoy prefix of a given (Unix) file name.
baseName :: String -> String   
Extracts the base name without directoy prefix of a given (Unix) file name.
splitDirectoryBaseName :: String -> (String,String)   
Splits a (Unix) file name into the directory prefix and the base name.
stripSuffix :: String -> String   
Strips a suffix (the last suffix starting with a dot) from a file name.
fileSuffix :: String -> String   
Yields the suffix (the last suffix starting with a dot) from given file name.
splitBaseName :: String -> (String,String)   
Splits a file name into prefix and suffix (the last suffix starting with a dot and the rest).
splitPath :: String -> [String]   
Splits a path string into list of directory names.
lookupFileInPath :: String -> [String] -> [String] -> IO (Maybe String)   
Looks up the first file with a possible suffix in a list of directories.
getFileInPath :: String -> [String] -> [String] -> IO String   
Gets the first file with a possible suffix in a list of directories.

Exported operations:

separatorChar :: Char   

The character for separating hierarchies in file names. On UNIX systems the value is /.

Further infos:
  • solution complete, i.e., able to compute all solutions

pathSeparatorChar :: Char   

The character for separating names in path expressions. On UNIX systems the value is :.

Further infos:
  • solution complete, i.e., able to compute all solutions

suffixSeparatorChar :: Char   

The character for separating suffixes in file names. On UNIX systems the value is ..

Further infos:
  • solution complete, i.e., able to compute all solutions

isAbsolute :: String -> Bool   

Is the argument an absolute name?

dirName :: String -> String   

Extracts the directoy prefix of a given (Unix) file name. Returns "." if there is no prefix.

baseName :: String -> String   

Extracts the base name without directoy prefix of a given (Unix) file name.

splitDirectoryBaseName :: String -> (String,String)   

Splits a (Unix) file name into the directory prefix and the base name. The directory prefix is "." if there is no real prefix in the name.

stripSuffix :: String -> String   

Strips a suffix (the last suffix starting with a dot) from a file name.

fileSuffix :: String -> String   

Yields the suffix (the last suffix starting with a dot) from given file name.

splitBaseName :: String -> (String,String)   

Splits a file name into prefix and suffix (the last suffix starting with a dot and the rest).

splitPath :: String -> [String]   

Splits a path string into list of directory names.

lookupFileInPath :: String -> [String] -> [String] -> IO (Maybe String)   

Looks up the first file with a possible suffix in a list of directories. Returns Nothing if such a file does not exist.

getFileInPath :: String -> [String] -> [String] -> IO String   

Gets the first file with a possible suffix in a list of directories. An error message is delivered if there is no such file.