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.
| Parameter | Type | Requirement | Explanation |
|---|---|---|---|
what | string | required | Path to the file or directory whose ownership you want to change |
user | string | required | Name of the local OS user to assign as the new owner |
| Return value | Explanation |
|---|---|
true | Ownership was updated successfully |
false | The 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.');
}