Example #1
0
<?php

use Naucon\File\File;
$examplePath = __DIR__ . '/example.txt';
$fileObject = new File($examplePath);
echo '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 '<br/>';
echo 'Filesize: ' . $fileObject->getSize() . ' bytes';
echo '<br/>';
echo 'Access Time: ' . $fileObject->lastAccessed()->format('d.m.Y H:s');
echo '<br/>';
echo 'Change Time: ' . $fileObject->lastChanged()->format('d.m.Y H:s');
echo '<br/>';
echo 'Modification Time: ' . $fileObject->lastModified()->format('d.m.Y H:s');
echo '<br/>';
echo '<br/>';
echo 'File Owner: ' . $fileObject->getOwnerName() . ' (' . $fileObject->getOwner() . ')';
echo '<br/>';
echo 'File Group: ' . $fileObject->getGroupName() . ' (' . $fileObject->getGroup() . ')';
echo '<br/>';
echo 'File permission: ' . $fileObject->getPermission();
echo '<br/>';
echo '<br/>';
echo 'Create new directory';
echo '<br/>';
$newDirectoryPath = __DIR__ . '/tmp/target/move/';
Example #2
0
 /**
  * @depends     testExist
  * @return      void
  */
 public function testLastAccessed()
 {
     $filePath = __DIR__ . '/example.txt';
     $fileObject = new File($filePath);
     $this->assertGreaterThanOrEqual(0, $fileObject->getATime());
     $this->assertInstanceOf('DateTime', $fileObject->lastAccessed());
     $fileObject = new \SplFileInfo($filePath);
     $this->assertGreaterThanOrEqual(0, $fileObject->getATime());
 }