예제 #1
0
파일: FileExample.php 프로젝트: naucon/file
if (!$newDirectoryFileObject->isDir()) {
    $newDirectoryFileObject->mkdirs();
}
echo 'Copy file to target directory';
echo '<br/>';
$examplePath = __DIR__ . '/example.txt';
$exampleCopyPath = __DIR__ . '/tmp/target/';
$fileObject = new File($examplePath);
$fileObject->copy($exampleCopyPath);
$fileObject->rename('example_copy.txt');
echo 'Move copied file to a new directory';
echo '<br/>';
$exampleMovePath = __DIR__ . '/tmp/target/move/';
$fileObject->move($exampleMovePath);
$fileObject->rename('example_move.txt');
echo 'Moved File ' . $fileObject->getPathname() . ' do' . ($fileObject->exists() ? '' : ' not') . ' exist.';
echo '<br/>';
echo 'File is' . ($fileObject->isReadable() ? '' : ' not') . ' readable.';
echo '<br/>';
echo 'File is' . ($fileObject->isWritable() ? '' : ' not') . ' writeable.';
echo '<br/>';
echo 'File permission: ' . $fileObject->getPermission();
echo '<br/>';
echo '<br/>';
echo 'Remove file';
echo '<br/>';
$deletePath = __DIR__ . '/tmp/example.txt';
$fileObject = new File($deletePath);
$fileObject->delete();
echo 'Remove directories';
echo '<br/>';
예제 #2
0
파일: FileTest.php 프로젝트: naucon/file
 /**
  * @return    void
  */
 public function testExist()
 {
     $path = __DIR__;
     $filePath = __DIR__ . '/example.txt';
     $fileObject = new File($filePath);
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->exists());
     $fileObject = new File($path);
     $this->assertEquals($path, $fileObject->getPathname());
     $this->assertTrue($fileObject->exists());
     $fileObject = new \SplFileInfo($filePath);
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isFile());
     // SplFileInfo has no exist method
     $fileObject = new \SplFileInfo($path);
     $this->assertEquals($path, $fileObject->getPathname());
     $this->assertTrue($fileObject->isDir());
     // SplFileInfo has no exist method
 }