Filesystem¶
pwd() → AbstractString¶Get the current working directory.
cd([dir::AbstractString=homedir()])¶Set the current working directory.
cd(f[, dir=homedir()])Temporarily changes the current working directory and applies function
fbefore returning.
readdir([dir]) → Vector{ByteString}¶Returns the files and directories in the directory
dir(or the current working directory if not given).
mkdir(path[, mode])¶Make a new directory with name
pathand permissionsmode.modedefaults to 0o777, modified by the current file creation mask.
mkpath(path[, mode])¶Create all directories in the given
path, with permissionsmode.modedefaults to 0o777, modified by the current file creation mask.
symlink(target, link)¶Creates a symbolic link to
targetwith the namelink.note
This function raises an error under operating systems that do not support soft symbolic links, such as Windows XP.
readlink(path) → AbstractString¶Returns the value of a symbolic link
path.
chmod(path, mode)¶Change the permissions mode of
pathtomode. Only integermodes (e.g. 0o777) are currently supported.
stat(file)¶Returns a structure whose fields contain information about the file. The fields of the structure are:
size The size (in bytes) of the file device ID of the device that contains the file inode The inode number of the file mode The protection mode of the file nlink The number of hard links to the file uid The user id of the owner of the file gid The group id of the file owner rdev If this file refers to a device, the ID of the device it refers to blksize The file-system preferred block size for the file blocks The number of such blocks allocated mtime Unix timestamp of when the file was last modified ctime Unix timestamp of when the file was created
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.
ctime(file)¶Equivalent to
stat(file).ctime
mtime(file)¶Equivalent to
stat(file).mtime
filemode(file)¶Equivalent to
stat(file).mode
filesize(path...)¶Equivalent to
stat(file).size
uperm(file)¶Gets the permissions of the owner of the file as a bitfield of
01 Execute Permission 02 Write Permission 04 Read Permission For allowed arguments, see
stat.
gperm(file)¶Like uperm but gets the permissions of the group owning the file
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
cp(src::AbstractString, dst::AbstractString; remove_destination::Bool=false, follow_symlinks::Bool=false)¶Copy the file, link, or directory from src to dest.
remove_destination=truewill first remove an existingdst.If
follow_symlinks=false, andsrcis a symbolic link,dstwill be created as a symbolic link. Iffollow_symlinks=trueandsrcis a symbolic link,dstwill be a copy of the file or directorysrcrefers to.
download(url[, localfile])¶Download a file from the given url, optionally renaming it to the given local file name. Note that this function relies on the availability of external tools such as
curl,wgetorfetchto 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.
mv(src::AbstractString, dst::AbstractString; remove_destination::Bool=false)¶Move the file, link, or directory from
srctodst.remove_destination=truewill first remove an existingdst.
rm(path::AbstractString; recursive=false)¶Delete the file, link, or empty directory at the given path. If
recursive=trueis passed and the path is a directory, then all contents are removed recursively.
touch(path::AbstractString)¶Update the last-modified timestamp on a file to the current time.
tempname()¶Generate a unique temporary file path.
tempdir()¶Obtain the path of a temporary directory (possibly shared with other processes).
mktemp([parent=tempdir()])¶Returns
(path,io), wherepathis the path of a new temporary file inparentandiois an open file object for this path.
mktemp(f::Function[, parent=tempdir()])Apply the function
fto the result ofmktemp(parent)and remove the temporary file upon completion.
mktempdir([parent=tempdir()])¶Create a temporary directory in the
parentdirectory and return its path.
mktempdir(f::Function[, parent=tempdir()])Apply the function
fto the result ofmktempdir(parent)and remove the temporary directory upon completion.
isblockdev(path) → Bool¶Returns
trueifpathis a block device,falseotherwise.
ischardev(path) → Bool¶Returns
trueifpathis a character device,falseotherwise.
isdir(path) → Bool¶Returns
trueifpathis a directory,falseotherwise.
isexecutable(path) → Bool¶Returns
trueif the current user has permission to executepath,falseotherwise.
isfifo(path) → Bool¶Returns
trueifpathis a FIFO,falseotherwise.
isfile(path) → Bool¶Returns
trueifpathis a regular file,falseotherwise.
islink(path) → Bool¶Returns
trueifpathis a symbolic link,falseotherwise.
ismount(path) → Bool¶Returns
trueifpathis a mount point,falseotherwise.
ispath(path) → Bool¶Returns
trueifpathis a valid filesystem path,falseotherwise.
isreadable(path) → Bool¶Returns
trueif the current user has permission to readpath,falseotherwise.
issetgid(path) → Bool¶Returns
trueifpathhas the setgid flag set,falseotherwise.
issetuid(path) → Bool¶Returns
trueifpathhas the setuid flag set,falseotherwise.
issocket(path) → Bool¶Returns
trueifpathis a socket,falseotherwise.
issticky(path) → Bool¶Returns
trueifpathhas the sticky bit set,falseotherwise.
iswritable(path) → Bool¶Returns
trueif the current user has permission to write topath,falseotherwise.
homedir() → AbstractString¶Return the current user’s home directory.
dirname(path::AbstractString) → AbstractString¶Get the directory part of a path.
basename(path::AbstractString) → AbstractString¶Get the file name part of a path.
@__FILE__ -> AbstractString@__FILE__expands to a string with the absolute path and file name of the script being run. Returnsnothingif run from a REPL or an empty string if evaluated byjulia-e<expr>.
@__LINE__ -> Int@__LINE__expands to the line number of the call-site.
isabspath(path::AbstractString) → Bool¶Determines whether a path is absolute (begins at the root directory).
isdirpath(path::AbstractString) → Bool¶Determines whether a path refers to a directory (for example, ends with a path separator).
joinpath(parts...) → AbstractString¶Join path components into a full path. If some argument is an absolute path, then prior components are dropped.
abspath(path::AbstractString) → AbstractString¶Convert a path to an absolute path by adding the current directory if necessary.
normpath(path::AbstractString) → AbstractString¶Normalize a path, removing ”.” and ”..” entries.
realpath(path::AbstractString) → AbstractString¶Canonicalize a path by expanding symbolic links and removing ”.” and ”..” entries.
relpath(path::AbstractString, startpath::AbstractString = ".") → AbstractString¶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.
expanduser(path::AbstractString) → AbstractString¶On Unix systems, replace a tilde character at the start of a path with the current user’s home directory.
splitdir(path::AbstractString) -> (AbstractString, AbstractString)¶Split a path into a tuple of the directory name and file name.
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.
splitext(path::AbstractString) -> (AbstractString, AbstractString)¶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.