darcs-2.8.4: a distributed, interactive, smart revision control system

Safe Haskell | None

Darcs.RepoPath

Contents

- AbsolutePath
- AbsolutePathOrStd
- AbsoluteOrRemotePath
- SubPath
- Miscellaneous

Description

Various abstractions for dealing with paths.

Synopsis

- data AbsolutePath
- makeAbsolute :: AbsolutePath -> FilePath -> AbsolutePath
- ioAbsolute :: FilePath -> IO AbsolutePath
- rootDirectory :: AbsolutePath
- data AbsolutePathOrStd
- makeAbsoluteOrStd :: AbsolutePath -> String -> AbsolutePathOrStd
- ioAbsoluteOrStd :: String -> IO AbsolutePathOrStd
- useAbsoluteOrStd :: (AbsolutePath -> a) -> a -> AbsolutePathOrStd -> a
- stdOut :: AbsolutePathOrStd
- data AbsoluteOrRemotePath
- ioAbsoluteOrRemote :: String -> IO AbsoluteOrRemotePath
- isRemote :: AbsoluteOrRemotePath -> Bool
- data SubPath
- makeSubPathOf :: AbsolutePath -> AbsolutePath -> Maybe SubPath
- simpleSubPath :: FilePath -> Maybe SubPath
- sp2fn :: SubPath -> FileName
- class FilePathOrURL a where
  - toPath :: a -> String
- class FilePathOrURL a => FilePathLike a where
  - toFilePath :: a -> FilePath
- getCurrentDirectory :: IO AbsolutePath
- setCurrentDirectory :: FilePathLike p => p -> IO ()

# AbsolutePath

data AbsolutePath

Instances

Eq AbsolutePath |
Ord AbsolutePath |
Show AbsolutePath |
FilePathLike AbsolutePath |
FilePathOrURL AbsolutePath |

makeAbsolute :: AbsolutePath -> FilePath -> AbsolutePath

Take an absolute path and a string representing a (possibly relative) path and combine them into an absolute path. If the second argument is already absolute, then the first argument gets ignored. This function also takes care that the result is converted to Posix convention and normalized. Also, parent directories ("..") at the front of the string argument get canceled out against trailing directory parts of the absolute path argument.

Regarding the last point, someone more familiar with how these functions are used should verify that this is indeed necessary or at least useful.

ioAbsolute :: FilePath -> IO AbsolutePath

Interpret a possibly relative path wrt the current working directory.

rootDirectory :: AbsolutePath

The root directory as an absolute path.

# AbsolutePathOrStd

data AbsolutePathOrStd

This is for situations where a string (e.g. a command line argument) may take the value "-" to mean stdin or stdout (which one depends on context) instead of a normal file path.

Instances

Eq AbsolutePathOrStd |
Ord AbsolutePathOrStd |
Show AbsolutePathOrStd |

makeAbsoluteOrStd :: AbsolutePath -> String -> AbsolutePathOrStd

ioAbsoluteOrStd :: String -> IO AbsolutePathOrStd

useAbsoluteOrStd :: (AbsolutePath -> a) -> a -> AbsolutePathOrStd -> a

Execute either the first or the second argument action, depending on whether the given path is an `AbsolutePath` or stdin/stdout.

stdOut :: AbsolutePathOrStd

# AbsoluteOrRemotePath

data AbsoluteOrRemotePath

Instances

Eq AbsoluteOrRemotePath |
Ord AbsoluteOrRemotePath |
Show AbsoluteOrRemotePath |
FilePathOrURL AbsoluteOrRemotePath |

ioAbsoluteOrRemote :: String -> IO AbsoluteOrRemotePath

isRemote :: AbsoluteOrRemotePath -> Bool

# SubPath

data SubPath

Paths which are relative to the local darcs repository and normalized. Note: These are understood not to have the dot in front.

Instances

Eq SubPath |
Ord SubPath |
Show SubPath |
FilePathLike SubPath |
FilePathOrURL SubPath |

makeSubPathOf :: AbsolutePath -> AbsolutePath -> Maybe SubPath

Make the second path relative to the first, if possible

simpleSubPath :: FilePath -> Maybe SubPath

# Miscellaneous

sp2fn :: SubPath -> FileName

class FilePathOrURL a where

Methods

toPath :: a -> String

Instances

FilePathOrURL FileName |
FilePathOrURL AbsoluteOrRemotePath |
FilePathOrURL AbsolutePath |
FilePathOrURL SubPath |
CharLike c => FilePathOrURL [c] |

class FilePathOrURL a => FilePathLike a where

Methods

toFilePath :: a -> FilePath

Instances

FilePathLike FileName |
FilePathLike AbsolutePath |
FilePathLike SubPath |
CharLike c => FilePathLike [c] |

getCurrentDirectory :: IO AbsolutePath

setCurrentDirectory :: FilePathLike p => p -> IO ()