/** * * Sets the permissions on this directory using a 9 [rwx-] character string. * This operation is not guaranteed to succeed. * * @param string $rwx_permissions The string permissions to set for this directory. * @param boolean $recursive defaults to false, sets the permissions to all the child file system elements. * @return boolean true if the operation was succesfull, false otherwise. * * @api */ public function setPermissions($rwx_permissions, $recursive = false) { $result = $this->setPermissionsRwx($rwx_permissions); if ($recursive) { foreach ($this->listFolders() as $folder) { $rr = Dir::asDir($folder)->setPermissions($rwx_permissions, $recursive); $result &= $rr; } foreach ($this->listFiles() as $file) { $rr = File::asFile($file)->setPermissionsRwx($rwx_permissions); $result &= $rr; } } return $result; }
/** * * Saves the uploaded file in the path specified by the provided file. * The temporary upload file is deleted. * * @param \Mbcraft\Piol\File|string $file The file instance or string path where to save the uploaded file. * @return boolean true if the operation was successfull, false otherwise. * * @api */ public function moveAs($file) { if (file_exists($this->my_tmp_name)) { $final_file = File::asFile($file); $tmp_path = $this->getTmpPath(); return move_uploaded_file($tmp_path, $final_file->getFullPath()); } else { return false; } }