Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- splitExtension :: Applicative f => ReadFilePathT f (String, String)
- takeExtension :: Applicative f => ReadFilePathT f String
- replaceExtension :: Applicative f => ReadFilePathT f (String -> FilePath)
- dropExtension :: Applicative f => ReadFilePathT f FilePath
- addExtension :: Applicative f => ReadFilePathT f (String -> FilePath)
- hasExtension :: Applicative f => ReadFilePathT f Bool
- splitExtensions :: Applicative f => ReadFilePathT f (FilePath, String)
- dropExtensions :: Applicative f => ReadFilePathT f FilePath
- takeExtensions :: Applicative f => ReadFilePathT f String
- replaceExtensions :: Applicative f => ReadFilePathT f (String -> FilePath)
- isExtensionOf :: Applicative f => String -> ReadFilePathT f Bool
- stripExtension :: Applicative f => String -> ReadFilePathT f (Maybe FilePath)
- splitFileName :: Applicative f => ReadFilePathT f (String, String)
- takeFileName :: Applicative f => ReadFilePathT f String
- replaceFileName :: Applicative f => ReadFilePathT f (String -> FilePath)
- dropFileName :: Applicative f => ReadFilePathT f FilePath
- takeBaseName :: Applicative f => ReadFilePathT f String
- replaceBaseName :: Applicative f => ReadFilePathT f (String -> FilePath)
- takeDirectory :: Applicative f => ReadFilePathT f FilePath
- replaceDirectory :: Applicative f => ReadFilePathT f (String -> FilePath)
- combine :: Applicative f => ReadFilePathT f (FilePath -> FilePath)
- splitPath :: Applicative f => ReadFilePathT f [FilePath]
- joinPath :: ToFilePath [FilePath]
- splitDirectories :: Applicative f => ReadFilePathT f [FilePath]
- splitDrive :: Applicative f => ReadFilePathT f (FilePath, FilePath)
- joinDrive :: Applicative f => ReadFilePathT f (FilePath -> FilePath)
- takeDrive :: Applicative f => ReadFilePathT f FilePath
- hasDrive :: Applicative f => ReadFilePathT f Bool
- dropDrive :: Applicative f => ReadFilePathT f FilePath
- isDrive :: Applicative f => ReadFilePathT f Bool
- hasTrailingPathSeparator :: Applicative f => ReadFilePathT f Bool
- addTrailingPathSeparator :: Applicative f => ReadFilePathT f FilePath
- dropTrailingPathSeparator :: Applicative f => ReadFilePathT f FilePath
- normalise :: Applicative f => ReadFilePathT f FilePath
- equalFilePath :: Applicative f => ReadFilePathT f (FilePath -> Bool)
- makeRelative :: Applicative f => ReadFilePathT f (FilePath -> FilePath)
- isRelative :: Applicative f => ReadFilePathT f Bool
- isAbsolute :: Applicative f => ReadFilePathT f Bool
- isValid :: Applicative f => ReadFilePathT f Bool
- makeValid :: Applicative f => ReadFilePathT f FilePath
- type FilePath = String
- (</>) :: FilePath -> FilePath -> FilePath
- (-<.>) :: FilePath -> String -> FilePath
- splitSearchPath :: String -> [FilePath]
- isExtSeparator :: Char -> Bool
- extSeparator :: Char
- isPathSeparator :: Char -> Bool
- pathSeparators :: [Char]
- pathSeparator :: Char
Documentation
splitExtension :: Applicative f => ReadFilePathT f (String, String) Source #
takeExtension :: Applicative f => ReadFilePathT f String Source #
replaceExtension :: Applicative f => ReadFilePathT f (String -> FilePath) Source #
dropExtension :: Applicative f => ReadFilePathT f FilePath Source #
addExtension :: Applicative f => ReadFilePathT f (String -> FilePath) Source #
hasExtension :: Applicative f => ReadFilePathT f Bool Source #
splitExtensions :: Applicative f => ReadFilePathT f (FilePath, String) Source #
dropExtensions :: Applicative f => ReadFilePathT f FilePath Source #
takeExtensions :: Applicative f => ReadFilePathT f String Source #
replaceExtensions :: Applicative f => ReadFilePathT f (String -> FilePath) Source #
isExtensionOf :: Applicative f => String -> ReadFilePathT f Bool Source #
stripExtension :: Applicative f => String -> ReadFilePathT f (Maybe FilePath) Source #
splitFileName :: Applicative f => ReadFilePathT f (String, String) Source #
takeFileName :: Applicative f => ReadFilePathT f String Source #
replaceFileName :: Applicative f => ReadFilePathT f (String -> FilePath) Source #
dropFileName :: Applicative f => ReadFilePathT f FilePath Source #
takeBaseName :: Applicative f => ReadFilePathT f String Source #
replaceBaseName :: Applicative f => ReadFilePathT f (String -> FilePath) Source #
takeDirectory :: Applicative f => ReadFilePathT f FilePath Source #
replaceDirectory :: Applicative f => ReadFilePathT f (String -> FilePath) Source #
combine :: Applicative f => ReadFilePathT f (FilePath -> FilePath) Source #
splitPath :: Applicative f => ReadFilePathT f [FilePath] Source #
joinPath :: ToFilePath [FilePath] Source #
splitDirectories :: Applicative f => ReadFilePathT f [FilePath] Source #
splitDrive :: Applicative f => ReadFilePathT f (FilePath, FilePath) Source #
joinDrive :: Applicative f => ReadFilePathT f (FilePath -> FilePath) Source #
takeDrive :: Applicative f => ReadFilePathT f FilePath Source #
hasDrive :: Applicative f => ReadFilePathT f Bool Source #
dropDrive :: Applicative f => ReadFilePathT f FilePath Source #
isDrive :: Applicative f => ReadFilePathT f Bool Source #
hasTrailingPathSeparator :: Applicative f => ReadFilePathT f Bool Source #
normalise :: Applicative f => ReadFilePathT f FilePath Source #
equalFilePath :: Applicative f => ReadFilePathT f (FilePath -> Bool) Source #
makeRelative :: Applicative f => ReadFilePathT f (FilePath -> FilePath) Source #
isRelative :: Applicative f => ReadFilePathT f Bool Source #
isAbsolute :: Applicative f => ReadFilePathT f Bool Source #
isValid :: Applicative f => ReadFilePathT f Bool Source #
makeValid :: Applicative f => ReadFilePathT f FilePath Source #
File and directory names are values of type String
, whose precise
meaning is operating system dependent. Files can be opened, yielding a
handle which can then be used to operate on the contents of that file.
(</>) :: FilePath -> FilePath -> FilePath infixr 5 #
Combine two paths with a path separator.
If the second path starts with a path separator or a drive letter, then it returns the second.
The intention is that readFile (dir
will access the same file as
</>
file)setCurrentDirectory dir; readFile file
.
Posix: "/directory" </> "file.ext" == "/directory/file.ext" Windows: "/directory" </> "file.ext" == "/directory\\file.ext" "directory" </> "/file.ext" == "/file.ext" Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x
Combined:
Posix: "/" </> "test" == "/test" Posix: "home" </> "bob" == "home/bob" Posix: "x:" </> "foo" == "x:/foo" Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar" Windows: "home" </> "bob" == "home\\bob"
Not combined:
Posix: "home" </> "/bob" == "/bob" Windows: "home" </> "C:\\bob" == "C:\\bob"
Not combined (tricky):
On Windows, if a filepath starts with a single slash, it is relative to the
root of the current drive. In [1], this is (confusingly) referred to as an
absolute path.
The current behavior of </>
is to never combine these forms.
Windows: "home" </> "/bob" == "/bob" Windows: "home" </> "\\bob" == "\\bob" Windows: "C:\\home" </> "\\bob" == "\\bob"
On Windows, from [1]: "If a file name begins with only a disk designator
but not the backslash after the colon, it is interpreted as a relative path
to the current directory on the drive with the specified letter."
The current behavior of </>
is to never combine these forms.
Windows: "D:\\foo" </> "C:bar" == "C:bar" Windows: "C:\\foo" </> "C:bar" == "C:bar"
(-<.>) :: FilePath -> String -> FilePath infixr 7 #
Remove the current extension and add another, equivalent to replaceExtension
.
"/directory/path.txt" -<.> "ext" == "/directory/path.ext" "/directory/path.txt" -<.> ".ext" == "/directory/path.ext" "foo.o" -<.> "c" == "foo.c"
splitSearchPath :: String -> [FilePath] #
Take a string, split it on the searchPathSeparator
character.
Blank items are ignored on Windows, and converted to .
on Posix.
On Windows path elements are stripped of quotes.
Follows the recommendations in http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
Posix: splitSearchPath "File1:File2:File3" == ["File1","File2","File3"] Posix: splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"] Windows: splitSearchPath "File1;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"]
isExtSeparator :: Char -> Bool #
Is the character an extension character?
isExtSeparator a == (a == extSeparator)
extSeparator :: Char #
File extension character
extSeparator == '.'
isPathSeparator :: Char -> Bool #
Rather than using (==
, use this. Test if something
is a path separator.pathSeparator
)
isPathSeparator a == (a `elem` pathSeparators)
pathSeparators :: [Char] #
The list of all possible separators.
Windows: pathSeparators == ['\\', '/'] Posix: pathSeparators == ['/'] pathSeparator `elem` pathSeparators
pathSeparator :: Char #
The character that separates directories. In the case where more than
one character is possible, pathSeparator
is the 'ideal' one.
Windows: pathSeparator == '\\' Posix: pathSeparator == '/' isPathSeparator pathSeparator