Module CPM.FileUtil

Some utilities for deailing with files and directories for the Curry Package Manager.

Exported Functions


joinSearchPath :: [String] -> String  Deterministic 

Joins a list of directories into a search path.


copyDirectory :: String -> String -> IO ()  Deterministic 

Recursively copies a directory structure.


copyDirectoryFollowingSymlinks :: String -> String -> IO ()  Deterministic 

Recursively copies a directory structure following symlinks, i.e. links get replaced by copies in the destination.


createSymlink :: String -> String -> IO Int  Deterministic 

Creates a new symlink.


removeSymlink :: String -> IO Int  Deterministic 

Deletes a symlink.


isSymlink :: String -> IO Bool  Deterministic 

Tests whether a file is a symlink.


linkTarget :: String -> IO String  Deterministic 

Gets the target of a symlink.


getRealPath :: String -> IO String  Deterministic 

Returns the absolute real path for a given file path by following all symlinks in all path components.


quote :: String -> String  Deterministic 

Puts a file argument into quotes to avoid problems with files containing blanks.

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

tempDir :: IO String  Deterministic 

Gets a temporary directory for some CPM command.


cleanTempDir :: IO ()  Deterministic 

Removes the temporary directory for some CPM command.


inTempDir :: IO a -> IO a  Deterministic 

Executes an IO action with the current directory set to CPM's temporary directory.


inDirectory :: String -> IO a -> IO a  Deterministic 

Executes an IO action with the current directory set to a specific directory.


recreateDirectory :: String -> IO ()  Deterministic 

Recreates a directory. Deletes its contents if it already exists.


removeDirectoryComplete :: String -> IO ()  Deterministic 

Deletes a directory and its contents, if it exists, otherwise nothing is done.


safeReadFile :: String -> IO (Either IOError String)  Deterministic 

Reads the complete contents of a file and catches any error (which is returned).


checkAndGetVisibleDirectoryContents :: String -> IO [String]  Deterministic 

Returns the list of all visible entries in a directory (i.e., not starting with ) and terminates with an error message if the directory does not exist.


ifFileExists :: String -> IO a -> IO a -> IO a  Deterministic 

Performs one of two actions depending on the existence of a file.


whenFileExists :: String -> IO () -> IO ()  Deterministic 

Performs an action when a file exists.


writeFileIfNotExists :: String -> String -> IO ()  Deterministic 

Writes a file with a given contents if it does not exist.