abspath
abspath(path::AbstractString) -> AbstractString
Convert a path to an absolute path by adding the current directory if necessary.
Examples
julia> abspath("file.txt")
"/Users/username/file.txt"
This example converts the relative path "file.txt" to an absolute path by adding the current directory.
julia> abspath("../folder/file.txt")
"/Users/username/folder/file.txt"
In this example, the relative path "../folder/file.txt" is converted to an absolute path by adding the current directory.
julia> abspath("/Users/username/file.txt")
"/Users/username/file.txt"
When an absolute path is provided, the abspath
function returns the same path without modification.
Common mistake example:
julia> abspath("non_existent/file.txt")
"/Users/username/non_existent/file.txt"
In this example, the provided path "non_existent/file.txt" is not a valid path, but abspath
still returns an absolute path. It's important to note that abspath
does not check if the path exists or is valid. It simply converts the given path to an absolute path.
See Also
abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.