Skip to main content

Zymba Documentation

IO

Text
object @IO() {
EOL;
append(string $path, string $string): int {}
appendLine(string $path, string $string): int {}
canExecute(string $path): bool {}
canRead(string $path): bool {}
canWrite(string $path): bool {}
copy(string $path, string $target) {}
countDirectories(string $path): int {}
countFiles(string $path): int {}
crc32(string $path): int {}
createDirectories(string $path, int $mode) {}
createDirectory(string $path, int $mode) {}
createFile(string $path): bool {}
createHardLink(string $path, string $target) {}
createSymbolicLink(string $path, string $target) {}
createTempFile(string $prefix): string {}
delete(string $path): string {}
deleteIfExists(string $path): bool {}
echo(string $path): int {}
execute(string $command): string {}
executeFlushed(string $command): int {}
exists(string $path): bool {}
getFreeSpace(string $path): float {}
getGroupID(string $path): int {}
getLastAccess(): int {}
getLastModified(): int {}
getPermissions(): int {}
getSize(string $path): int {}
getTotalSpace(string $path): float {}
getUsedSpace(string $path): float {}
getUserID(string $path): int {}
hasExistingTarget(string $path): bool {}
hasSameContent(string $path1, string $path2): bool {}
isDirectory(string $path): bool {}
isFile(string $path): bool {}
isRegularDirectory(string $path): bool {}
isRegularFile(string $path): bool {}
isSameFile(string $path1, string $path2): bool {}
isSymbolicLink(string $path): bool {}
listDirectories(string $path): object {}
listFiles(string $path): object {}
move(string $path, string $target) {}
quoteCommandArgument(string $argument): string {}
read(string $path, ?int $length): string {}
readCSV(string $path, string $delimiter): object {}
readJSON(string $path): mixed {}
readLines(string $path): object {}
readModifyWrite(string $path, function $callback, ?object $bind): string {}
readNonEmptyLines(string $path): object {}
readSymbolicLink(string $path): string {}
selectReadyStreams(?object $read, ?object $write, ?object $exceptional, ?number $timeout): int {}
setGroupByID(string $path, int $id) {}
setGroupByName(string $path, string $name) {}
setLastAccess(string $path, ?int $timestamp) {}
setLastModified(string $path, ?int $timestamp) {}
setPermissions(string $path, int $mode) {}
setUserByID(string $path, int $id) {}
setUserByName(string $path, string $name) {}
truncate(string $path, int $size) {}
write(string $path, string $string, ?int $length): int {}
writeCSV(string $path, object $array, string $delimiter): int {}
writeJSON(string $path, mixed $value): int {}
}

Static IO related constants, prototypes and functions.

Functions

Appends a string to a file and returns the number of bytes written.

CODE
@IO.append(string $path, string $string): int
Parameters
NameTypeValueDefault
pathstring""
stringstring""
Returns
TypeValue
int

Appends a string appended by an end-of-line sequence to a file and returns the number of bytes written.

CODE
@IO.appendLine(string $path, string $string): int
Parameters
NameTypeValueDefault
pathstring""
stringstring""
Returns
TypeValue
int

Determines whether a file exists and can be executed.

CODE
@IO.canExecute(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether a file exists and can be read from.

CODE
@IO.canRead(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether a file exists and can be written to.

CODE
@IO.canWrite(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Copies an existing file to a specific target.

CODE
@IO.copy(string $path, string $target): void
Parameters
NameTypeValueDefault
pathstring""
targetstring""

Counts the total number of subdirectories in an existing directory.

CODE
@IO.countDirectories(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Counts the total number of files in an existing directory.

CODE
@IO.countFiles(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Generates the 32-bit cyclic redundancy checksum polynomial of the content of an existing file as a signed integer.

CODE
@IO.crc32(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Creates directories recursively.

CODE
@IO.createDirectories(string $path, int $mode): void
Parameters
NameTypeValueDefault
pathstring""
modeint0o777

Creates a directory.

CODE
@IO.createDirectory(string $path, int $mode): void
Parameters
NameTypeValueDefault
pathstring""
modeint0o777

Creates an empty file if it does not exist and return whether it was newly created.

CODE
@IO.createFile(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Creates a hard link to a specific target.

CODE
@IO.createHardLink(string $path, string $target): void
Parameters
NameTypeValueDefault
pathstring""
targetstring""

Creates a symbolic link to a specific target.

CODE
@IO.createSymbolicLink(string $path, string $target): void
Parameters
NameTypeValueDefault
pathstring""
targetstring""

Creates an empty temporary file and returns its absolute path.

CODE
@IO.createTempFile(string $prefix): string
Parameters
NameTypeValueDefault
prefixstring"z"
Returns
TypeValue
string

Deletes an existing file.

CODE
@IO.delete(string $path): string
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
string

Deletes a file if it exists and return whether it existed.

CODE
@IO.deleteIfExists(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Outputs the content of an existing file and returns the number of bytes outputted.

CODE
@IO.echo(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Executes a shell command and returns its output.

CODE
@IO.execute(string $command): string
Parameters
NameTypeValueDefault
commandstring""
Returns
TypeValue
string

Executes a shell command, immediately flushes its output and returns the exit code.

CODE
@IO.executeFlushed(string $command): int
Parameters
NameTypeValueDefault
commandstring""
Returns
TypeValue
int

Determines whether a path exists.

CODE
@IO.exists(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Gets the free space of a filesystem in number of bytes.

CODE
@IO.getFreeSpace(string $path): float
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
float

Gets the group ID of an existing file.

CODE
@IO.getGroupID(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Gets the timestamp for the last access date and time of an existing file.

CODE
@IO.getLastAccess(): int
Returns
TypeValue
int

Gets the timestamp for the last modification date and time of an existing file.

CODE
@IO.getLastModified(): int
Returns
TypeValue
int

Gets the permissions of an existing file as the numeric mode.

CODE
@IO.getPermissions(): int
Returns
TypeValue
int

Gets the size of an existing file in number of bytes.

CODE
@IO.getSize(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Gets the total space of a filesystem in number of bytes.

CODE
@IO.getTotalSpace(string $path): float
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
float

Gets the used space of a filesystem in number of bytes.

CODE
@IO.getUsedSpace(string $path): float
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
float

Gets the user ID of an existing file.

CODE
@IO.getUserID(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Determines whether a symbolic link has an existing target.

CODE
@IO.hasExistingTarget(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether two existing files have the same content.

CODE
@IO.hasSameContent(string $path1, string $path2): bool
Parameters
NameTypeValueDefault
path1string""
path2string""
Returns
TypeValue
bool

Determines whether a path exists and resolves to a directory after following symbolic links.

CODE
@IO.isDirectory(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether a path exists and resolves to a file after following symbolic links.

CODE
@IO.isFile(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether a path exists and refers to a regular directory, without following symbolic links.

CODE
@IO.isRegularDirectory(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether a path exists and refers to a regular file, without following symbolic links.

CODE
@IO.isRegularFile(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Determines whether two existing paths refer to the same physical file on the file system.

CODE
@IO.isSameFile(string $path1, string $path2): bool
Parameters
NameTypeValueDefault
path1string""
path2string""
Returns
TypeValue
bool

Determines whether a path exists and refers to a symbolic link.

CODE
@IO.isSymbolicLink(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool
CODE
@IO.listDirectories(string $path): object
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
object[filename, ...]
CODE
@IO.listFiles(string $path): object
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
object[filename, ...]

Moves an existing file to a specific target.

CODE
@IO.move(string $path, string $target): void
Parameters
NameTypeValueDefault
pathstring""
targetstring""
CODE
@IO.quoteCommandArgument(string $argument): string
Parameters
NameTypeValueDefault
argumentstring""
Returns
TypeValue
string

Reads the content of an existing file up to a specific byte-based length.

CODE
@IO.read(string $path, ?int $length): string
Parameters
NameTypeValueDefault
pathstring""
length?intmaximum length
Returns
TypeValue
string
CODE
@IO.readCSV(string $path, string $delimiter): object
Parameters
NameTypeValueDefault
pathstring""
delimiterstring";"
Returns
TypeValue
object[[value, ...], ...]
CODE
@IO.readJSON(string $path): mixed
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
mixed
CODE
@IO.readLines(string $path): object
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
object[line, ...]
CODE
@IO.readModifyWrite(string $path, function $callback, ?object $bind): string
Parameters
NameTypeValueDefault
pathstring""
callbackfunctionnull
bind?objectnull
Returns
TypeValue
string
CODE
@IO.readNonEmptyLines(string $path): object
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
object[line, ...]
CODE
@IO.readSymbolicLink(string $path): string
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
string
CODE
@IO.selectReadyStreams(?object $read, ?object $write, ?object $exceptional, ?number $timeout): int
Parameters
NameTypeValueDefault
read?object[key: stream, ...]null
write?object[key: stream, ...]null
exceptional?object[key: stream, ...]null
timeout?numberblock indefinitely
Returns
TypeValue
int

Sets the group of an exiting file by ID.

CODE
@IO.setGroupByID(string $path, int $id): void
Parameters
NameTypeValueDefault
pathstring""
idint0

Sets the group of an exiting file by name.

CODE
@IO.setGroupByName(string $path, string $name): void
Parameters
NameTypeValueDefault
pathstring""
namestring""

Sets the last access date and time of an exiting file to a specific timestamp.

CODE
@IO.setLastAccess(string $path, ?int $timestamp): void
Parameters
NameTypeValueDefault
pathstring""
timestamp?intnow

Sets the last modification date and time of an exiting file to a specific timestamp.

CODE
@IO.setLastModified(string $path, ?int $timestamp): void
Parameters
NameTypeValueDefault
pathstring""
timestamp?intnow

Sets the permissions of an exiting file to a specific numeric mode.

CODE
@IO.setPermissions(string $path, int $mode): void
Parameters
NameTypeValueDefault
pathstring""
modeint0o777

Sets the user of an exiting file by ID.

CODE
@IO.setUserByID(string $path, int $id): void
Parameters
NameTypeValueDefault
pathstring""
idint0

Sets the user of an exiting file by name.

CODE
@IO.setUserByName(string $path, string $name): void
Parameters
NameTypeValueDefault
pathstring""
namestring""

Truncates an existing file to a specific size in number of bytes.

CODE
@IO.truncate(string $path, int $size): void
Parameters
NameTypeValueDefault
pathstring""
sizeint0

Writes a string to a file up to a specific byte-based length and returns the number of bytes written.

CODE
@IO.write(string $path, string $string, ?int $length): int
Parameters
NameTypeValueDefault
pathstring""
stringstring""
length?intmaximum length
Returns
TypeValue
int
CODE
@IO.writeCSV(string $path, object $array, string $delimiter): int
Parameters
NameTypeValueDefault
pathstring""
arrayobject[[value, ...], ...][]
delimiterstring";"
Returns
TypeValue
int
CODE
@IO.writeJSON(string $path, mixed $value): int
Parameters
NameTypeValueDefault
pathstring""
valuemixednull
Returns
TypeValue
int