watch_file
watch_file(path, timeout_s::Real)
Watch file or directory path
for changes until a change occurs or timeout_s
seconds have elapsed.
The returned value is an object with boolean fields changed
, renamed
, and timedout
, giving the result of watching the file.
This behavior of this function varies slightly across platforms. See https://nodejs.org/api/fs.html#fs_caveats for more detailed information.
Examples
-
Watch a file for changes with a timeout:
julia> result = watch_file("file.txt", 10)
This example watches the file "file.txt" for changes for a maximum of 10 seconds. The
result
object will indicate whether the file has changed, been renamed, or if the timeout has occurred. -
Watch a directory for changes with a timeout:
julia> result = watch_file("directory/", 5)
This example watches the directory "directory/" for any changes, such as file additions or modifications, for a maximum of 5 seconds. The
result
object will indicate the status of the watch. -
Handle the watch timeout:
julia> result = watch_file("file.txt", 2)
In this example, the function will watch the file "file.txt" for a maximum of 2 seconds. If no changes occur within the specified timeout, the
result.timedout
field will betrue
.
Note: The behavior of watch_file
may vary slightly across platforms. For more detailed information, refer to the official Julia documentation or relevant platform-specific documentation.
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.