file : add rename and copy functions

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2956 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-07-25 18:54:31 +00:00
parent fb32656cfc
commit 4bc2fcaf6c

View File

@@ -260,6 +260,42 @@ class file
return $rc;
}
/** Copy a file
* @param string $oldname The file to rename
* @param string $newname The new name of the file. It will be
* overwrited if it already exists
* @return bool
*/
public function copy ($oldname, $newname)
{
$this->debug (2, "copy ($oldname, $newname)");
$oldname = $this->realpath ($oldname);
$newname = $this->realpath ($newname);
$this->checkPathRO (dirname ($oldname));
$this->checkPathRW (dirname ($newname));
$rc = copy ($oldname, $newname);
$this->debug (1, "copy ($oldname, $newname) => $rc");
return $rc;
}
/** Renames a file or directory
* @param string $oldname The file or directory to rename
* @param string $newname The new name of the file or directory. It will be
* overwrited if it already exists
* @return bool
*/
public function rename ($oldname, $newname)
{
$this->debug (2, "rename ($oldname, $newname)");
$oldname = $this->realpath ($oldname);
$newname = $this->realpath ($newname);
$this->checkPathRO (dirname ($oldname));
$this->checkPathRW (dirname ($newname));
$rc = rename ($oldname, $newname);
$this->debug (1, "rename ($oldname, $newname) => $rc");
return $rc;
}
/** Return a ini file converted to an array
* @param string $filename The filename of the ini file being parsed.
* @param bool $process_sections Process the sections