take -bytestring +filepath

takeBaseName :: FilePath -> String
filepath System.FilePath.Windows, filepath System.FilePath.Posix
Get the base name, without an extension or path. > takeBaseName "file/test.txt" == "test" > takeBaseName "dave.ext" == "dave" > takeBaseName "" == "" > takeBaseName "test" == "test" > takeBaseName (addTrailingPathSeparator x) == "" > takeBaseName "file/file.tar.gz" == "file.tar"
takeDirectory :: FilePath -> FilePath
filepath System.FilePath.Windows, filepath System.FilePath.Posix
Get the directory name, move up one level. > takeDirectory x `isPrefixOf` x || takeDirectory x == "." > takeDirectory "foo" == "." > takeDirectory "/foo/bar/baz" == "/foo/bar" > takeDirectory "/foo/bar/baz/" == "/foo/bar/baz" > takeDirectory "foo/bar/baz" == "foo/bar" > Windows: takeDirectory "foo\\bar" == "foo" > Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar" > Windows: takeDirectory "C:\\" == "C:\\"
takeDrive :: FilePath -> FilePath
filepath System.FilePath.Windows, filepath System.FilePath.Posix
Get the drive from a filepath. > takeDrive x == fst (splitDrive x)
takeExtension :: FilePath -> String
filepath System.FilePath.Windows, filepath System.FilePath.Posix
Get the extension of a file, returns "" for no extension, .ext otherwise. > takeExtension x == snd (splitExtension x) > Valid x => takeExtension (addExtension x "ext") == ".ext" > Valid x => takeExtension (replaceExtension x "ext") == ".ext"
takeExtensions :: FilePath -> String
filepath System.FilePath.Windows, filepath System.FilePath.Posix
Get all extensions > takeExtensions "file.tar.gz" == ".tar.gz"
takeFileName :: FilePath -> FilePath
filepath System.FilePath.Windows, filepath System.FilePath.Posix
Get the file name. > takeFileName "test/" == "" > takeFileName x `isSuffixOf` x > takeFileName x == snd (splitFileName x) > Valid x => takeFileName (replaceFileName x "fred") == "fred" > Valid x => takeFileName (x </> "fred") == "fred" > Valid x => isRelative (takeFileName x)