コード例 #1
0
ファイル: sftp.php プロジェクト: Combustible/core
 public function stat($path)
 {
     try {
         $stat = $this->client->stat($this->absPath($path));
         $mtime = $stat ? $stat['mtime'] : -1;
         $size = $stat ? $stat['size'] : 0;
         return array('mtime' => $mtime, 'size' => $size, 'ctime' => -1);
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #2
0
ファイル: SftpHelper.php プロジェクト: giovdk21/deployii
 /**
  * Returns the stat information of the given path.
  * It also sets the cache for the fileExists command.
  *
  * NOTE: the returned array structure depends on the current connection type
  *
  * @param string $path
  *
  * @return false|array
  */
 public function stat($path)
 {
     $stat = $this->_getFromCache(__FUNCTION__, $path);
     if ($stat === null) {
         switch ($this->_connType) {
             case SftpHelper::TYPE_SFTP:
             default:
                 $stat = $this->_connection->stat($path);
                 break;
             case SftpHelper::TYPE_FTP:
                 $stat = false;
                 if ($this->fileExists($path)) {
                     $stat = stat($this->_getStreamUrl($path));
                 }
                 break;
         }
         Log::logger()->addDebug('Performing ' . __METHOD__ . ' // result: {stat}', ['stat' => var_export($stat, true), 'path' => $path]);
         $this->_addToCache(__FUNCTION__, $path, $stat);
         $this->_addToCache('fileExists', $path, isset($stat['size']) ? true : false);
     }
     return $stat;
 }
コード例 #3
0
 /**
  * This method is called in response to all stat() related functions
  *
  * Retrieves information about a file
  *
  * @see SFTP_StreamWrapper::stream_stat()
  * @param String $path
  * @param Integer $flags
  * @return mixed
  * @access public
  */
 public function url_stat($path, $flags)
 {
     $connection = $this->stream_open($path, NULL, NULL, $opened_path);
     if ($connection === false) {
         return FALSE;
     }
     if ($flags === STREAM_URL_STAT_LINK) {
         $stat = $this->sftp->lstat($this->path);
     } else {
         $stat = $this->sftp->stat($this->path);
     }
     $this->stream_close();
     if (!empty($stat)) {
         // mode fix
         $stat['mode'] = $stat['permissions'];
         unset($stat['permissions']);
         return $stat;
     } else {
         return FALSE;
     }
 }