/**
  *
  * @param SplFileInfo $file
  * @param string $path
  * @param RecursiveDirectoryIterator $iterator
  * @return boolean
  */
 public function call(\SplFileInfo $file, $path, \RecursiveDirectoryIterator $iterator)
 {
     $firstChar = substr($file->getFileName(), 0, 1);
     if (in_array($firstChar, ['.', '_'])) {
         return false;
     }
     if ($file->isDir()) {
         return true;
     }
     if (!in_array($file->getExtension(), $this->extensions)) {
         return false;
     }
     return true;
 }
Example #2
0
 public function properties($path)
 {
     $path = $this->preparePath($path);
     $file = new \SplFileInfo($path);
     $data['Name'] = $file->getFileName();
     $data['Type'] = $file->getType();
     $data['Size'] = $file->getSize() . ' b';
     $data['Location'] = $this->fileSystem->makePathRelative(pathinfo($file->getRealPath(), PATHINFO_DIRNAME), $this->root);
     return $data;
 }
<?php

/**
 * Read file info
 * @author Bramus Van Damme <*****@*****.**>
 */
$filename = __DIR__ . '/testfile.txt';
$fi = new SplFileInfo($filename);
echo '<p>The file ' . $fi->getFileName() . ' was last modified on ' . date('Y-m-d H:i:s', $fi->getMTime()) . '</p>' . PHP_EOL;
echo '<p>The file ' . $fi->getFileName() . ' is ' . ($fi->isDir() ? '' : 'not') . ' a directory</p>' . PHP_EOL;
echo '<p>The file ' . $fi->getFileName() . ' is ' . ($fi->isFile() ? '' : 'not') . ' a file</p>' . PHP_EOL;
echo '<p>The file ' . $fi->getFileName() . ' is ' . ($fi->isLink() ? '' : 'not') . ' a shortcut</p>' . PHP_EOL;
// EOF
<?php

$file = new SplFileInfo('spl_file_info.php');
print 'Nome: ' . $file->getFileName() . '<br>' . PHP_EOL;
print 'Extensão: ' . $file->getExtension() . '<br>' . PHP_EOL;
print 'Tamanho: ' . $file->getSize() . '<br>' . PHP_EOL;
print 'Caminho: ' . $file->getRealPath() . '<br>' . PHP_EOL;
print 'Tipo: ' . $file->getType() . '<br>' . PHP_EOL;
print 'Gravação: ' . $file->isWritable() . '<br>' . PHP_EOL;
 /**
  * Publishes a file
  *
  * @param \SplFileInfo $file
  */
 protected function publishFile($file)
 {
     $cache = $this->getFileCache();
     $id = $this->hash($file->getRealPath());
     if (!array_key_exists($id, $cache)) {
         $fileCache = array('sha' => 'cdnManager', 'ver' => $this->startVersion, 'run' => 0);
     } else {
         $fileCache = $cache[$id];
     }
     $crc = sha1_file($file->getRealPath());
     if ($fileCache['sha'] !== $crc) {
         $this->consoleEcho("Updating ", "0;32");
         $this->consoleEcho($file->getFileName() . " \r\n", true);
         $fileCache['ver'] = $fileCache['ver'] + 1;
         $fileCache['sha'] = $crc;
         $fileCache['pub'] = $this->assetManager->publish($file->getRealPath(), false, -1, true, $fileCache['ver']);
         $fileCache['run'] = $this->timeStamp;
         $cache[$id] = $fileCache;
         $this->setFileCache($cache);
     } else {
         $this->consoleEcho("No Change ", "0;33");
         $this->consoleEcho($file->getFileName() . "\r\n");
     }
 }
Example #6
0
 /**
  * File/directory sorting function
  * @param SplFileInfo $a First item
  * @param SplFileInfo $b Second item
  * @return boolean
  */
 private function internalSort($a, $b)
 {
     // Compare name
     return $a->getFileName() > $b->getFileName();
 }
Example #7
0
        echo 'wrote ' . $out_path . $req_uri . "\n";
    }
}
/**
 * copy php file
 */
$files = glob($pub_path . '/*');
foreach ($files as $file) {
    if (!is_file($file)) {
        continue;
    }
    $info = new \SplFileInfo($file);
    if ($info->getExtension() != 'php') {
        continue;
    }
    if ($info->getFileName() == 'index.php' || $info->getFileName() == 'phybrid_generator.php') {
        continue;
    }
    copy($file, $out_path . '/' . $info->getFileName());
    if ($debug) {
        echo 'copied ' . $file . "\n";
    }
}
/**
 * copy assets files and image files
 */
if (file_exists($pub_path . '/assets')) {
    system('cp -pfr ' . $pub_path . '/assets ' . $out_path . '/.');
    if ($debug) {
        echo "copied assets directory\n";
    }