iswritable(path) -> Bool

Returns true if the current user has permission to write to path, false otherwise.


Check if a file is writable:

julia> iswritable("path/to/file.txt")

This example checks if the current user has permission to write to the file specified by the path "path/to/file.txt". If the user has write permission, it returns true.

julia> iswritable("/etc/passwd")

In this example, the function returns false because the current user does not have write permission for the file /etc/passwd.

Handle non-existent paths:

julia> iswritable("nonexistent/file.txt")

When the specified file or directory does not exist, iswritable returns false. It does not create the file or directory, only checks for write permission.

Common mistake example:

julia> iswritable("/root/file.txt")
ERROR: SystemError: Permission denied

In this example, the function throws an error because the current user does not have permission to access the file /root/file.txt. It's important to ensure that the user has the necessary permissions before calling iswritable to avoid such errors.

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.

*Required Field

Checking you are not a robot: