Beispiel #1
0
 public function unmount($path)
 {
     $path = Util::normalizePath($path);
     if (empty($path)) {
         throw new InvalidArgumentException('Mount path cannot be empty');
     }
 }
Beispiel #2
0
 /**
  * Create a new local adapter using a local pathname as base pathname.
  *
  * @param string $basePath The local base pathname.
  *
  * @throws InvalidArgumentException
  */
 public function __construct($basePath = null)
 {
     $basePath = Util::normalizePath($basePath);
     if (empty($basePath)) {
         throw new InvalidArgumentException('Pathname cannot be empty');
     }
     if (!is_dir($basePath)) {
         throw new InvalidArgumentException(sprintf('Pathname "%s" is not a directory', $basePath));
     }
     $this->basePath = $basePath . '/';
 }
Beispiel #3
0
 /**
  * Notify about config changes.
  */
 public function notifyConfigChange()
 {
     $host = $this->config->get(FilesystemConfig::HOST);
     $port = $this->config->get(FilesystemConfig::PORT);
     $username = $this->config->get(FilesystemConfig::USERNAME);
     $password = $this->config->get(FilesystemConfig::PASSWORD);
     $key = $this->config->get(self::CONFIG_KEY);
     $keyFile = $this->config->get(self::CONFIG_KEY_FILE);
     $basepath = $this->config->get('/' . FilesystemConfig::BASEPATH);
     if ($basepath) {
         $basepath = Util::normalizePath($basepath);
     }
     $connectUrl = $username;
     if ($keyFile) {
         $connectUrl .= ':' . crypt($keyFile . $password);
     } else {
         if ($key) {
             $connectUrl .= ':' . crypt($key . $password);
         } else {
             if ($password) {
                 $connectUrl .= ':' . crypt($password);
             }
         }
     }
     $connectUrl .= '@' . $host;
     if ($port) {
         $connectUrl .= ':' . $port;
     }
     $connectUrl .= $basepath;
     if ($this->connectionURL != $connectUrl) {
         if ($this->connection) {
             $this->connection->disconnect();
             $this->connection = null;
         }
         $this->connectionURL = $connectUrl;
     }
 }
Beispiel #4
0
 protected function evaluateFilters($filters)
 {
     if (Util::isTraversable($filters)) {
         // search for File::LIST_RECURSIVE
         foreach ($filters as $arg) {
             if (is_int($arg)) {
                 if ($this->bitmask === null) {
                     $this->bitmask = $arg;
                 } else {
                     $this->bitmask |= $arg;
                 }
             } else {
                 if (is_string($arg)) {
                     $this->globs[] = Util::normalizePath($arg);
                 } else {
                     if (is_callable($arg)) {
                         $this->callables[] = $arg;
                     } else {
                         if (is_array($arg)) {
                             $this->evaluateFilters($arg);
                         } else {
                             if (is_object($arg)) {
                                 $type = get_class($arg);
                             } else {
                                 ob_start();
                                 var_dump($arg);
                                 $type = ob_get_contents();
                                 ob_end_clean();
                             }
                             throw new Exception(sprintf('Can not use %s as listing filter.', $type));
                         }
                     }
                 }
             }
         }
     }
 }