FilePaths.@compat
— MacroFilePaths.@compat fn
Generates a compatibility method for handling paths as strings based on the function definition passed in.
Wrapper method properties:
- Any arguments that accepted
P <: AbstractPath
will acceptUnion{String, P}
- All string path inputs will be converted to path types
- If a path return type was specified then the path result will be converted back to a string.
Examples
julia> using FilePaths
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"