isdir
isdir(path) -> Bool
Returns true
if path
is a directory, false
otherwise.
Examples
-
Check if a path is a directory:
julia> isdir("/path/to/directory") true
This example checks if the given path is a directory and returns
true
if it is. -
Handle non-existent paths:
julia> isdir("/nonexistent/directory") false
The function returns
false
for paths that do not exist on the filesystem. - Use relative paths:
julia> isdir("relative/path/to/directory") true
Relative paths can also be used with
isdir
to check if a directory exists relative to the current working directory.
Common mistake example:
julia> isdir("/path/to/file.txt")
ERROR: MethodError: no method matching isdir(::String)
In this example, the isdir
function is mistakenly used to check if a file exists. Remember that isdir
specifically checks for directories, not files. To check if a file exists, use the isfile
function instead.
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.