beetlebug▾
/

ztcl::filefile

Flushes a file channel to the disk, and syncs a folder after a rename.

ztcl::file SUBCOMMAND ?ARG ...?

Description

The command for the order of writes to the disk. sync flushes the buffer of a file channel and then syncs its file, or syncs a folder after a rename into it.

The command exists when the embedder turns on the capability file, and the ztcl program turns it on with --allow file. It needs no package require. Each path goes through the folder jail of file and open, so a path outside the root is an error. A channel name is a name of the interpreter.

sync CHANNEL flushes the buffer of CHANNEL, then calls fsync on Linux, F_FULLFSYNC on macOS, and FlushFileBuffers on Windows. sync -dir PATH syncs the folder PATH on Linux and macOS. On Windows it checks the path, then does nothing and gives no error.

The examples of this page run in an empty root folder with --root . --allow file,channels.

Subcommands

SubcommandDescription
ztcl::file syncFlushes a channel and syncs its file, or syncs a folder.

Returns

The result of the subcommand.

Examples

% set f [open sync.txt w]
> puts $f hello
> ztcl::file sync $f
> close $f
> ztcl::file sync -dir .

Errors

% ztcl::file
wrong # args: should be "ztcl::file sync ?-dir? channel"
-errorcode TCL WRONGARGS

% ztcl::file bogus
unknown subcommand "bogus": must be sync
-errorcode TCL LOOKUP SUBCOMMAND bogus

Facts

Capability
file. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.9

The full page: ztcl::file.

See also