MissingH API ManualContentsIndex
MissingH.Path
Portability portable
Stability provisional
Maintainer jgoerzen@complete.org
Contents
Name processing
Directory Processing
Temporary Directories
Description

This module provides various helpful utilities for dealing with path and file names, directories, and related support.

Written by John Goerzen, jgoerzen@complete.org

Synopsis
splitExt :: String -> (String, String)
absNormPath :: String -> String -> Maybe String
secureAbsNormPath :: String -> String -> Maybe String
recurseDir :: HVFS a => a -> FilePath -> IO [FilePath]
recurseDirStat :: HVFS a => a -> FilePath -> IO [(FilePath, HVFSStatEncap)]
recursiveRemove :: HVFS a => a -> FilePath -> IO ()
mktmpdir :: String -> IO String
brackettmpdir :: String -> (String -> IO a) -> IO a
Name processing
splitExt :: String -> (String, String)
Splits a pathname into a tuple representing the root of the name and the extension. The extension is considered to be all characters from the last dot after the last slash to the end. Either returned string may be empty.
absNormPath
:: StringAbsolute path for use with starting directory
-> StringThe path name to make absolute
-> Maybe StringResult

Make an absolute, normalized version of a path with all double slashes, dot, and dotdot entries removed.

The first parameter is the base for the absolut calculation; in many cases, it would correspond to the current working directory.

The second parameter is the pathname to transform. If it is already absolute, the first parameter is ignored.

Nothing may be returned if there's an error; for instance, too many .. entries for the given path.

secureAbsNormPath
:: StringAbsolute path for use with starting directory
-> StringThe path to make absolute
-> Maybe String
Like absNormPath, but returns Nothing if the generated result is not the passed base path or a subdirectory thereof.
Directory Processing
recurseDir :: HVFS a => a -> FilePath -> IO [FilePath]

Obtain a recursive listing of all files/directories beneath the specified directory. The traversal is depth-first and the original item is always present in the returned list.

If the passed value is not a directory, the return value be only that value.

The "." and ".." entries are removed from the data returned.

recurseDirStat :: HVFS a => a -> FilePath -> IO [(FilePath, HVFSStatEncap)]
Like recurseDir, but return the stat() (System.Posix.Files.FileStatus) information with them. This is an optimization if you will be statting files yourself later.
recursiveRemove :: HVFS a => a -> FilePath -> IO ()
Removes a file or a directory. If a directory, also removes all its child files/directories.
Temporary Directories
mktmpdir :: String -> IO String

Creates a temporary directory for your use.

The passed string should be a template suitable for mkstemp; that is, end with "XXXXXX".

The name of the directory created will be returned.

brackettmpdir :: String -> (String -> IO a) -> IO a
Creates a temporary directory for your use via mktmpdir, runs the specified action (passing in the directory name), then removes the directory and all its contents when the action completes (or raises an exception.
Produced by Haddock version 0.6