function test($name, $lc, $lp)
{
    static $i = 0;
    echo "==={$i}===\n";
    $i++;
    $o = new SplFileInfo($name);
    var_dump($o);
    $c = clone $o;
    var_dump($c);
    var_dump($o === $c);
    var_dump($o == $c);
    var_dump($o->getPathname() == $c->getPathname());
    try {
        $f = new SplFileObject($name);
        var_dump($name);
        var_dump($f->getPathName());
        $l = substr($f->getPathName(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lc);
        var_dump($f->getFileName());
        $l = substr($f->getFileName(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lc);
        var_dump($f->getPath());
        $l = substr($f->getPath(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lp);
    } catch (LogicException $e) {
        echo "LogicException: " . $e->getMessage() . "\n";
    }
    try {
        $fo = $o->openFile();
        var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath());
    } catch (LogicException $e) {
        echo "LogicException: " . $e->getMessage() . "\n";
    }
}
예제 #2
0
파일: Post.php 프로젝트: jeremyharris/build
 /**
  * Constructor
  *
  * @param \SplFileObject $post Post source file
  */
 public function __construct(\SplFileObject $post)
 {
     $this->source = $post;
     if (!preg_match('/[\\d]{4}\\/[\\d]{2}\\/(.+)$/', $post->getPathname())) {
         throw new \Exception(sprintf('%s is not a valid post', $post->getPathname()));
     }
     $paths = explode(DIRECTORY_SEPARATOR, $post->getPath());
     $this->month = $paths[count($paths) - 1];
     $this->year = $paths[count($paths) - 2];
     $this->slug = $post->getBasename('.' . $post->getExtension());
 }
예제 #3
0
 /**
  * @return string
  */
 public function getFilename()
 {
     return $this->movieFile->getPath() . DIRECTORY_SEPARATOR . $this->movieFile->getBasename();
 }
예제 #4
0
<?php

set_include_path('tests');
chdir(dirname(dirname(__FILE__)));
// ext/spl
$fo = new SplFileObject('fileobject_004.phpt', 'r', true);
var_dump($fo->getPath());
var_dump($fo->getFilename());
var_dump($fo->getRealPath());
?>
==DONE==
예제 #5
0
 /**
  * Compiles all required resources for the passed shop and template.
  * The function compiles all theme and plugin less files and
  * compresses the theme and plugin javascript and css files
  * into one file.
  *
  * @param $timestamp
  * @param Shop\Template $template
  * @param Shop\Shop $shop
  * @throws \Exception
  */
 public function compileLess($timestamp, Shop\Template $template, Shop\Shop $shop)
 {
     if ($shop->getMain()) {
         $shop = $shop->getMain();
     }
     $file = $this->pathResolver->getCssFilePath($shop, $timestamp);
     $file = new \SplFileObject($file, "a");
     if (!$file->flock(LOCK_EX)) {
         return;
     }
     $file->ftruncate(0);
     $this->compiler->setConfiguration($this->getCompilerConfiguration($shop));
     $config = $this->getConfig($template, $shop);
     $this->compiler->setVariables($config);
     $definitions = $this->collectLessDefinitions($template, $shop);
     foreach ($definitions as $definition) {
         $this->compileLessDefinition($shop, $definition);
     }
     $css = $this->compiler->get();
     $this->compiler->reset();
     $success = $file->fwrite($css);
     if ($success === null) {
         throw new \RuntimeException("Could not write to " . $file->getPath());
     }
     $file->flock(LOCK_UN);
     // release the lock
 }