Filesystem

  1. pwd() -> AbstractString

Get the current working directory.

Examples

  1. julia> pwd()
  2. "/home/JuliaUser"
  3. julia> cd("/home/JuliaUser/Projects/julia")
  4. julia> pwd()
  5. "/home/JuliaUser/Projects/julia"

source

  1. cd(dir::AbstractString=homedir())

Set the current working directory.

Examples

  1. julia> cd("/home/JuliaUser/Projects/julia")
  2. julia> pwd()
  3. "/home/JuliaUser/Projects/julia"
  4. julia> cd()
  5. julia> pwd()
  6. "/home/JuliaUser"

source

  1. cd(f::Function, dir::AbstractString=homedir())

Temporarily change the current working directory to dir, apply function f and finally return to the original directory.

Examples

  1. julia> pwd()
  2. "/home/JuliaUser"
  3. julia> cd(readdir, "/home/JuliaUser/Projects/julia")
  4. 34-element Array{String,1}:
  5. ".circleci"
  6. ".freebsdci.sh"
  7. ".git"
  8. ".gitattributes"
  9. ".github"
  10. "test"
  11. "ui"
  12. "usr"
  13. "usr-staging"
  14. julia> pwd()
  15. "/home/JuliaUser"

source

  1. readdir(dir::AbstractString=pwd();
  2. join::Bool = false,
  3. sort::Bool = true,
  4. ) -> Vector{String}

Return the names in the directory dir or the current working directory if not given. When join is false, readdir returns just the names in the directory as is; when join is true, it returns joinpath(dir, name) for each name so that the returned strings are full paths. If you want to get absolute paths back, call readdir with an absolute directory path and join set to true.

By default, readdir sorts the list of names it returns. If you want to skip sorting the names and get them in the order that the file system lists them, you can use readir(dir, sort=false) to opt out of sorting.

The join and sort keyword arguments require at least Julia 1.4.

Examples

  1. julia> cd("/home/JuliaUser/dev/julia")
  2. julia> readdir()
  3. 30-element Array{String,1}:
  4. ".appveyor.yml"
  5. ".git"
  6. ".gitattributes"
  7. "ui"
  8. "usr"
  9. "usr-staging"
  10. julia> readdir(join=true)
  11. 30-element Array{String,1}:
  12. "/home/JuliaUser/dev/julia/.appveyor.yml"
  13. "/home/JuliaUser/dev/julia/.git"
  14. "/home/JuliaUser/dev/julia/.gitattributes"
  15. "/home/JuliaUser/dev/julia/ui"
  16. "/home/JuliaUser/dev/julia/usr"
  17. "/home/JuliaUser/dev/julia/usr-staging"
  18. julia> readdir("base")
  19. 145-element Array{String,1}:
  20. ".gitignore"
  21. "Base.jl"
  22. "Enums.jl"
  23. "version_git.sh"
  24. "views.jl"
  25. "weakkeydict.jl"
  26. julia> readdir("base", join=true)
  27. 145-element Array{String,1}:
  28. "base/.gitignore"
  29. "base/Base.jl"
  30. "base/Enums.jl"
  31. "base/version_git.sh"
  32. "base/views.jl"
  33. "base/weakkeydict.jl"

julia> readdir(abspath(“base”), join=true) 145-element Array{String,1}: “/home/JuliaUser/dev/julia/base/.gitignore” “/home/JuliaUser/dev/julia/base/Base.jl” “/home/JuliaUser/dev/julia/base/Enums.jl” ⋮ “/home/JuliaUser/dev/julia/base/version_git.sh” “/home/JuliaUser/dev/julia/base/views.jl” “/home/JuliaUser/dev/julia/base/weakkeydict.jl”

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L699-L772)

walkdir(dir; topdown=true, follow_symlinks=false, onerror=throw)

  1. Return an iterator that walks the directory tree of a directory. The iterator returns a tuple containing `(rootpath, dirs, files)`. The directory tree can be traversed top-down or bottom-up. If `walkdir` encounters a [`SystemError`]($8c6cc72df6a580fb.md#Base.SystemError) it will rethrow the error by default. A custom error handling function can be provided through `onerror` keyword argument. `onerror` is called with a `SystemError` as argument.
  2. **Examples**

for (root, dirs, files) in walkdir(“.”) println(“Directories in $root”) for dir in dirs println(joinpath(root, dir)) # path to directories end println(“Files in $root”) for file in files println(joinpath(root, file)) # path to files end end

julia> mkpath(“my/test/dir”);

julia> itr = walkdir(“my”);

julia> (root, dirs, files) = first(itr) (“my”, [“test”], String[])

julia> (root, dirs, files) = first(itr) (“my/test”, [“dir”], String[])

julia> (root, dirs, files) = first(itr) (“my/test/dir”, String[], String[])

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L801-L840)

mkdir(path::AbstractString; mode::Unsigned = 0o777)

  1. Make a new directory with name `path` and permissions `mode`. `mode` defaults to `0o777`, modified by the current file creation mask. This function never creates more than one directory. If the directory already exists, or some intermediate directories do not exist, this function throws an error. See [`mkpath`](#Base.Filesystem.mkpath) for a function which creates all required intermediate directories. Return `path`.
  2. **Examples**

julia> mkdir(“testingdir”) “testingdir”

julia> cd(“testingdir”)

julia> pwd() “/home/JuliaUser/testingdir”

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L148-L168)

mkpath(path::AbstractString; mode::Unsigned = 0o777)

  1. Create all directories in the given `path`, with permissions `mode`. `mode` defaults to `0o777`, modified by the current file creation mask. Return `path`.
  2. **Examples**

julia> mkdir(“testingdir”) “testingdir”

julia> cd(“testingdir”)

julia> pwd() “/home/JuliaUser/testingdir”

julia> mkpath(“my/test/dir”) “my/test/dir”

julia> readdir() 1-element Array{String,1}: “my”

julia> cd(“my”)

julia> readdir() 1-element Array{String,1}: “test”

julia> readdir(“test”) 1-element Array{String,1}: “dir”

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L186-L220)

symlink(target::AbstractString, link::AbstractString)

  1. Creates a symbolic link to `target` with the name `link`.
  2. This function raises an error under operating systems that do not support soft symbolic links, such as Windows XP.
  3. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L930-L938)

readlink(path::AbstractString) -> AbstractString

  1. Return the target location a symbolic link `path` points to.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L961-L965)

chmod(path::AbstractString, mode::Integer; recursive::Bool=false)

  1. Change the permissions mode of `path` to `mode`. Only integer `mode`s (e.g. `0o777`) are currently supported. If `recursive=true` and the path is a directory all permissions in that directory will be recursively changed. Return `path`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L985-L992)

chown(path::AbstractString, owner::Integer, group::Integer=-1)

  1. Change the owner and/or group of `path` to `owner` and/or `group`. If the value entered for `owner` or `group` is `-1` the corresponding ID will not change. Only integer `owner`s and `group`s are currently supported. Return `path`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L1006-L1012)

RawFD

  1. Primitive type which wraps the native OS file descriptor. `RawFD`s can be passed to methods like [`stat`](#Base.stat) to discover information about the underlying file, and can also be used to open streams, with the `RawFD` describing the OS file backing the stream.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/libc.jl#L22-L30)

stat(file)

  1. Returns a structure whose fields contain information about the file. The fields of the structure are:
  2. <table><tbody><tr><th>Name</th><th>Description</th></tr><tr><td>size</td><td>The size (in bytes) of the file</td></tr><tr><td>device</td><td>ID of the device that contains the file</td></tr><tr><td>inode</td><td>The inode number of the file</td></tr><tr><td>mode</td><td>The protection mode of the file</td></tr><tr><td>nlink</td><td>The number of hard links to the file</td></tr><tr><td>uid</td><td>The user id of the owner of the file</td></tr><tr><td>gid</td><td>The group id of the file owner</td></tr><tr><td>rdev</td><td>If this file refers to a device, the ID of the device it refers to</td></tr><tr><td>blksize</td><td>The file-system preferred block size for the file</td></tr><tr><td>blocks</td><td>The number of such blocks allocated</td></tr><tr><td>mtime</td><td>Unix timestamp of when the file was last modified</td></tr><tr><td>ctime</td><td>Unix timestamp of when the file was created</td></tr></tbody></table>
  3. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L87-L108)

lstat(file)

  1. Like [`stat`](#Base.stat), but for symbolic links gets the info for the link itself rather than the file it refers to. This function must be called on a file path rather than a file object or a file descriptor.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L111-L118)

ctime(file)

  1. Equivalent to `stat(file).ctime`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L144-L148)

mtime(file)

  1. Equivalent to `stat(file).mtime`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L137-L141)

filemode(file)

  1. Equivalent to `stat(file).mode`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L123-L127)

filesize(path…)

  1. Equivalent to `stat(file).size`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L130-L134)

uperm(file)

  1. Get the permissions of the owner of the file as a bitfield of
  2. <table><tbody><tr><th>Value</th><th>Description</th></tr><tr><td>01</td><td>Execute Permission</td></tr><tr><td>02</td><td>Write Permission</td></tr><tr><td>04</td><td>Read Permission</td></tr></tbody></table>
  3. For allowed arguments, see [`stat`](#Base.stat).
  4. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L260-L272)

gperm(file)

  1. Like [`uperm`](#Base.Filesystem.uperm) but gets the permissions of the group owning the file.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L275-L279)

operm(file)

  1. Like [`uperm`](#Base.Filesystem.uperm) but gets the permissions for people who neither own the file nor are a member of the group owning the file
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L282-L287)

cp(src::AbstractString, dst::AbstractString; force::Bool=false, follow_symlinks::Bool=false)

  1. Copy the file, link, or directory from `src` to `dst`. `force=true` will first remove an existing `dst`.
  2. If `follow_symlinks=false`, and `src` is a symbolic link, `dst` will be created as a symbolic link. If `follow_symlinks=true` and `src` is a symbolic link, `dst` will be a copy of the file or directory `src` refers to. Return `dst`.
  3. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L332-L342)

download(url::AbstractString, [localfile::AbstractString])

  1. Download a file from the given url, optionally renaming it to the given local file name. If no filename is given this will download into a randomly-named file in your temp directory. Note that this function relies on the availability of external tools such as `curl`, `wget` or `fetch` to download the file and is provided for convenience. For production use or situations in which more options are needed, please use a package that provides the desired functionality instead.
  2. Returns the filename of the downloaded file.
  3. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/download.jl#L85-L96)

mv(src::AbstractString, dst::AbstractString; force::Bool=false)

  1. Move the file, link, or directory from `src` to `dst`. `force=true` will first remove an existing `dst`. Return `dst`.
  2. **Examples**

julia> write(“hello.txt”, “world”);

julia> mv(“hello.txt”, “goodbye.txt”) “goodbye.txt”

julia> “hello.txt” in readdir() false

julia> readline(“goodbye.txt”) “world”

julia> write(“hello.txt”, “world2”);

julia> mv(“hello.txt”, “goodbye.txt”) ERROR: ArgumentError: ‘goodbye.txt’ exists. force=true is required to remove ‘goodbye.txt’ before moving. Stacktrace: [1] #checkfor_mv_cp_cptree#10(::Bool, ::Function, ::String, ::String, ::String) at ./file.jl:293 […]

julia> mv(“hello.txt”, “goodbye.txt”, force=true) “goodbye.txt”

julia> rm(“goodbye.txt”);

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L356-L390)

rm(path::AbstractString; force::Bool=false, recursive::Bool=false)

  1. Delete the file, link, or empty directory at the given path. If `force=true` is passed, a non-existing path is not treated as error. If `recursive=true` is passed and the path is a directory, then all contents are removed recursively.
  2. **Examples**

julia> mkpath(“my/test/dir”);

julia> rm(“my”, recursive=true)

julia> rm(“this_file_does_not_exist”, force=true)

julia> rm(“this_file_does_not_exist”) ERROR: IOError: unlink: no such file or directory (ENOENT) Stacktrace: […]

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L238-L258)

touch(path::AbstractString)

  1. Update the last-modified timestamp on a file to the current time.
  2. If the file does not exist a new file is created.
  3. Return `path`.
  4. **Examples**

julia> write(“my_little_file”, 2);

julia> mtime(“my_little_file”) 1.5273815391135583e9

julia> touch(“my_little_file”);

julia> mtime(“my_little_file”) 1.527381559163435e9

  1. We can see the [`mtime`](#Base.Filesystem.mtime) has been modified by `touch`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L397-L420)

tempname(parent=tempdir(); cleanup=true) -> String

  1. Generate a temporary file path. This function only returns a path; no file is created. The path is likely to be unique, but this cannot be guaranteed due to the very remote posibility of two simultaneous calls to `tempname` generating the same file name. The name is guaranteed to differ from all files already existing at the time of the call to `tempname`.
  2. When called with no arguments, the temporary name will be an absolute path to a temporary name in the system temporary directory as given by `tempdir()`. If a `parent` directory argument is given, the temporary path will be in that directory instead.
  3. The `cleanup` option controls whether the process attempts to delete the returned path automatically when the process exits. Note that the `tempname` function does not create any file or directory at the returned location, so there is nothing to cleanup unless you create a file or directory there. If you do and `clean` is `true` it will be deleted upon process termination.
  4. The `parent` and `cleanup` arguments were added in 1.4. Prior to Julia 1.4 the path `tempname` would never be cleaned up at process termination.
  5. This can lead to security holes if another process obtains the same file name and creates the file before you are able to. Open the file with `JL_O_EXCL` if this is a concern. Using [`mktemp()`](#Base.Filesystem.mktemp-Tuple{AbstractString}) is also recommended instead.
  6. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L571-L601)

tempdir()

  1. Gets the path of the temporary directory. On Windows, `tempdir()` uses the first environment variable found in the ordered list `TMP`, `TEMP`, `USERPROFILE`. On all other operating systems, `tempdir()` uses the first environment variable found in the ordered list `TMPDIR`, `TMP`, `TEMP`, and `TEMPDIR`. If none of these are found, the path `"/tmp"` is used.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L437-L444)

mktemp(parent=tempdir(); cleanup=true) -> (path, io)

  1. Return `(path, io)`, where `path` is the path of a new temporary file in `parent` and `io` is an open file object for this path. The `cleanup` option controls whether the temporary file is automatically deleted when the process exits.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L604-L610)

mktemp(f::Function, parent=tempdir())

  1. Apply the function `f` to the result of [`mktemp(parent)`](#Base.Filesystem.mktemp-Tuple{AbstractString}) and remove the temporary file upon completion.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L650-L655)

mktempdir(parent=tempdir(); prefix=”jl_”, cleanup=true) -> path

  1. Create a temporary directory in the `parent` directory with a name constructed from the given prefix and a random suffix, and return its path. Additionally, any trailing `X` characters may be replaced with random characters. If `parent` does not exist, throw an error. The `cleanup` option controls whether the temporary directory is automatically deleted when the process exits.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L613-L621)

mktempdir(f::Function, parent=tempdir(); prefix=”jl_”)

  1. Apply the function `f` to the result of [`mktempdir(parent; prefix)`](#Base.Filesystem.mktempdir-Tuple{AbstractString}) and remove the temporary directory all of its contents upon completion.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/file.jl#L672-L677)

isblockdev(path) -> Bool

  1. Return `true` if `path` is a block device, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L194-L198)

ischardev(path) -> Bool

  1. Return `true` if `path` is a character device, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L169-L173)

isdir(path) -> Bool

  1. Return `true` if `path` is a directory, `false` otherwise.
  2. **Examples**

julia> isdir(homedir()) true

julia> isdir(“not/a/directory”) false

  1. See also: [`isfile`](#Base.Filesystem.isfile) and [`ispath`](#Base.Filesystem.ispath).
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L176-L191)

isfifo(path) -> Bool

  1. Return `true` if `path` is a FIFO, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L162-L166)

isfile(path) -> Bool

  1. Return `true` if `path` is a regular file, `false` otherwise.
  2. **Examples**

julia> isfile(homedir()) false

julia> f = open(“test_file.txt”, “w”);

julia> isfile(f) true

julia> close(f); rm(“test_file.txt”)

  1. See also: [`isdir`](#Base.Filesystem.isdir) and [`ispath`](#Base.Filesystem.ispath).
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L201-L220)

islink(path) -> Bool

  1. Return `true` if `path` is a symbolic link, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L223-L227)

ismount(path) -> Bool

  1. Return `true` if `path` is a mount point, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L328-L332)

ispath(path) -> Bool

  1. Return `true` if a valid filesystem entity exists at `path`, otherwise returns `false`. This is the generalization of [`isfile`](#Base.Filesystem.isfile), [`isdir`](#Base.Filesystem.isdir) etc.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L153-L159)

issetgid(path) -> Bool

  1. Return `true` if `path` has the setgid flag set, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L246-L250)

issetuid(path) -> Bool

  1. Return `true` if `path` has the setuid flag set, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L239-L243)

issocket(path) -> Bool

  1. Return `true` if `path` is a socket, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L230-L234)

issticky(path) -> Bool

  1. Return `true` if `path` has the sticky bit set, `false` otherwise.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/stat.jl#L253-L257)

homedir() -> String

  1. Return the current user's home directory.
  2. `homedir` determines the home directory via `libuv`'s `uv_os_homedir`. For details (for example on how to specify the home directory via environment variables), see the [`uv_os_homedir` documentation](http://docs.libuv.org/en/v1.x/misc.html#c.uv_os_homedir).
  3. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L54-L63)

dirname(path::AbstractString) -> AbstractString

  1. Get the directory part of a path. Trailing characters ('/' or '\\') in the path are counted as part of the path.
  2. **Examples**

julia> dirname(“/home/myuser”) “/home”

julia> dirname(“/home/myuser/“) “/home/myuser”

  1. See also: [`basename`](#Base.Filesystem.basename)
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L144-L160)

basename(path::AbstractString) -> AbstractString

  1. Get the file name part of a path.
  2. **Examples**

julia> basename(“/home/myuser/example.jl”) “example.jl”

  1. See also: [`dirname`](#Base.Filesystem.dirname)
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L163-L175)

@FILE -> AbstractString

  1. Expand to a string with the path to the file containing the macrocall, or an empty string if evaluated by `julia -e <expr>`. Return `nothing` if the macro was missing parser source information. Alternatively see [`PROGRAM_FILE`]($1877a82b3497e9ff.md#Base.PROGRAM_FILE).
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/loading.jl#L1480-L1487)

@DIR -> AbstractString

  1. Expand to a string with the absolute path to the directory of the file containing the macrocall. Return the current working directory if run from a REPL or if evaluated by `julia -e <expr>`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/loading.jl#L1493-L1499)

@LINE -> Int

  1. Expand to the line number of the location of the macrocall. Return `0` if the line number could not be determined.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/essentials.jl#L792-L797)

isabspath(path::AbstractString) -> Bool

  1. Determine whether a path is absolute (begins at the root directory).
  2. **Examples**

julia> isabspath(“/home”) true

julia> isabspath(“home”) false

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L87-L100)

isdirpath(path::AbstractString) -> Bool

  1. Determine whether a path refers to a directory (for example, ends with a path separator).
  2. **Examples**

julia> isdirpath(“/home”) false

julia> isdirpath(“/home/“) true

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L103-L116)

joinpath(parts::AbstractString…) -> String

  1. Join path components into a full path. If some argument is an absolute path or (on Windows) has a drive specification that doesn't match the drive computed for the join of the preceding paths, then prior components are dropped.
  2. Note on Windows since there is a current directory for each drive, `joinpath("c:", "foo")` represents a path relative to the current directory on drive "c:" so this is equal to "c:foo", not "c:\\foo". Furthermore, `joinpath` treats this as a non-absolute path and ignores the drive letter casing, hence `joinpath("C:\A","c:b") = "C:\A\b"`.
  3. **Examples**

julia> joinpath(“/home/myuser”, “example.jl”) “/home/myuser/example.jl”

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L304-L321)

abspath(path::AbstractString) -> String

  1. Convert a path to an absolute path by adding the current directory if necessary. Also normalizes the path as in [`normpath`](#Base.Filesystem.normpath).
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L377-L382)

abspath(path::AbstractString, paths::AbstractString…) -> String

  1. Convert a set of paths to an absolute path by joining them together and adding the current directory if necessary. Equivalent to `abspath(joinpath(path, paths...))`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L385-L390)

normpath(path::AbstractString) -> String

  1. Normalize a path, removing "." and ".." entries.
  2. **Examples**

julia> normpath(“/home/myuser/../example.jl”) “/home/example.jl”

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L324-L334)

normpath(path::AbstractString, paths::AbstractString…) -> String

  1. Convert a set of paths to a normalized path by joining them together and removing "." and ".." entries. Equivalent to `normpath(joinpath(path, paths...))`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L369-L374)

realpath(path::AbstractString) -> String

  1. Canonicalize a path by expanding symbolic links and removing "." and ".." entries. On case-insensitive case-preserving filesystems (typically Mac and Windows), the filesystem's stored case for the path is returned.
  2. (This function throws an exception if `path` does not exist in the filesystem.)
  3. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L412-L420)

relpath(path::AbstractString, startpath::AbstractString = “.”) -> AbstractString

  1. Return a relative filepath to `path` either from the current directory or from an optional start directory. This is a path computation: the filesystem is not accessed to confirm the existence or nature of `path` or `startpath`.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L482-L488)

expanduser(path::AbstractString) -> AbstractString

  1. On Unix systems, replace a tilde character at the start of a path with the current user's home directory.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L467-L471)

splitdir(path::AbstractString) -> (AbstractString, AbstractString)

  1. Split a path into a tuple of the directory name and file name.
  2. **Examples**

julia> splitdir(“/home/myuser”) (“/home”, “myuser”)

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L119-L129)

splitdrive(path::AbstractString) -> (AbstractString, AbstractString)

  1. On Windows, split a path into the drive letter part and the path part. On Unix systems, the first component is always the empty string.
  2. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L46-L51)

splitext(path::AbstractString) -> (AbstractString, AbstractString)

  1. If the last component of a path contains a dot, split the path into everything before the dot and everything including and after the dot. Otherwise, return a tuple of the argument unmodified and the empty string.
  2. **Examples**

julia> splitext(“/home/myuser/example.jl”) (“/home/myuser/example”, “.jl”)

julia> splitext(“/home/myuser/example”) (“/home/myuser/example”, “”)

  1. [source](https://github.com/JuliaLang/julia/blob/381693d3dfc9b7072707f6d544f82f6637fc5e7c/base/path.jl#L178-L193)

splitpath(path::AbstractString) -> Vector{String}

  1. Split a file path into all its path components. This is the opposite of `joinpath`. Returns an array of substrings, one for each directory or file in the path, including the root directory if present.
  2. This function requires at least Julia 1.1.
  3. **Examples**

julia> splitpath(“/home/myuser/example.jl”) 4-element Array{String,1}: “/“ “home” “myuser” “example.jl” ```

source