Skip to content

A type based approach to working with filesystem paths in julia

License

Notifications You must be signed in to change notification settings

rofinn/FilePaths.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FilePaths.jl

Build Status codecov.io

FilePathsBase.jl provides a type based API for working with filesystem paths. Please review the FilePathsBase docs for more info on working with the base filepath types. FilePaths.jl extends FilePathsBase to provide easier interoperability with the rest of the Julia ecosystem.

Intallation:

FilePaths.jl is registered, so you can to use Pkg.add to install it.

julia> Pkg.add("FilePaths")

Usage:

julia> using FilePaths; using FilePathsBase: /

Globbing files:

julia> using Glob

julia> glob("*test*.jl", p"test")
2-element Array{PosixPath,1}:
 p"test/runtests.jl"
 p"test/test_uri.jl"

URIParsing:

julia> using URIs

julia> URI(cwd() / p"test/runtests.jl")
URI("file:///Users/rory/repos/FilePaths.jl/test/runtests.jl")

Writing String and AbstractPath compatible code:

julia> FilePaths.@compat function myrelative(x::AbstractPath, y::AbstractPath)
           return relative(x, y)
       end
myrelative (generic function with 2 methods)

julia> FilePaths.@compat function myjoin(x::P, y::String)::P where P <: AbstractPath
           return x / y
       end
myjoin (generic function with 2 methods)

julia> myrelative(cwd(), home())
p"repos/FilePaths.jl"

julia> myrelative(pwd(), homedir())
p"repos/FilePaths.jl"

julia> myjoin(parent(cwd()), "FilePaths.jl")
p"/Users/rory/repos/FilePaths.jl"

julia> myjoin("/Users/rory/repos", "FilePaths.jl")
"/Users/rory/repos/FilePaths.jl"

About

A type based approach to working with filesystem paths in julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages