Example #1
0
 /**
  * Hash constructor.
  * creates a new hash set from a list of files
  *
  * @constructor
  * @access public
  * @param array $fileList
  */
 public function __construct(array $fileList)
 {
     $this->fileList = $fileList;
     foreach ($this->fileList as $filePath) {
         $file = new \SplFileInfo($filePath);
         // hash the file path, size and CTime using murmur
         $this->hashSet[$file->getRealPath()] = murmurhash3($file->getRealPath() . $file->getSize() . $file->getCTime());
     }
 }
 /**
  * @return array
  */
 public function toArray()
 {
     $rows = [];
     $currentDir = getcwd() . DIRECTORY_SEPARATOR;
     /* @var $reflection ReflectionFile  */
     foreach ($this->getIterator() as $reflection) {
         $row = [];
         $file = new \SplFileInfo($reflection->getName());
         $row = array("Files" => str_replace($currentDir, "", $file->getPathName()), "Owner" => $file->getOwner(), "Group" => $file->getGroup(), "Permissions" => $file->getPerms(), "Created" => date("d.m.Y h:m:s", $file->getCTime()), "Modified" => date("d.m.Y h:m:s", $file->getMTime()));
         $rows[] = $row;
     }
     return $rows;
 }
Example #3
0
 /**
  * create file from SplFileInfo
  *
  * @param SplFileInfo $file 
  * @return Post
  */
 private function createFileFromFileInfo(\SplFileInfo $file)
 {
     $post = new Post($this->getFilter());
     $post->setText(file_get_contents((string) $file));
     $post->setIdentifier(str_replace('.markdown', '', $file->getFilename()));
     $post->setCreated($file->getCTime());
     $post->setModified($file->getMTime());
     $matches = array();
     $found = preg_match('/#.*/', $post->getText(), $matches);
     if ($found === false) {
         $title = $file->getFilename();
     } else {
         $title = ltrim(array_shift($matches), '#');
     }
     $post->setTitle($title);
     //parse title out of body text
     return $post;
 }
Example #4
0
 /**
  * @inheritDoc
  */
 public function findAll()
 {
     try {
         $domainFiles = $this->finder->files('*')->depth('>= 1')->in($this->baseDir);
     } catch (\InvalidArgumentException $e) {
         $domainFiles = array();
     }
     $output = array();
     foreach ($domainFiles as $file) {
         $domainName = explode('/', $file->getPath());
         $domainName = array_pop($domainName);
         if (!array_key_exists($domainName, $output)) {
             $domainDir = new \SplFileInfo($file->getPath());
             $creationDate = $domainDir->getCTime();
             $output[$domainName] = new Domain($creationDate);
         }
         $domain = $output[$domainName];
         $domain->addFile($file, $this->read($file->getPathName()));
     }
     return $output;
 }
 public function workload_image($courseInstructorId, $lastDataUpdate = null)
 {
     $svgFilename = WEBROOT_DIR . DS . 'img' . DS . 'stats' . DS . $courseInstructorId . DS . "{$courseInstructorId}Workload.svg";
     $pngFilename = WEBROOT_DIR . DS . 'img' . DS . 'stats' . DS . $courseInstructorId . DS . "{$courseInstructorId}Workload.png";
     $createFile = true;
     if (!empty($lastDataUpdate) && file_exists(APP . $pngFilename)) {
         $lastDataUpdate = intval($lastDataUpdate);
         $fileInfo = new SplFileInfo(APP . $pngFilename);
         $lastFileChange = $fileInfo->getCTime();
         if ($lastDataUpdate < $lastFileChange) {
             $createFile = false;
         }
     }
     if ($createFile) {
         $this->_generateWorkloadPngFromSvg(APP . $svgFilename, APP . $pngFilename);
     }
     $this->response->file($pngFilename);
     return $this->response;
 }
Example #6
0
 public function testDecoratedMethods()
 {
     $decorated = $this->getMockBuilder('hanneskod\\classtools\\Tests\\MockSplFileInfo')->setConstructorArgs([''])->getMock();
     $decorated->expects($this->once())->method('getRelativePath');
     $decorated->expects($this->once())->method('getRelativePathname');
     $decorated->expects($this->once())->method('getContents');
     $decorated->expects($this->once())->method('getATime');
     $decorated->expects($this->once())->method('getBasename');
     $decorated->expects($this->once())->method('getCTime');
     $decorated->expects($this->once())->method('getExtension');
     $decorated->expects($this->once())->method('getFileInfo');
     $decorated->expects($this->once())->method('getFilename');
     $decorated->expects($this->once())->method('getGroup');
     $decorated->expects($this->once())->method('getInode');
     $decorated->expects($this->once())->method('getLinkTarget');
     $decorated->expects($this->once())->method('getMTime');
     $decorated->expects($this->once())->method('getOwner');
     $decorated->expects($this->once())->method('getPath');
     $decorated->expects($this->once())->method('getPathInfo');
     $decorated->expects($this->once())->method('getPathname');
     $decorated->expects($this->once())->method('getPerms');
     $decorated->expects($this->once())->method('getRealPath');
     $decorated->expects($this->once())->method('getSize');
     $decorated->expects($this->once())->method('getType');
     $decorated->expects($this->once())->method('isDir');
     $decorated->expects($this->once())->method('isExecutable');
     $decorated->expects($this->once())->method('isFile');
     $decorated->expects($this->once())->method('isLink');
     $decorated->expects($this->once())->method('isReadable');
     $decorated->expects($this->once())->method('isWritable');
     $decorated->expects($this->once())->method('openFile');
     $decorated->expects($this->once())->method('setFileClass');
     $decorated->expects($this->once())->method('setInfoClass');
     $decorated->expects($this->once())->method('__toString')->will($this->returnValue(''));
     $fileInfo = new SplFileInfo($decorated);
     $fileInfo->getRelativePath();
     $fileInfo->getRelativePathname();
     $fileInfo->getContents();
     $fileInfo->getATime();
     $fileInfo->getBasename();
     $fileInfo->getCTime();
     $fileInfo->getExtension();
     $fileInfo->getFileInfo();
     $fileInfo->getFilename();
     $fileInfo->getGroup();
     $fileInfo->getInode();
     $fileInfo->getLinkTarget();
     $fileInfo->getMTime();
     $fileInfo->getOwner();
     $fileInfo->getPath();
     $fileInfo->getPathInfo();
     $fileInfo->getPathname();
     $fileInfo->getPerms();
     $fileInfo->getRealPath();
     $fileInfo->getSize();
     $fileInfo->getType();
     $fileInfo->isDir();
     $fileInfo->isExecutable();
     $fileInfo->isFile();
     $fileInfo->isLink();
     $fileInfo->isReadable();
     $fileInfo->isWritable();
     $fileInfo->openFile();
     $fileInfo->setFileClass();
     $fileInfo->setInfoClass();
     (string) $fileInfo;
 }
 public function getCTime()
 {
     return $this->file->getCTime();
 }
Example #8
0
if (!empty($_SERVER['SERVER_SOFTWARE'])) {
    ?>
                <tr>
                    <td class="">Server Software</td>
                    <td><?php 
    echo $_SERVER['SERVER_SOFTWARE'];
    ?>
</td>
                </tr>
            <?php 
}
?>
            <tr>
                <td class="">Start Time</td>
                <td><?php 
echo date($date_format, $file_info->getCTime());
?>
</td>
            </tr>
            <tr>
                <td class="">Last Modified Time</td>
                <td><?php 
echo date($date_format, $file_info->getMTime());
?>
</td>
            </tr>
            </tbody>
        </table>
    </section>

    <section>
Example #9
0
<?php

include __DIR__ . '/../../../test/sample_dir/fix_mtimes.inc';
$info = new SplFileInfo(__DIR__ . '/../../sample_dir');
if (!$info->isFile()) {
    echo $info->getRealPath();
}
$info = new SplFileInfo(__DIR__ . '/../../sample_dir/file');
var_dump($info->getbaseName());
var_dump($info->getbaseName('.cpp'));
$info->getCTime();
$info->getGroup();
$info->getInode();
$info->getMTime();
$info->getOwner();
$info->getPerms();
$info->getSize();
$info->getType();
$info->isDir();
$info->isFile();
$info->isLink();
$info->isReadable();
$info->isWritable();
Example #10
0
 /**
  * Fetch item metadata
  *
  * @param string $key
  * @return array
  */
 public function fetchMetadata($key)
 {
     $info = new \SplFileInfo("{$this->root}/{$key}");
     return array('size' => $info->getSize(), 'change_time' => $info->getCTime());
 }
 public function getCTime($format = false)
 {
     if ($format) {
         return date($format, parent::getCTime());
     }
     return parent::getCTime();
 }
Example #12
0
 /**
  * @depends     testExist
  * @return      void
  */
 public function testLastChanged()
 {
     $filePath = __DIR__ . '/example.txt';
     $fileObject = new File($filePath);
     $this->assertGreaterThanOrEqual(0, $fileObject->getCTime());
     $this->assertInstanceOf('DateTime', $fileObject->lastChanged());
     $fileObject = new \SplFileInfo($filePath);
     $this->assertGreaterThanOrEqual(0, $fileObject->getCTime());
 }
Example #13
0
 protected function getFileDetailsRawStatistic(\SplFileInfo $info, $fileGiven)
 {
     return ['File is Dir' => $info->isDir(), 'File is Executable' => $info->isExecutable(), 'File is File' => $info->isFile(), 'File is Link' => $info->isLink(), 'File is Readable' => $info->isReadable(), 'File is Writable' => $info->isWritable(), 'File Permissions' => $this->explainPerms($info->getPerms()), 'Size' => $info->getSize(), 'Sha1' => sha1_file($fileGiven), 'Timestamp Accessed' => $this->getFileTimes($info->getATime()), 'Timestamp Changed' => $this->getFileTimes($info->getCTime()), 'Timestamp Modified' => $this->getFileTimes($info->getMTime())];
 }
Example #14
0
 /**
  * Check if this error is overdue of fixing
  *
  * Set interval via system settings
  *
  * @return boolean TRUE or FALSE
  */
 public function errorRemember()
 {
     $interval = $this->modx->getOption('jslog.error_interval', '', 0);
     $file = new SplFileInfo($this->config['errorPath'] . $this->error['key']);
     $interval = 0;
     if ($file->getCTime() < time() - $interval) {
         touch($this->config['errorPath'] . $this->error['key']);
         return true;
         // unlink($this->config['errorPath'] . $this->error['key']);
     }
     return false;
 }
Example #15
0
 /**
  * Create file instance from \SplFileInfo instance.
  *
  * @param \SplFileInfo $file
  * @param null|string $rootPath Root path of file.
  * @return File
  */
 public static function fromSplFileInfo(\SplFileInfo $file, $rootPath = null)
 {
     return new static($file->getPathname(), $rootPath, $file->getSize(), $file->getCTime(), $file->getMTime());
 }
 protected function mustBuildImage(File $file, $filename)
 {
     if ($this->timestampCheck == false) {
         return true;
     }
     $fs = new Filesystem();
     if (!$fs->exists($this->basePath . '/' . $filename)) {
         return true;
     }
     $info = new \SplFileInfo($this->basePath . '/' . $filename);
     if ($file->getTimestampLastChange() > $info->getCTime()) {
         return true;
     }
     // Change timestamp of the file, to mark it as "active"
     $fs->touch($this->basePath . '/' . $filename);
     return false;
 }