Filesystem

Base.Filesystem.pwd — Function

  1. pwd() -> String

Get the current working directory.

See also: cd, tempdir.

Examples

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

source

Base.Filesystem.cd — Method

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

Set the current working directory.

See also: pwd, mkdir, mkpath, mktempdir.

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

Base.Filesystem.cd — Method

  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

Base.Filesystem.readdir — Function

  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 readdir(dir, sort=false) to opt out of sorting.

See also: walkdir.

Julia 1.4

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"
  34. julia> readdir(abspath("base"), join=true)
  35. 145-element Array{String,1}:
  36. "/home/JuliaUser/dev/julia/base/.gitignore"
  37. "/home/JuliaUser/dev/julia/base/Base.jl"
  38. "/home/JuliaUser/dev/julia/base/Enums.jl"
  39. "/home/JuliaUser/dev/julia/base/version_git.sh"
  40. "/home/JuliaUser/dev/julia/base/views.jl"
  41. "/home/JuliaUser/dev/julia/base/weakkeydict.jl"

source

Base.Filesystem.walkdir — Function

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

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 or stat encounters a IOError it will rethrow the error by default. A custom error handling function can be provided through onerror keyword argument. onerror is called with a IOError as argument.

See also: readdir.

Examples

  1. for (root, dirs, files) in walkdir(".")
  2. println("Directories in $root")
  3. for dir in dirs
  4. println(joinpath(root, dir)) # path to directories
  5. end
  6. println("Files in $root")
  7. for file in files
  8. println(joinpath(root, file)) # path to files
  9. end
  10. end
  1. julia> mkpath("my/test/dir");
  2. julia> itr = walkdir("my");
  3. julia> (root, dirs, files) = first(itr)
  4. ("my", ["test"], String[])
  5. julia> (root, dirs, files) = first(itr)
  6. ("my/test", ["dir"], String[])
  7. julia> (root, dirs, files) = first(itr)
  8. ("my/test/dir", String[], String[])

source

Base.Filesystem.mkdir — Function

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

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 for a function which creates all required intermediate directories. Return path.

Examples

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

source

Base.Filesystem.mkpath — Function

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

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, mkpath does not error if path (or parts of it) already exists. However, an error will be thrown if path (or parts of it) points to an existing file. 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

  1. julia> cd(mktempdir())
  2. julia> mkpath("my/test/dir") # creates three directories
  3. "my/test/dir"
  4. julia> readdir()
  5. 1-element Array{String,1}:
  6. "my"
  7. julia> cd("my")
  8. julia> readdir()
  9. 1-element Array{String,1}:
  10. "test"
  11. julia> readdir("test")
  12. 1-element Array{String,1}:
  13. "dir"
  14. julia> mkpath("intermediate_dir/actually_a_directory.txt") # creates two directories
  15. "intermediate_dir/actually_a_directory.txt"
  16. julia> isdir("intermediate_dir/actually_a_directory.txt")
  17. true

source

Base.Filesystem.hardlink — Function

  1. hardlink(src::AbstractString, dst::AbstractString)

Creates a hard link to an existing source file src with the name dst. The destination, dst, must not exist.

See also: symlink.

Julia 1.8

This method was added in Julia 1.8.

source

Base.Filesystem.symlink — Function

  1. symlink(target::AbstractString, link::AbstractString; dir_target = false)

Creates a symbolic link to target with the name link.

On Windows, symlinks must be explicitly declared as referring to a directory or not. If target already exists, by default the type of link will be auto- detected, however if target does not exist, this function defaults to creating a file symlink unless dir_target is set to true. Note that if the user sets dir_target but target exists and is a file, a directory symlink will still be created, but dereferencing the symlink will fail, just as if the user creates a file symlink (by calling symlink() with dir_target set to false before the directory is created) and tries to dereference it to a directory.

Additionally, there are two methods of making a link on Windows; symbolic links and junction points. Junction points are slightly more efficient, but do not support relative paths, so if a relative directory symlink is requested (as denoted by isabspath(target) returning false) a symlink will be used, else a junction point will be used. Best practice for creating symlinks on Windows is to create them only after the files/directories they reference are already created.

See also: hardlink.

Note

This function raises an error under operating systems that do not support soft symbolic links, such as Windows XP.

Julia 1.6

The dir_target keyword argument was added in Julia 1.6. Prior to this, symlinks to nonexistent paths on windows would always be file symlinks, and relative symlinks to directories were not supported.

source

Base.Filesystem.readlink — Function

  1. readlink(path::AbstractString) -> String

Return the target location a symbolic link path points to.

source

Base.Filesystem.chmod — Function

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

Change the permissions mode of path to mode. Only integer modes (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.

Note

Prior to Julia 1.6, this did not correctly manipulate filesystem ACLs on Windows, therefore it would only set read-only bits on files. It now is able to manipulate ACLs.

source

Base.Filesystem.chown — Function

  1. chown(path::AbstractString, owner::Integer, group::Integer=-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 owners and groups are currently supported. Return path.

source

Base.Libc.RawFD — Type

  1. RawFD

Primitive type which wraps the native OS file descriptor. RawFDs can be passed to methods like 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.

source

Base.stat — Function

  1. stat(file)

Return a structure whose fields contain information about the file. The fields of the structure are:

NameDescription
descThe path or OS file descriptor
sizeThe size (in bytes) of the file
deviceID of the device that contains the file
inodeThe inode number of the file
modeThe protection mode of the file
nlinkThe number of hard links to the file
uidThe user id of the owner of the file
gidThe group id of the file owner
rdevIf this file refers to a device, the ID of the device it refers to
blksizeThe file-system preferred block size for the file
blocksThe number of such blocks allocated
mtimeUnix timestamp of when the file was last modified
ctimeUnix timestamp of when the file’s metadata was changed

source

Base.Filesystem.diskstat — Function

  1. diskstat(path=pwd())

Returns statistics in bytes about the disk that contains the file or directory pointed at by path. If no argument is passed, statistics about the disk that contains the current working directory are returned.

Julia 1.8

This method was added in Julia 1.8.

source

Base.Filesystem.lstat — Function

  1. lstat(file)

Like 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.

source

Base.Filesystem.ctime — Function

  1. ctime(file)

Equivalent to stat(file).ctime.

source

Base.Filesystem.mtime — Function

  1. mtime(file)

Equivalent to stat(file).mtime.

source

Base.Filesystem.filemode — Function

  1. filemode(file)

Equivalent to stat(file).mode.

source

Base.filesize — Function

  1. filesize(path...)

Equivalent to stat(file).size.

source

Base.Filesystem.uperm — Function

  1. uperm(file)

Get the permissions of the owner of the file as a bitfield of

ValueDescription
01Execute Permission
02Write Permission
04Read Permission

For allowed arguments, see stat.

source

Base.Filesystem.gperm — Function

  1. gperm(file)

Like uperm but gets the permissions of the group owning the file.

source

Base.Filesystem.operm — Function

  1. operm(file)

Like uperm but gets the permissions for people who neither own the file nor are a member of the group owning the file

source

Base.Filesystem.cp — Function

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

Copy the file, link, or directory from src to dst. force=true will first remove an existing dst.

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.

Note

The cp function is different from the cp command. The cp function always operates on the assumption that dst is a file, while the command does different things depending on whether dst is a directory or a file. Using force=true when dst is a directory will result in loss of all the contents present in the dst directory, and dst will become a file that has the contents of src instead.

source

Base.download — Function

  1. download(url::AbstractString, [path::AbstractString = tempname()]) -> path

Download a file from the given url, saving it to the location path, or if not specified, a temporary path. Returns the path of the downloaded file.

Note

Since Julia 1.6, this function is deprecated and is just a thin wrapper around Downloads.download. In new code, you should use that function directly instead of calling this.

source

Base.Filesystem.mv — Function

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

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

Examples

  1. julia> write("hello.txt", "world");
  2. julia> mv("hello.txt", "goodbye.txt")
  3. "goodbye.txt"
  4. julia> "hello.txt" in readdir()
  5. false
  6. julia> readline("goodbye.txt")
  7. "world"
  8. julia> write("hello.txt", "world2");
  9. julia> mv("hello.txt", "goodbye.txt")
  10. ERROR: ArgumentError: 'goodbye.txt' exists. `force=true` is required to remove 'goodbye.txt' before moving.
  11. Stacktrace:
  12. [1] #checkfor_mv_cp_cptree#10(::Bool, ::Function, ::String, ::String, ::String) at ./file.jl:293
  13. [...]
  14. julia> mv("hello.txt", "goodbye.txt", force=true)
  15. "goodbye.txt"
  16. julia> rm("goodbye.txt");

source

Base.Filesystem.rm — Function

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

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.

Examples

  1. julia> mkpath("my/test/dir");
  2. julia> rm("my", recursive=true)
  3. julia> rm("this_file_does_not_exist", force=true)
  4. julia> rm("this_file_does_not_exist")
  5. ERROR: IOError: unlink("this_file_does_not_exist"): no such file or directory (ENOENT)
  6. Stacktrace:
  7. [...]

source

Base.Filesystem.touch — Function

  1. Base.touch(::Pidfile.LockMonitor)

Update the mtime on the lock, to indicate it is still fresh.

See also the refresh keyword in the mkpidlock constructor.

  1. touch(path::AbstractString)
  2. touch(fd::File)

Update the last-modified timestamp on a file to the current time.

If the file does not exist a new file is created.

Return path.

Examples

  1. julia> write("my_little_file", 2);
  2. julia> mtime("my_little_file")
  3. 1.5273815391135583e9
  4. julia> touch("my_little_file");
  5. julia> mtime("my_little_file")
  6. 1.527381559163435e9

We can see the mtime has been modified by touch.

source

Base.Filesystem.tempname — Function

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

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 possibility 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.

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.

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.

Julia 1.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.

Warning

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() is also recommended instead.

source

Base.Filesystem.tempdir — Function

  1. tempdir()

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.

source

Base.Filesystem.mktemp — Method

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

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.

Julia 1.3

The cleanup keyword argument was added in Julia 1.3. Relatedly, starting from 1.3, Julia will remove the temporary paths created by mktemp when the Julia process exits, unless cleanup is explicitly set to false.

source

Base.Filesystem.mktemp — Method

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

Apply the function f to the result of mktemp(parent) and remove the temporary file upon completion.

See also: mktempdir.

source

Base.Filesystem.mktempdir — Method

  1. mktempdir(parent=tempdir(); prefix="jl_", cleanup=true) -> path

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, on some platforms, any trailing 'X' characters in prefix 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.

Julia 1.2

The prefix keyword argument was added in Julia 1.2.

Julia 1.3

The cleanup keyword argument was added in Julia 1.3. Relatedly, starting from 1.3, Julia will remove the temporary paths created by mktempdir when the Julia process exits, unless cleanup is explicitly set to false.

See also: mktemp, mkdir.

source

Base.Filesystem.mktempdir — Method

  1. mktempdir(f::Function, parent=tempdir(); prefix="jl_")

Apply the function f to the result of mktempdir(parent; prefix) and remove the temporary directory all of its contents upon completion.

See also: mktemp, mkdir.

Julia 1.2

The prefix keyword argument was added in Julia 1.2.

source

Base.Filesystem.isblockdev — Function

  1. isblockdev(path) -> Bool

Return true if path is a block device, false otherwise.

source

Base.Filesystem.ischardev — Function

  1. ischardev(path) -> Bool

Return true if path is a character device, false otherwise.

source

Base.Filesystem.isdir — Function

  1. isdir(path) -> Bool

Return true if path is a directory, false otherwise.

Examples

  1. julia> isdir(homedir())
  2. true
  3. julia> isdir("not/a/directory")
  4. false

See also isfile and ispath.

source

Base.Filesystem.isfifo — Function

  1. isfifo(path) -> Bool

Return true if path is a FIFO, false otherwise.

source

Base.Filesystem.isfile — Function

  1. isfile(path) -> Bool

Return true if path is a regular file, false otherwise.

Examples

  1. julia> isfile(homedir())
  2. false
  3. julia> filename = "test_file.txt";
  4. julia> write(filename, "Hello world!");
  5. julia> isfile(filename)
  6. true
  7. julia> rm(filename);
  8. julia> isfile(filename)
  9. false

See also isdir and ispath.

source

Base.Filesystem.islink — Function

  1. islink(path) -> Bool

Return true if path is a symbolic link, false otherwise.

source

Base.Filesystem.ismount — Function

  1. ismount(path) -> Bool

Return true if path is a mount point, false otherwise.

source

Base.Filesystem.ispath — Function

  1. ispath(path) -> Bool

Return true if a valid filesystem entity exists at path, otherwise returns false. This is the generalization of isfile, isdir etc.

source

Base.Filesystem.issetgid — Function

  1. issetgid(path) -> Bool

Return true if path has the setgid flag set, false otherwise.

source

Base.Filesystem.issetuid — Function

  1. issetuid(path) -> Bool

Return true if path has the setuid flag set, false otherwise.

source

Base.Filesystem.issocket — Function

  1. issocket(path) -> Bool

Return true if path is a socket, false otherwise.

source

Base.Filesystem.issticky — Function

  1. issticky(path) -> Bool

Return true if path has the sticky bit set, false otherwise.

source

Base.Filesystem.homedir — Function

  1. homedir() -> String

Return the current user’s home directory.

Note

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.

source

Base.Filesystem.dirname — Function

  1. dirname(path::AbstractString) -> String

Get the directory part of a path. Trailing characters (‘/‘ or ‘\‘) in the path are counted as part of the path.

Examples

  1. julia> dirname("/home/myuser")
  2. "/home"
  3. julia> dirname("/home/myuser/")
  4. "/home/myuser"

See also basename.

source

Base.Filesystem.basename — Function

  1. basename(path::AbstractString) -> String

Get the file name part of a path.

Note

This function differs slightly from the Unix basename program, where trailing slashes are ignored, i.e. $ basename /foo/bar/ returns bar, whereas basename in Julia returns an empty string "".

Examples

  1. julia> basename("/home/myuser/example.jl")
  2. "example.jl"
  3. julia> basename("/home/myuser/")
  4. ""

See also dirname.

source

Base.Filesystem.isabspath — Function

  1. isabspath(path::AbstractString) -> Bool

Determine whether a path is absolute (begins at the root directory).

Examples

  1. julia> isabspath("/home")
  2. true
  3. julia> isabspath("home")
  4. false

source

Base.Filesystem.isdirpath — Function

  1. isdirpath(path::AbstractString) -> Bool

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

Examples

  1. julia> isdirpath("/home")
  2. false
  3. julia> isdirpath("/home/")
  4. true

source

Base.Filesystem.joinpath — Function

  1. joinpath(parts::AbstractString...) -> String
  2. joinpath(parts::Vector{AbstractString}) -> String
  3. joinpath(parts::Tuple{AbstractString}) -> String

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.

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".

Examples

  1. julia> joinpath("/home/myuser", "example.jl")
  2. "/home/myuser/example.jl"
  1. julia> joinpath(["/home/myuser", "example.jl"])
  2. "/home/myuser/example.jl"

source

Base.Filesystem.abspath — Function

  1. abspath(path::AbstractString) -> String

Convert a path to an absolute path by adding the current directory if necessary. Also normalizes the path as in normpath.

Example

If you are in a directory called JuliaExample and the data you are using is two levels up relative to the JuliaExample directory, you could write:

abspath(“../../data”)

Which gives a path like "/home/JuliaUser/data/".

See also joinpath, pwd, expanduser.

source

  1. abspath(path::AbstractString, paths::AbstractString...) -> String

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...)).

source

Base.Filesystem.normpath — Function

  1. normpath(path::AbstractString) -> String

Normalize a path, removing “.” and “..” entries and changing “/“ to the canonical path separator for the system.

Examples

  1. julia> normpath("/home/myuser/../example.jl")
  2. "/home/example.jl"
  3. julia> normpath("Documents/Julia") == joinpath("Documents", "Julia")
  4. true

source

  1. normpath(path::AbstractString, paths::AbstractString...) -> String

Convert a set of paths to a normalized path by joining them together and removing “.” and “..” entries. Equivalent to normpath(joinpath(path, paths...)).

source

Base.Filesystem.realpath — Function

  1. realpath(path::AbstractString) -> String

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.

(This function throws an exception if path does not exist in the filesystem.)

source

Base.Filesystem.relpath — Function

  1. relpath(path::AbstractString, startpath::AbstractString = ".") -> String

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.

On Windows, case sensitivity is applied to every part of the path except drive letters. If path and startpath refer to different drives, the absolute path of path is returned.

source

Base.Filesystem.expanduser — Function

  1. expanduser(path::AbstractString) -> AbstractString

On Unix systems, replace a tilde character at the start of a path with the current user’s home directory.

See also: contractuser.

source

Base.Filesystem.contractuser — Function

  1. contractuser(path::AbstractString) -> AbstractString

On Unix systems, if the path starts with homedir(), replace it with a tilde character.

See also: expanduser.

source

Base.Filesystem.samefile — Function

  1. samefile(path_a::AbstractString, path_b::AbstractString)

Check if the paths path_a and path_b refer to the same existing file or directory.

source

Base.Filesystem.splitdir — Function

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

Split a path into a tuple of the directory name and file name.

Examples

  1. julia> splitdir("/home/myuser")
  2. ("/home", "myuser")

source

Base.Filesystem.splitdrive — Function

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

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.

source

Base.Filesystem.splitext — Function

  1. splitext(path::AbstractString) -> (String, String)

If the last component of a path contains one or more dots, split the path into everything before the last dot and everything including and after the dot. Otherwise, return a tuple of the argument unmodified and the empty string. “splitext” is short for “split extension”.

Examples

  1. julia> splitext("/home/myuser/example.jl")
  2. ("/home/myuser/example", ".jl")
  3. julia> splitext("/home/myuser/example.tar.gz")
  4. ("/home/myuser/example.tar", ".gz")
  5. julia> splitext("/home/my.user/example")
  6. ("/home/my.user/example", "")

source

Base.Filesystem.splitpath — Function

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

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.

Julia 1.1

This function requires at least Julia 1.1.

Examples

  1. julia> splitpath("/home/myuser/example.jl")
  2. 4-element Vector{String}:
  3. "/"
  4. "home"
  5. "myuser"
  6. "example.jl"

source