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


PHP OC_Filesystem::getView方法代码示例

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


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

示例1: file_assemble

 public function file_assemble($path)
 {
     $absolutePath = OC_Filesystem::normalizePath(OC_Filesystem::getView()->getAbsolutePath($path));
     $data = '';
     // use file_put_contents as method because that best matches what this function does
     if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && OC_Filesystem::isValidPath($path)) {
         $path = OC_Filesystem::getView()->getRelativePath($absolutePath);
         $exists = OC_Filesystem::file_exists($path);
         $run = true;
         if (!$exists) {
             OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array(OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
         }
         OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array(OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
         if (!$run) {
             return false;
         }
         $target = OC_Filesystem::fopen($path, 'w');
         if ($target) {
             $count = $this->assemble($target);
             fclose($target);
             if (!$exists) {
                 OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array(OC_Filesystem::signal_param_path => $path));
             }
             OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array(OC_Filesystem::signal_param_path => $path));
             OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
             return $count > 0;
         } else {
             return false;
         }
     }
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:filechunking.php

示例2: rename

 /**
  * update the filesystem after a rename has been detected
  * @param string oldPath
  * @param string newPath
  * @param string root (optional)
  */
 public static function rename($oldPath, $newPath, $root = false)
 {
     if (!OC_FileCache::inCache($oldPath, $root)) {
         return;
     }
     if ($root === false) {
         $view = OC_Filesystem::getView();
     } else {
         $view = new OC_FilesystemView($root);
     }
     $cached = OC_FileCache_Cached::get($oldPath, $root);
     $oldSize = $cached['size'];
     OC_FileCache::increaseSize(dirname($oldPath), -$oldSize, $root);
     OC_FileCache::increaseSize(dirname($newPath), $oldSize, $root);
     OC_FileCache::move($oldPath, $newPath);
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:22,代码来源:update.php

示例3: cleanFolder

 /**
  * delete non existing files from the cache
  */
 private static function cleanFolder($path, $root = '')
 {
     if (!$root) {
         $view = OC_Filesystem::getView();
     } else {
         $view = new OC_FilesystemView($root == '/' ? '' : $root);
     }
     //check for removed files, not using getFolderContent to prevent loops
     $parent = self::getFileId($view->getRoot() . $path);
     $query = OC_DB::prepare('SELECT name FROM *PREFIX*fscache WHERE parent=?');
     $result = $query->execute(array($parent));
     while ($row = $result->fetchRow()) {
         $file = $path . '/' . $row['name'];
         if (!$view->file_exists($file)) {
             if (!$root) {
                 //filesystem hooks are only valid for the default root
                 OC_Hook::emit('OC_Filesystem', 'post_delete', array('path' => $file));
             } else {
                 self::fileSystemWatcherDelete(array('path' => $file), $root);
             }
         }
     }
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:26,代码来源:filecache.php

示例4: scanFile

 /**
  * scan a single file
  * @param string path
  * @param string root (optional)
  * @return int size of the scanned file
  */
 public static function scanFile($path, $root = false)
 {
     // NOTE: Ugly hack to prevent shared files from going into the cache (the source already exists somewhere in the cache)
     if (substr($path, 0, 7) == '/Shared') {
         return;
     }
     if ($root === false) {
         $view = OC_Filesystem::getView();
     } else {
         $view = new OC_FilesystemView($root);
     }
     if (!$view->is_readable($path)) {
         return;
     }
     //cant read, nothing we can do
     clearstatcache();
     $mimetype = $view->getMimeType($path);
     $stat = $view->stat($path);
     if ($mimetype == 'httpd/unix-directory') {
         $stat['size'] = 0;
         $writable = $view->is_writable($path . '/');
     } else {
         $writable = $view->is_writable($path);
     }
     $stat['mimetype'] = $mimetype;
     $stat['writable'] = $writable;
     if ($path == '/') {
         $path = '';
     }
     self::put($path, $stat, $root);
     return $stat['size'];
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:38,代码来源:filecache.php

示例5: testHooks

 public function testHooks()
 {
     if (OC_Filesystem::getView()) {
         $user = OC_User::getUser();
     } else {
         $user = uniqid();
         OC_Filesystem::init('/' . $user . '/files');
     }
     OC_Hook::clear('OC_Filesystem');
     OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
     OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
     $rootView = new OC_FilesystemView('');
     $rootView->mkdir('/' . $user);
     $rootView->mkdir('/' . $user . '/files');
     OC_Filesystem::file_put_contents('/foo', 'foo');
     OC_Filesystem::mkdir('/bar');
     OC_Filesystem::file_put_contents('/bar//foo', 'foo');
     $tmpFile = OC_Helper::tmpFile();
     file_put_contents($tmpFile, 'foo');
     $fh = fopen($tmpFile, 'r');
     OC_Filesystem::file_put_contents('/bar//foo', $fh);
 }
开发者ID:ryanshoover,项目名称:core,代码行数:22,代码来源:filesystem.php


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