当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::putFileInfo方法代码示例

本文整理汇总了PHP中OC\Files\Filesystem::putFileInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::putFileInfo方法的具体用法?PHP Filesystem::putFileInfo怎么用?PHP Filesystem::putFileInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::putFileInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateProperties

 /**
  * Updates properties on this node,
  * @see \Sabre\DAV\IProperties::updateProperties
  * @param array $properties
  * @return boolean
  */
 public function updateProperties($properties)
 {
     $existing = $this->getProperties(array());
     foreach ($properties as $propertyName => $propertyValue) {
         // If it was null, we need to delete the property
         if (is_null($propertyValue)) {
             if (array_key_exists($propertyName, $existing)) {
                 $query = OC_DB::prepare('DELETE FROM `*PREFIX*properties`' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?');
                 $query->execute(array(OC_User::getUser(), $this->path, $propertyName));
             }
         } else {
             if (strcmp($propertyName, self::GETETAG_PROPERTYNAME) === 0) {
                 \OC\Files\Filesystem::putFileInfo($this->path, array('etag' => $propertyValue));
             } elseif (strcmp($propertyName, self::LASTMODIFIED_PROPERTYNAME) === 0) {
                 $this->touch($propertyValue);
             } else {
                 if (!array_key_exists($propertyName, $existing)) {
                     $query = OC_DB::prepare('INSERT INTO `*PREFIX*properties`' . ' (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)');
                     $query->execute(array(OC_User::getUser(), $this->path, $propertyName, $propertyValue));
                 } else {
                     $query = OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertyvalue` = ?' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?');
                     $query->execute(array($propertyValue, OC_User::getUser(), $this->path, $propertyName));
                 }
             }
         }
     }
     $this->setPropertyCache(null);
     return true;
 }
开发者ID:Combustible,项目名称:core,代码行数:35,代码来源:node.php

示例2: encryptAll

 /**
  * Encrypt all files in a directory
  * @param string $dirPath the directory whose files will be encrypted
  * @return bool
  * @note Encryption is recursive
  */
 public function encryptAll($dirPath)
 {
     $result = true;
     $found = $this->findEncFiles($dirPath);
     // Disable proxy to prevent file being encrypted twice
     \OC_FileProxy::$enabled = false;
     $versionStatus = \OCP\App::isEnabled('files_versions');
     \OC_App::disable('files_versions');
     $encryptedFiles = array();
     // Encrypt unencrypted files
     foreach ($found['plain'] as $plainFile) {
         //get file info
         $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
         //relative to data/<user>/file
         $relPath = $plainFile['path'];
         //relative to /data
         $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
         // keep timestamp
         $timestamp = $fileInfo['mtime'];
         // Open plain file handle for binary reading
         $plainHandle = $this->view->fopen($rawPath, 'rb');
         // Open enc file handle for binary writing, with same filename as original plain file
         $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
         if (is_resource($encHandle) && is_resource($plainHandle)) {
             // Move plain file to a temporary location
             $size = stream_copy_to_stream($plainHandle, $encHandle);
             fclose($encHandle);
             fclose($plainHandle);
             $fakeRoot = $this->view->getRoot();
             $this->view->chroot('/' . $this->userId . '/files');
             $this->view->rename($relPath . '.part', $relPath);
             // set timestamp
             $this->view->touch($relPath, $timestamp);
             $encSize = $this->view->filesize($relPath);
             $this->view->chroot($fakeRoot);
             // Add the file to the cache
             \OC\Files\Filesystem::putFileInfo($relPath, array('encrypted' => true, 'size' => $encSize, 'unencrypted_size' => $size, 'etag' => $fileInfo['etag']));
             $encryptedFiles[] = $relPath;
         } else {
             \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt ' . $rawPath, \OCP\Util::FATAL);
             $result = false;
         }
     }
     \OC_FileProxy::$enabled = true;
     if ($versionStatus) {
         \OC_App::enable('files_versions');
     }
     $result = $result && $this->encryptVersions($encryptedFiles);
     return $result;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:56,代码来源:util.php

示例3: encryptAll

 /**
  * @brief Encrypt all files in a directory
  * @param string $dirPath the directory whose files will be encrypted
  * @param null $legacyPassphrase
  * @param null $newPassphrase
  * @return bool
  * @note Encryption is recursive
  */
 public function encryptAll($dirPath, $legacyPassphrase = null, $newPassphrase = null)
 {
     $found = $this->findEncFiles($dirPath);
     if ($found) {
         // Disable proxy to prevent file being encrypted twice
         \OC_FileProxy::$enabled = false;
         $versionStatus = \OCP\App::isEnabled('files_versions');
         \OC_App::disable('files_versions');
         $encryptedFiles = array();
         // Encrypt unencrypted files
         foreach ($found['plain'] as $plainFile) {
             //get file info
             $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
             //relative to data/<user>/file
             $relPath = $plainFile['path'];
             //relative to /data
             $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
             // keep timestamp
             $timestamp = $fileInfo['mtime'];
             // Open plain file handle for binary reading
             $plainHandle = $this->view->fopen($rawPath, 'rb');
             // Open enc file handle for binary writing, with same filename as original plain file
             $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
             if (is_resource($encHandle)) {
                 // Move plain file to a temporary location
                 $size = stream_copy_to_stream($plainHandle, $encHandle);
                 fclose($encHandle);
                 fclose($plainHandle);
                 $fakeRoot = $this->view->getRoot();
                 $this->view->chroot('/' . $this->userId . '/files');
                 $this->view->rename($relPath . '.part', $relPath);
                 // set timestamp
                 $this->view->touch($relPath, $timestamp);
                 $encSize = $this->view->filesize($relPath);
                 $this->view->chroot($fakeRoot);
                 // Add the file to the cache
                 \OC\Files\Filesystem::putFileInfo($relPath, array('encrypted' => true, 'size' => $encSize, 'unencrypted_size' => $size, 'etag' => $fileInfo['etag']));
                 $encryptedFiles[] = $relPath;
             }
         }
         // Encrypt legacy encrypted files
         if (!empty($legacyPassphrase) && !empty($newPassphrase)) {
             foreach ($found['legacy'] as $legacyFile) {
                 // Fetch data from file
                 $legacyData = $this->view->file_get_contents($legacyFile['path']);
                 // decrypt data, generate catfile
                 $decrypted = Crypt::legacyBlockDecrypt($legacyData, $legacyPassphrase);
                 $rawPath = $legacyFile['path'];
                 // enable proxy the ensure encryption is handled
                 \OC_FileProxy::$enabled = true;
                 // Open enc file handle for binary writing, with same filename as original plain file
                 $encHandle = $this->view->fopen($rawPath, 'wb');
                 if (is_resource($encHandle)) {
                     // write data to stream
                     fwrite($encHandle, $decrypted);
                     // close stream
                     fclose($encHandle);
                 }
                 // disable proxy to prevent file being encrypted twice
                 \OC_FileProxy::$enabled = false;
             }
         }
         \OC_FileProxy::$enabled = true;
         if ($versionStatus) {
             \OC_App::enable('files_versions');
         }
         $this->encryptVersions($encryptedFiles);
         // If files were found, return true
         return true;
     } else {
         // If no files were found, return false
         return false;
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:82,代码来源:util.php


注:本文中的OC\Files\Filesystem::putFileInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。