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


PHP Files\Filesystem类代码示例

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


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

示例1: tearDown

 public function tearDown()
 {
     foreach ($this->storages as $storage) {
         $storage->getCache()->clear();
     }
     \OC\Files\Filesystem::clearMounts();
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:7,代码来源:integration.php

示例2: listdir

    public static function listdir($dir, $dirs_stat)
    {
        $list = \OC\Files\Filesystem::getdirectorycontent($dir);
        if (sizeof($list) > 0) {
            $ret = '';
            //$d=explode('/',$dir);
            foreach ($list as $i) {
                if ($i['type'] == 'dir' && $i['name'] != '.') {
                    if (!isset($i['directory'])) {
                        $i['directory'] = '';
                    }
                    $ret .= '<li class="ui-droppable">
					 	<a href="./?app=files&dir=' . $i['directory'] . '/' . $i['name'] . '" data-pathname="' . $i['directory'] . '/' . $i['name'] . '">' . $i['name'] . '</a>' . listdir($dir . '/' . $i['name'], $dirs_stat) . '
						</li>
					';
                }
            }
            if ($ret != '') {
                $class = 'class="collapsed"';
                if ($dir == '' || isset($dirs_stat[$dir]) && $dirs_stat[$dir] == 'expanded') {
                    $class = 'class="expanded"';
                }
                $ret = '<ul ' . $class . ' data-path="' . $dir . '"><li></li>' . $ret . '</ul>';
            }
            return $ret;
        }
    }
开发者ID:ukitiyan,项目名称:files_tree,代码行数:27,代码来源:tree.php

示例3: getFiles

 public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '')
 {
     $contents = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter);
     if (isset($_SESSION['targetType']) && $_SESSION['targetType'] == TargetType::PROJECT) {
         /** @var FileInfo[] $subContents */
         $subContents = [];
         foreach ($contents as $content) {
             /** @var FileInfo $content */
             if ($content && $content->getMimetype() === 'httpd/unix-directory') {
                 $subDir = $dir . "/" . $content->getName();
                 $subContents = array_merge($subContents, \OC\Files\Filesystem::getDirectoryContent($subDir, $mimetypeFilter));
             }
         }
     }
     if (isset($subContents) && count($subContents) != 0) {
         $contents = array_merge($contents, $subContents);
     }
     $excludeFolder = [];
     foreach ($contents as $content) {
         /** @var FileInfo $content */
         if ($content && $content->getMimetype() === 'httpd/unix-directory') {
             continue;
         }
         array_push($excludeFolder, $content);
     }
     return self::sortFiles($excludeFolder, $sortAttribute, $sortDescending);
 }
开发者ID:fproject,项目名称:apps,代码行数:27,代码来源:helper.php

示例4: propagateChange

 /**
  * @param string $internalPath
  * @param int $time
  * @return array[] all propagated entries
  */
 public function propagateChange($internalPath, $time)
 {
     $source = $this->storage->getSourcePath($internalPath);
     /** @var \OC\Files\Storage\Storage $storage */
     list($storage, $sourceInternalPath) = \OC\Files\Filesystem::resolvePath($source);
     return $storage->getPropagator()->propagateChange($sourceInternalPath, $time);
 }
开发者ID:kenwi,项目名称:core,代码行数:12,代码来源:sharedpropagator.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->user = $this->getUniqueID();
     $storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/');
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:7,代码来源:avatar.php

示例6: Add

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function Add()
 {
     \OCP\JSON::setContentTypeHeader('application/json');
     if (isset($_POST['FILE']) && strlen($_POST['FILE']) > 0 && Tools::CheckURL($_POST['FILE']) && isset($_POST['OPTIONS'])) {
         try {
             $Target = Tools::CleanString(substr($_POST['FILE'], strrpos($_POST['FILE'], '/') + 1));
             // If target file exists, create a new one
             if (\OC\Files\Filesystem::file_exists($this->DownloadsFolder . '/' . $Target)) {
                 $Target = time() . '_' . $Target;
             }
             // Create the target file if the downloader is Aria2
             if ($this->WhichDownloader == 0) {
                 \OC\Files\Filesystem::touch($this->DownloadsFolder . '/' . $Target);
             } else {
                 if (!\OC\Files\Filesystem::is_dir($this->DownloadsFolder)) {
                     \OC\Files\Filesystem::mkdir($this->DownloadsFolder);
                 }
             }
             // Build OPTIONS array
             $OPTIONS = array('dir' => $this->AbsoluteDownloadsFolder, 'out' => $Target, 'follow-torrent' => false);
             if (isset($_POST['OPTIONS']['FTPUser']) && strlen(trim($_POST['OPTIONS']['FTPUser'])) > 0 && isset($_POST['OPTIONS']['FTPPasswd']) && strlen(trim($_POST['OPTIONS']['FTPPasswd'])) > 0) {
                 $OPTIONS['ftp-user'] = $_POST['OPTIONS']['FTPUser'];
                 $OPTIONS['ftp-passwd'] = $_POST['OPTIONS']['FTPPasswd'];
             }
             if (isset($_POST['OPTIONS']['FTPPasv']) && strlen(trim($_POST['OPTIONS']['FTPPasv'])) > 0) {
                 $OPTIONS['ftp-pasv'] = strcmp($_POST['OPTIONS']['FTPPasv'], "true") == 0 ? true : false;
             }
             if (!$this->ProxyOnlyWithYTDL && !is_null($this->ProxyAddress) && $this->ProxyPort > 0 && $this->ProxyPort <= 65536) {
                 $OPTIONS['all-proxy'] = rtrim($this->ProxyAddress, '/') . ':' . $this->ProxyPort;
                 if (!is_null($this->ProxyUser) && !is_null($this->ProxyPasswd)) {
                     $OPTIONS['all-proxy-user'] = $this->ProxyUser;
                     $OPTIONS['all-proxy-passwd'] = $this->ProxyPasswd;
                 }
             }
             $AddURI = $this->WhichDownloader == 0 ? Aria2::AddUri(array($_POST['FILE']), array('Params' => $OPTIONS)) : CURL::AddUri($_POST['FILE'], $OPTIONS);
             if (isset($AddURI['result']) && !is_null($AddURI['result'])) {
                 $SQL = 'INSERT INTO `*PREFIX*ocdownloader_queue` (`UID`, `GID`, `FILENAME`, `PROTOCOL`, `STATUS`, `TIMESTAMP`) VALUES (?, ?, ?, ?, ?, ?)';
                 if ($this->DbType == 1) {
                     $SQL = 'INSERT INTO *PREFIX*ocdownloader_queue ("UID", "GID", "FILENAME", "PROTOCOL", "STATUS", "TIMESTAMP") VALUES (?, ?, ?, ?, ?, ?)';
                 }
                 $Query = \OCP\DB::prepare($SQL);
                 $Result = $Query->execute(array($this->CurrentUID, $AddURI['result'], $Target, strtoupper(substr($_POST['FILE'], 0, strpos($_POST['FILE'], ':'))), 1, time()));
                 sleep(1);
                 $Status = $this->WhichDownloader == 0 ? Aria2::TellStatus($AddURI['result']) : CURL::TellStatus($AddURI['result']);
                 $Progress = 0;
                 if ($Status['result']['totalLength'] > 0) {
                     $Progress = $Status['result']['completedLength'] / $Status['result']['totalLength'];
                 }
                 $ProgressString = Tools::GetProgressString($Status['result']['completedLength'], $Status['result']['totalLength'], $Progress);
                 return new JSONResponse(array('ERROR' => false, 'MESSAGE' => (string) $this->L10N->t('Download started'), 'GID' => $AddURI['result'], 'PROGRESSVAL' => round($Progress * 100, 2) . '%', 'PROGRESS' => is_null($ProgressString) ? (string) $this->L10N->t('N/A') : $ProgressString, 'STATUS' => isset($Status['result']['status']) ? (string) $this->L10N->t(ucfirst($Status['result']['status'])) : (string) $this->L10N->t('N/A'), 'STATUSID' => Tools::GetDownloadStatusID($Status['result']['status']), 'SPEED' => isset($Status['result']['downloadSpeed']) ? Tools::FormatSizeUnits($Status['result']['downloadSpeed']) . '/s' : (string) $this->L10N->t('N/A'), 'FILENAME' => strlen($Target) > 40 ? substr($Target, 0, 40) . '...' : $Target, 'PROTO' => strtoupper(substr($_POST['FILE'], 0, strpos($_POST['FILE'], ':'))), 'ISTORRENT' => false));
             } else {
                 return new JSONResponse(array('ERROR' => true, 'MESSAGE' => (string) $this->L10N->t($this->WhichDownloader == 0 ? 'Returned GID is null ! Is Aria2c running as a daemon ?' : 'An error occurred while running the CURL download')));
             }
         } catch (Exception $E) {
             return new JSONResponse(array('ERROR' => true, 'MESSAGE' => $E->getMessage()));
         }
     } else {
         return new JSONResponse(array('ERROR' => true, 'MESSAGE' => (string) $this->L10N->t('Please check the URL you\'ve just provided')));
     }
 }
开发者ID:samosito,项目名称:ocdownloader,代码行数:64,代码来源:ftpdownloader.php

示例7: initMountPointsHook

 /**
  * Hook that mounts the given user's visible mount points
  * @param array $data
  */
 public static function initMountPointsHook($data)
 {
     $mountPoints = self::getAbsoluteMountPoints($data['user']);
     foreach ($mountPoints as $mountPoint => $options) {
         \OC\Files\Filesystem::mount($options['class'], $options['options'], $mountPoint);
     }
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:11,代码来源:config.php

示例8: generateFileToken

 public function generateFileToken($fileId, $version)
 {
     // Get the FS view of the current user.
     $view = \OC\Files\Filesystem::getView();
     // Get the virtual path (if the file is shared).
     $path = $view->getPath($fileId);
     if (!$view->is_file($path) || !$view->isUpdatable($path)) {
         throw new \Exception('Invalid fileId.');
     }
     // Figure out the real owner, if not us.
     $owner = $view->getOwner($path);
     // Create a view into the owner's FS.
     $view = new \OC\Files\View('/' . $owner . '/files');
     // Find the real path.
     $path = $view->getPath($fileId);
     if (!$view->is_file($path)) {
         throw new \Exception('Invalid fileId.');
     }
     $editor = \OC::$server->getUserSession()->getUser()->getUID();
     $token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(32, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS);
     \OC::$server->getLogger()->debug('Issuing token for {editor} file {fileId}, version {version} owned by {owner}, path {path}: {token}', ['owner' => $owner, 'editor' => $editor, 'fileId' => $fileId, 'version' => $version, 'path' => $path, 'token' => $token]);
     $wopi = new \OCA\Richdocuments\Db\Wopi([$owner, $editor, $fileId, $version, $path, $token, time() + self::TOKEN_LIFETIME_SECONDS]);
     if (!$wopi->insert()) {
         throw new \Exception('Failed to add wopi token into database');
     }
     return $token;
 }
开发者ID:owncloud,项目名称:richdocuments,代码行数:27,代码来源:wopi.php

示例9: __construct

 public function __construct($imagePath, $user = null, $square = false)
 {
     if (!Filesystem::isValidPath($imagePath)) {
         return;
     }
     if (is_null($user)) {
         $this->view = Filesystem::getView();
         $this->user = \OCP\User::getUser();
     } else {
         $this->view = new View('/' . $user . '/files');
         $this->user = $user;
     }
     $this->useOriginal = (substr($imagePath, -4) === '.svg' or substr($imagePath, -5) === '.svgz');
     if ($this->useOriginal) {
         $this->path = $imagePath;
     } else {
         $galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
         if (strrpos($imagePath, '.')) {
             $extension = substr($imagePath, strrpos($imagePath, '.') + 1);
             $image = substr($imagePath, 0, strrpos($imagePath, '.'));
         } else {
             $extension = '';
             $image = $imagePath;
         }
         if ($square) {
             $extension = 'square.' . $extension;
         }
         $this->path = $galleryDir . $image . '.' . $extension;
         if (!file_exists($this->path)) {
             $this->create($imagePath, $square);
         }
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:33,代码来源:thumbnail.php

示例10: checkUpdate

 private static function checkUpdate($id)
 {
     $cacheItem = Cache::getById($id);
     if (is_null($cacheItem)) {
         return;
     }
     list($storageId, $internalPath) = $cacheItem;
     $mounts = Filesystem::getMountByStorageId($storageId);
     if (count($mounts) === 0) {
         //if the storage we need isn't mounted on default, try to find a user that has access to the storage
         $permissionsCache = new Permissions($storageId);
         $users = $permissionsCache->getUsers($id);
         if (count($users) === 0) {
             return;
         }
         Filesystem::initMountPoints($users[0]);
         $mounts = Filesystem::getMountByStorageId($storageId);
         if (count($mounts) === 0) {
             return;
         }
     }
     $storage = $mounts[0]->getStorage();
     $watcher = new Watcher($storage);
     $watcher->checkUpdate($internalPath);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:backgroundwatcher.php

示例11: setUp

 /**
  * Make sure your configuration file doesn't contain any additional providers
  */
 protected function setUp()
 {
     parent::setUp();
     $userManager = \OC::$server->getUserManager();
     $userManager->clearBackends();
     $backend = new \Test\Util\User\Dummy();
     $userManager->registerBackend($backend);
     $backend->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1);
     $this->loginAsUser(self::TEST_PREVIEW_USER1);
     $storage = new \OC\Files\Storage\Temporary([]);
     \OC\Files\Filesystem::mount($storage, [], '/' . self::TEST_PREVIEW_USER1 . '/');
     $this->rootView = new \OC\Files\View('');
     $this->rootView->mkdir('/' . self::TEST_PREVIEW_USER1);
     $this->rootView->mkdir('/' . self::TEST_PREVIEW_USER1 . '/files');
     // We simulate the max dimension set in the config
     \OC::$server->getConfig()->setSystemValue('preview_max_x', $this->configMaxWidth);
     \OC::$server->getConfig()->setSystemValue('preview_max_y', $this->configMaxHeight);
     // Used to test upscaling
     $this->maxScaleFactor = 2;
     \OC::$server->getConfig()->setSystemValue('preview_max_scale_factor', $this->maxScaleFactor);
     // We need to enable the providers we're going to use in the tests
     $providers = ['OC\\Preview\\JPEG', 'OC\\Preview\\PNG', 'OC\\Preview\\GIF', 'OC\\Preview\\TXT', 'OC\\Preview\\Postscript'];
     \OC::$server->getConfig()->setSystemValue('enabledPreviewProviders', $providers);
     // Sample is 1680x1050 JPEG
     $this->prepareSample('testimage.jpg', 1680, 1050);
     // Sample is 2400x1707 EPS
     $this->prepareSample('testimage.eps', 2400, 1707);
     // Sample is 1200x450 PNG
     $this->prepareSample('testimage-wide.png', 1200, 450);
     // Sample is 64x64 GIF
     $this->prepareSample('testimage.gif', 64, 64);
 }
开发者ID:The-Website-Nursery,项目名称:core,代码行数:35,代码来源:preview.php

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     if (!getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('objectstore tests are unreliable in some environments');
     }
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // create users
     $users = array('test');
     foreach ($users as $userName) {
         \OC_User::deleteUser($userName);
         \OC_User::createUser($userName, $userName);
     }
     // main test user
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_User::setUserId('test');
     $config = \OC::$server->getConfig()->getSystemValue('objectstore');
     $this->objectStorage = new ObjectStoreToTest($config['arguments']);
     $config['objectstore'] = $this->objectStorage;
     $this->instance = new ObjectStoreStorage($config);
 }
开发者ID:nem0xff,项目名称:core,代码行数:25,代码来源:swift.php

示例13: propagateChanges

 /**
  * propagate the registered changes to their parent folders
  *
  * @param int $time (optional) the mtime to set for the folders, if not set the current time is used
  */
 public function propagateChanges($time = null)
 {
     $changes = $this->getChanges();
     $this->changedFiles = [];
     if (!$time) {
         $time = time();
     }
     foreach ($changes as $change) {
         /**
          * @var \OC\Files\Storage\Storage $storage
          * @var string $internalPath
          */
         $absolutePath = $this->view->getAbsolutePath($change);
         $mount = $this->view->getMount($change);
         $storage = $mount->getStorage();
         $internalPath = $mount->getInternalPath($absolutePath);
         if ($storage) {
             $propagator = $storage->getPropagator();
             $propagatedEntries = $propagator->propagateChange($internalPath, $time);
             foreach ($propagatedEntries as $entry) {
                 $absolutePath = Filesystem::normalizePath($mount->getMountPoint() . '/' . $entry['path']);
                 $relativePath = $this->view->getRelativePath($absolutePath);
                 $this->emit('\\OC\\Files', 'propagate', [$relativePath, $entry]);
             }
         }
     }
 }
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:32,代码来源:changepropagator.php

示例14: search

 /**
  * Search for files and folders matching the given query
  * @param string $query
  * @return \OCP\Search\Result
  */
 function search($query)
 {
     $files = Filesystem::search($query);
     $results = array();
     // edit results
     foreach ($files as $fileData) {
         // skip versions
         if (strpos($fileData['path'], '_versions') === 0) {
             continue;
         }
         // skip top-level folder
         if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
             continue;
         }
         // create audio result
         if ($fileData['mimepart'] === 'audio') {
             $result = new \OC\Search\Result\Audio($fileData);
         } elseif ($fileData['mimepart'] === 'image') {
             $result = new \OC\Search\Result\Image($fileData);
         } elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
             $result = new \OC\Search\Result\Folder($fileData);
         } else {
             $result = new \OC\Search\Result\File($fileData);
         }
         // add to results
         $results[] = $result;
     }
     // return
     return $results;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:35,代码来源:File.php

示例15: rename

 /**
  * rename a file
  *
  * @param string $dir
  * @param string $oldname
  * @param string $newname
  * @return array
  */
 public function rename($dir, $oldname, $newname)
 {
     $result = array('success' => false, 'data' => NULL);
     $normalizedOldPath = \OC\Files\Filesystem::normalizePath($dir . '/' . $oldname);
     $normalizedNewPath = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname);
     // rename to non-existing folder is denied
     if (!$this->view->file_exists($normalizedOldPath)) {
         $result['data'] = array('message' => $this->l10n->t('%s could not be renamed as it has been deleted', array($oldname)), 'code' => 'sourcenotfound', 'oldname' => $oldname, 'newname' => $newname);
     } else {
         if (!$this->view->file_exists($dir)) {
             $result['data'] = array('message' => (string) $this->l10n->t('The target folder has been moved or deleted.', array($dir)), 'code' => 'targetnotfound');
             // rename to existing file is denied
         } else {
             if ($this->view->file_exists($normalizedNewPath)) {
                 $result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir)));
             } else {
                 if ($newname !== '.' and $this->view->rename($normalizedOldPath, $normalizedNewPath)) {
                     // successful rename
                     $meta = $this->view->getFileInfo($normalizedNewPath);
                     $meta = \OCA\Files\Helper::populateTags(array($meta));
                     $fileInfo = \OCA\Files\Helper::formatFileInfo(current($meta));
                     $fileInfo['path'] = dirname($normalizedNewPath);
                     $result['success'] = true;
                     $result['data'] = $fileInfo;
                 } else {
                     // rename failed
                     $result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname)));
                 }
             }
         }
     }
     return $result;
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:41,代码来源:app.php


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