~ninjin/julia-nix

86184db399b87a1be4279e872eeb8ae59274ee66 — Eric Hanson 2 years ago fd7bc03
Clarify `mkpath` docstring (#42160)

Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>

Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
1 files changed, 16 insertions(+), 12 deletions(-)

M base/file.jl
M base/file.jl => base/file.jl +16 -12
@@ 193,22 193,19 @@ end
"""
    mkpath(path::AbstractString; mode::Unsigned = 0o777)

Create all directories in the given `path`, with permissions `mode`. `mode` defaults to
`0o777`, modified by the current file creation mask. Unlike [`mkdir`](@ref), `mkpath`
does not error if `path` (or parts of it) already exists.
Return `path`.
Create all intermediate directories in the `path` as required. Directories are created with
the permissions `mode` which defaults to `0o777` and is modified by the current file
creation mask. Unlike [`mkdir`](@ref), `mkpath` does not error if `path` (or parts of it)
already exists. Return `path`.

If `path` includes a filename you will probably want to use `mkpath(dirname(path))` to
avoid creating a directory using the filename.

# Examples
```julia-repl
julia> mkdir("testingdir")
"testingdir"

julia> cd("testingdir")
julia> cd(mktempdir())

julia> pwd()
"/home/JuliaUser/testingdir"

julia> mkpath("my/test/dir")
julia> mkpath("my/test/dir") # creates three directories
"my/test/dir"

julia> readdir()


@@ 224,6 221,13 @@ julia> readdir()
julia> readdir("test")
1-element Array{String,1}:
 "dir"

julia> mkpath("intermediate_dir/actually_a_directory.txt") # creates two directories
"intermediate_dir/actually_a_directory.txt"

julia> isdir("intermediate_dir/actually_a_directory.txt")
true

```
"""
function mkpath(path::AbstractString; mode::Integer = 0o777)