Esempio n. 1
0
 static function make($file)
 {
     so_file::ensure($file);
     $nameList = $file->nameList;
     while ($nameList) {
         array_shift($nameList);
         $className = __NAMESPACE__ . '\\' . ($nameList ? 'so_source__' . implode('_', $nameList) : 'so_source');
         if (class_exists($className)) {
             return $className::makeAdapter($file);
         }
     }
     throw new \Exception("Can not make (so_source) for [{$file}]");
 }
Esempio n. 2
0
 function copy($target)
 {
     if (!$this->exists) {
         return $this;
     }
     so_file::ensure($target);
     $target->parent->exists = true;
     if (false === copy((string) $this, (string) $target)) {
         throw new \Exception("Can not copy [{$this}] to [{$target}]");
     }
     unset($target->version);
     unset($target->exists);
     unset($target->content);
     return $target;
 }
Esempio n. 3
0
 function copy($target)
 {
     if (!$this->exists) {
         return $this;
     }
     so_file::ensure($target);
     switch ($this->type) {
         case 'dir':
             foreach ($this->childs as $child) {
                 $child->copy($target[$child->name]);
             }
             break;
         case 'file':
             $target->parent->exists = true;
             if (false === copy((string) $this, (string) $target)) {
                 throw new \Exception("Can not copy [{$this}] to [{$target}]");
             }
             unset($target->version);
             unset($target->exists);
             unset($target->content);
             break;
     }
     return $target;
 }