예제 #1
0
 /**
  * Renames / moves a file.
  *
  * @param  string  $source Source file name
  * @param  string  $destination Target file name
  * @param  boolean $overwrite TRUE to overrides destination file if it exists
  * @return boolean TRUE if move succeeds
  */
 public function move($source, $destination, $overwrite = false)
 {
     if (!$this->exists($source)) {
         return false;
     }
     if ($this->exists($destination) && !$overwrite) {
         return false;
     }
     // make sure the directory exists!
     $dir = new Directories();
     $dir->mkdir(dirname($destination));
     return @rename($source, $destination);
 }
예제 #2
0
 public function testMkDirRecursively()
 {
     $d = __DIR__ . DIRECTORY_SEPARATOR . "levelone" . DIRECTORY_SEPARATOR . "secondlevel";
     $dir = new Dir();
     // directory does not exists
     $this->assertFalse(is_dir($d));
     $dir->mkdir($d);
     $this->assertTrue(is_dir($d));
     rmdir($d);
     rmdir(dirname($d));
 }