Filesystem::path PHP Method

path() public static method

public static path ( $path, $absolute = true )
    public static function path($path, $absolute = true)
    {
        if (strpos($path, SPAGHETTI_ROOT) === false && !preg_match('(^[a-z]+:)i', $path, $out)) {
            if ($absolute) {
                $path = SPAGHETTI_ROOT . '/' . $path;
            }
        }
        $pattern = '(([^:])[/\\\\]+|\\\\)';
        // v.4.3
        return preg_replace($pattern, '$1/', $path);
    }

Usage Example

Example #1
0
 /**
  * Aplicar template de um arquivo único.
  *
  * @param $file
  * @param $target
  */
 public function file($file, $target)
 {
     // Verificar se template existe na lista
     if ($this->files->exists($file) != true) {
         error('Template %s não foi encontrado', $file);
     }
     $this->outpath = '';
     $this->filters = [$target];
     // Criar diretório destino
     $path = $this->files->path($target);
     $this->files->force($path);
     // Copiar arquivo
     $this->files->copy($file, $target);
     return $this;
 }
All Usage Examples Of Filesystem::path