コード例 #1
0
ファイル: FileExample.php プロジェクト: naucon/file
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/';
$newDirectoryFileObject = new File($newDirectoryPath);
if (!$newDirectoryFileObject->isDir()) {
    $newDirectoryFileObject->mkdirs();
}
echo 'Copy file to target directory';
echo '<br/>';
$examplePath = __DIR__ . '/example.txt';
$exampleCopyPath = __DIR__ . '/tmp/target/';
コード例 #2
0
ファイル: FileTest.php プロジェクト: naucon/file
 /**
  * @depends     testExist
  * @return      void
  */
 public function testChgrp()
 {
     $filePath = __DIR__ . '/example.txt';
     $fileObject = new File($filePath);
     $this->assertGreaterThanOrEqual(0, $userGroupId = $fileObject->getGroup());
     $this->assertGreaterThanOrEqual(0, strlen($userGroup = $fileObject->getGroupName()));
     if ($userGroupId > 0) {
         $this->assertTrue($fileObject->chgrp($userGroupId));
         $this->assertTrue($fileObject->chgrp($userGroup));
         $this->assertEquals($userGroupId, $fileObject->getGroup());
         $this->assertEquals($userGroup, $fileObject->getGroupName());
     }
 }