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:
36
file.php
36
file.php
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user