File module

file_length

procedureSource

The size of the file in bytes and whether it could be read. The position does not change.

file_length :: (file: File) -> (s64, bool)

Parameters

file: File

Returns

s64
bool
Example
#import "Extensions/Environment";
base := environment_variable("TMPDIR");
if base == "" base = environment_variable("TEMP");
if base == "" base = "/tmp";
path := tprint("%/jai-doc-length.bin", base);
defer file_delete(path);
assert(write_entire_file(path, "abcdef"));
file, ok := file_open(path);
assert(ok);
defer file_close(*file);
length, length_ok := file_length(file);
assert(length_ok && length == 6);

Doesn't run in the browser (only on windows).

See also