MissingH-1.4.3.0: Large utility library

CopyrightCopyright (C) 2004-2011 John Goerzen
LicenseBSD-3-Clause
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

System.Path

Contents

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

Name processing

splitExt :: String -> (String, String) Source #

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 Source #

Arguments

:: String

Absolute path for use with starting directory

-> String

The path name to make absolute

-> Maybe String

Result

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 Source #

Arguments

:: String

Absolute path for use with starting directory

-> String

The 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] Source #

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)] Source #

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.

The items are returned lazily.

WARNING: do not change your current working directory until you have consumed all the items. Doing so could cause strange effects.

Alternatively, you may wish to pass an absolute path to this function.

recursiveRemove :: HVFS a => a -> FilePath -> IO () Source #

Removes a file or a directory. If a directory, also removes all its child files/directories.

bracketCWD :: FilePath -> IO a -> IO a Source #

Changes the current working directory to the given path, executes the given I/O action, then changes back to the original directory, even if the I/O action raised an exception.

Temporary Directories

mktmpdir :: String -> IO String Source #

Creates a temporary directory for your use.

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

Your string should probably start with the value returned from System.Directory.getTemporaryDirectory.

The name of the directory created will be returned.

brackettmpdir :: String -> (String -> IO a) -> IO a Source #

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.

brackettmpdirCWD :: String -> IO a -> IO a Source #

Runs the given I/O action with the CWD set to the given tmp dir, removing the tmp dir and changing CWD back afterwards, even if there was an exception.