Skip to content

Chown (change file owner)

ts
function Chown(what: string, user: string): boolean;

Changes the ownership of the file or directory specified by what to the local OS user user. Returns true on success, false on failure.

IMPORTANT

Chown is a POSIX/Linux-only function. It is a no-op on Windows and will always return false there. It also requires that ss-wrk is running as root; otherwise the operating system will deny the chown system call.

ParameterTypeRequirementExplanation
whatstringrequiredPath to the file or directory whose ownership you want to change
userstringrequiredName of the local OS user to assign as the new owner
Return valueExplanation
trueOwnership was updated successfully
falseThe operation failed (insufficient privileges, user not found, Windows, etc.)

Example

ts
var ok = Chown('/var/uploads/report.csv', 'alice');
if (!ok) {
  Log('WARNING: Could not change file owner.');
}