在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:rofinn/FilePathsBase.jl开源软件地址:https://github.com/rofinn/FilePathsBase.jl开源编程语言:Julia 100.0%开源软件介绍:FilePathsBase.jlFilePathsBase.jl provides a type based approach to working with filesystem paths in julia. IntallationFilePathsBase.jl is registered, so you can to use julia> Pkg.add("FilePathsBase") Getting StartedHere are some common operations that you may want to perform with file paths. #=
NOTE: We're loading our `/` operator for path concatenation into the currect scope, but non-path division operations will still fallback to the base behaviour.
=#
julia> using FilePathsBase; using FilePathsBase: /
julia> cwd()
p"/Users/rory/repos/FilePathsBase.jl"
julia> walkpath(cwd() / "docs") |> collect
23-element Array{Any,1}:
p"/Users/rory/repos/FilePathsBase.jl/docs/.DS_Store"
p"/Users/rory/repos/FilePathsBase.jl/docs/Manifest.toml"
p"/Users/rory/repos/FilePathsBase.jl/docs/Project.toml"
p"/Users/rory/repos/FilePathsBase.jl/docs/build"
p"/Users/rory/repos/FilePathsBase.jl/docs/build/api.html"
p"/Users/rory/repos/FilePathsBase.jl/docs/build/assets"
p"/Users/rory/repos/FilePathsBase.jl/docs/build/assets/arrow.svg"
p"/Users/rory/repos/FilePathsBase.jl/docs/build/assets/documenter.css"
...
julia> stat(p"docs/src/index.md")
Status(
device = 16777223,
inode = 32240108,
mode = -rw-r--r--,
nlink = 1,
uid = 501 (rory),
gid = 20 (staff),
rdev = 0,
size = 2028 (2.0K),
blksize = 4096 (4.0K),
blocks = 8,
mtime = 2020-04-20T17:20:38.612,
ctime = 2020-04-20T17:20:38.612,
)
julia> relative(p"docs/src/index.md", p"src/")
p"../docs/src/index.md"
julia> normalize(p"src/../docs/src/index.md")
p"docs/src/index.md"
julia> absolute(p"docs/src/index.md")
p"/Users/rory/repos/FilePathsBase.jl/docs/src/index.md"
julia> islink(p"docs/src/index.md")
true
julia> canonicalize(p"docs/src/index.md")
p"/Users/rory/repos/FilePathsBase.jl/README.md"
julia> parents(p"./docs/src")
2-element Array{PosixPath,1}:
p"."
p"./docs"
julia> parents(absolute(p"./docs/src"))
6-element Array{PosixPath,1}:
p"/"
p"/Users"
p"/Users/rory"
p"/Users/rory/repos"
p"/Users/rory/repos/FilePathsBase.jl"
p"/Users/rory/repos/FilePathsBase.jl/docs"
julia> absolute(p"./docs/src")[1:end-1]
("Users", "rory", "repos", "FilePathsBase.jl", "docs")
julia> tmpfp = mktempdir(SystemPath)
p"/var/folders/vz/zx_0gsp9291dhv049t_nx37r0000gn/T/jl_1GCBFT"
julia> sync(p"/Users/rory/repos/FilePathsBase.jl/docs", tmpfp / "docs")
p"/var/folders/vz/zx_0gsp9291dhv049t_nx37r0000gn/T/jl_1GCBFT/docs"
julia> exists(tmpfp / "docs" / "make.jl")
true
julia> m = mode(tmpfp / "docs" / "make.jl")
Mode("-rw-r--r--")
julia> m - readable(:ALL)
Mode("--w-------")
julia> m + executable(:ALL)
Mode("-rwxr-xr-x")
julia> chmod(tmpfp / "docs" / "make.jl", "+x")
"/var/folders/vz/zx_0gsp9291dhv049t_nx37r0000gn/T/jl_1GCBFT/docs/make.jl"
julia> mode(tmpfp / "docs" / "make.jl")
Mode("-rwxr-xr-x")
# Count LOC
julia> mapreduce(+, walkpath(cwd() / "src")) do x
extension(x) == "jl" ? count("\n", read(x, String)) : 0
end
3020
# Concatenate multiple files.
julia> str = mapreduce(*, walkpath(tmpfp / "docs" / "src")) do x
read(x, String)
end
"# API\n\nAll the standard methods for working with paths in base julia exist in the FilePathsBase.jl. The following describes the rough mapping of method names. Use `?` at the REPL to get the documentation and arguments as they may be different than the base implementations.\n\n..."
# Could also write the result to a file with `write(newfile, str)`)
julia> rm(tmpfp; recursive=true)
julia> exists(tmpfp)
false
# Loading code from paths (e.g., S3Path)
julia> FilePathsBase.@__INCLUDE__()
julia> include(p"test/testpkg.jl")
Main.TestPkg |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论