NAME
std/io - Filesystem paths and standard stream helpers.
SYNOPSIS
from std/io import Path, STDIN, STDOUT, STDERR;
let p := new Path("notes.txt");
p.spew_utf8("hello\n");
p.each_line( line => {
STDOUT.print(line);
} );
IMPLEMENTATION SUPPORT
This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and Electron. It is not supported by zuzu-js in the browser.
DESCRIPTION
This module provides path objects built on path semantics, an iterator for directory traversal, and objects for standard I/O streams.
EXPORTS
Classes
PathRepresents a filesystem path.
Construction and conversion:
new Path(String path = "")to_String
Path queries and transforms:
basename,canonpath,realpath,volumeabsolute,child,parent,siblingis_absolute,is_relative,is_rootdirsubsumes,exists,is_file,is_dir
Filesystem actions:
copy,move,remove,mkdir,mkdir_exclusive,remove_treemkdir_exclusive()performs one non-recursive directory creation attempt. It returns true if the directory was created, false if the path already exists, and throws for other filesystem errors.touch,touchpath,chmodsize,size_human,stat,lstat
Text and binary I/O:
spew,append,slurp,lines(BinaryString)spew_utf8,append_utf8,slurp_utf8,lines_utf8(String)spew_async,append_async,slurp_async,lines_asyncreturn awaitable
Taskvalues for binary file I/Ospew_utf8_async,append_utf8_async,slurp_utf8_async,lines_utf8_asyncreturn awaitableTaskvalues for UTF-8 file I/Oedit_lines,edit_lines_utf8each_line(callback, raw?)whereraw=trueyieldsBinaryStringnext_line(raw?)whereraw=truereturnsBinaryString
Traversal helpers:
children(...)iterator(...)returningPathIteratorvisit(callback, ...)
Static helpers:
Path.cwd(),Path.rootdir()Path.tempfile(...),Path.tempdir(...)Path.glob(pattern, options?)Path.join(parts)Path.split(path)Path.normalize(path)
PathIteratorDirectory iterator object with
next().STDINRead helpers:
next_line(raw?),each_line(callback, raw?). Withraw=true, values areBinaryString; otherwiseString.STDOUTWrite helpers:
print(...),say(...).STDERRWrite helpers:
print(...),say(...).
COPYRIGHT AND LICENCE
std/io is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.