webCOMAND

util::chown()

Change the user and group ownership on a file or folder, including any contained files and subfolders recursively.

Prototype

chown(string $path, string $user = '', string $group = '', bool $force = FALSE)

Parameters

  • path - The fully qualified path to a file or directory to delete.
  • user - The username to change ownership to, if specified.
  • group - The group name to change ownership to, if specified.
  • force - If TRUE, the ownership will be updated on files and folders, even they are outside the configured webCOMAND Files, System and Temp folders.

Exceptions

The function will throw an exception if the path, files and subfolders cannot be modified.

Example

// recursively update the ownership user of a folder under webCOMAND's Files path
try {
    \io_comand_file\util\chown('/var/www/webcomand/files/test', 'sue');
} catch(\exception $e) {
    \comand::log_error("Could not update test dir: " . $e->getMessage());
}

Related

chmod()