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


PHP View::getDirectoryContent方法代码示例

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


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

示例1: decryptUsersFiles

 /**
  * encrypt files from the given user
  *
  * @param string $uid
  * @param ProgressBar $progress
  * @param string $userCount
  */
 protected function decryptUsersFiles($uid, ProgressBar $progress, $userCount)
 {
     $this->setupUserFS($uid);
     $directories = array();
     $directories[] = '/' . $uid . '/files';
     while ($root = array_pop($directories)) {
         $content = $this->rootView->getDirectoryContent($root);
         foreach ($content as $file) {
             $path = $root . '/' . $file['name'];
             if ($this->rootView->is_dir($path)) {
                 $directories[] = $path;
                 continue;
             } else {
                 try {
                     $progress->setMessage("decrypt files for user {$userCount}: {$path}");
                     $progress->advance();
                     if ($this->decryptFile($path) === false) {
                         $progress->setMessage("decrypt files for user {$userCount}: {$path} (already decrypted)");
                         $progress->advance();
                     }
                 } catch (\Exception $e) {
                     if (isset($this->failed[$uid])) {
                         $this->failed[$uid][] = $path;
                     } else {
                         $this->failed[$uid] = [$path];
                     }
                 }
             }
         }
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:38,代码来源:decryptall.php

示例2: testRestoreFile

	/**
	 * @medium
	 * test restore file
	 */
	function testRestoreFile() {
		// generate filename
		$filename = 'tmp-' . $this->getUniqueID() . '.txt';
		$filename2 = $filename . '.backup'; // a second file with similar name

		// save file with content
		$cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename, $this->dataShort);
		$cryptedFile2 = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename2, $this->dataShort);

		// delete both files
		\OC\Files\Filesystem::unlink($filename);
		\OC\Files\Filesystem::unlink($filename2);

		$trashFiles = $this->view->getDirectoryContent('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/');

		$trashFileSuffix = null;
		$trashFileSuffix2 = null;
		// find created file with timestamp
		foreach ($trashFiles as $file) {
			if (strpos($file['path'], $filename . '.d') !== false) {
				$path_parts = pathinfo($file['name']);
				$trashFileSuffix = $path_parts['extension'];
			}
		}

		// prepare file information
		$timestamp = str_replace('d', '', $trashFileSuffix);

		// restore first file
		$this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename . '.' . $trashFileSuffix, $filename, $timestamp));

		// check if file exists
		$this->assertTrue($this->view->file_exists(
			'/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));

		// check if key for admin exists
		$this->assertTrue($this->view->file_exists(
			'/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/'
			. $filename . '.key'));

		// check if share key for admin exists
		$this->assertTrue($this->view->file_exists(
			'/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
			. $filename . '.' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));

		// check that second file was NOT restored
		$this->assertFalse($this->view->file_exists(
			'/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2));

		// check if key for admin exists
		$this->assertFalse($this->view->file_exists(
			'/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/'
			. $filename2 . '.key'));

		// check if share key for admin exists
		$this->assertFalse($this->view->file_exists(
			'/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
			. $filename2 . '.' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:63,代码来源:trashbin.php

示例3: run

 public function run()
 {
     $view = new View('/');
     $children = $view->getDirectoryContent('/');
     foreach ($children as $child) {
         if ($view->is_dir($child->getPath())) {
             $thumbnailsFolder = $child->getPath() . '/thumbnails';
             if ($view->is_dir($thumbnailsFolder)) {
                 $view->rmdir($thumbnailsFolder);
             }
         }
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:13,代码来源:preview.php

示例4: recoverAllFiles

 /**
  * recover users files
  *
  * @param string $path
  * @param string $privateKey
  * @param string $uid
  */
 private function recoverAllFiles($path, $privateKey, $uid)
 {
     $dirContent = $this->view->getDirectoryContent($path);
     foreach ($dirContent as $item) {
         // Get relative path from encryption/keyfiles
         $filePath = $item->getPath();
         if ($this->view->is_dir($filePath)) {
             $this->recoverAllFiles($filePath . '/', $privateKey, $uid);
         } else {
             $this->recoverFile($filePath, $privateKey, $uid);
         }
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:20,代码来源:Recovery.php

示例5: recoverAllFiles

 /**
  * collect all files and recover them one by one
  * @param string $path to look for files keys
  * @param string $privateKey private recovery key which is used to decrypt the files
  */
 private function recoverAllFiles($path, $privateKey)
 {
     $dirContent = $this->view->getDirectoryContent($this->keysPath . '/' . $path);
     foreach ($dirContent as $item) {
         // get relative path from files_encryption/keyfiles
         $filePath = substr($item['path'], strlen('files_encryption/keys'));
         if ($this->view->is_dir($this->userFilesDir . '/' . $filePath)) {
             $this->recoverAllFiles($filePath . '/', $privateKey);
         } else {
             $this->recoverFile($filePath, $privateKey);
         }
     }
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:18,代码来源:util.php

示例6: getBackupPath

 function getBackupPath($extension)
 {
     $encPath = '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '/files_encryption';
     $encFolderContent = $this->view->getDirectoryContent($encPath);
     $backupPath = '';
     foreach ($encFolderContent as $c) {
         $name = $c['name'];
         if (substr($name, 0, strlen('backup.' . $extension)) === 'backup.' . $extension) {
             $backupPath = $encPath . '/' . $c['name'];
             break;
         }
     }
     return $backupPath;
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:14,代码来源:util.php

示例7: getChildInfo

/**
 * @param \OCP\Files\FileInfo $dir
 * @param \OC\Files\View $view
 * @return array
 */
function getChildInfo($dir, $view)
{
    $children = $view->getDirectoryContent($dir->getPath());
    $result = array();
    foreach ($children as $child) {
        $formated = \OCA\Files\Helper::formatFileInfo($child);
        if ($child->getType() === 'dir') {
            $formated['children'] = getChildInfo($child, $view);
        }
        $formated['mtime'] = $formated['mtime'] / 1000;
        $result[] = $formated;
    }
    return $result;
}
开发者ID:samj1912,项目名称:repo,代码行数:19,代码来源:shareinfo.php

示例8: testGetDirectoryPermissions

 /**
  * Test that the permissions of shared directory are returned correctly
  */
 function testGetDirectoryPermissions()
 {
     $contents = $this->secondView->getDirectoryContent('files/shareddir');
     $this->assertEquals('subdir', $contents[0]['name']);
     $this->assertEquals(31, $contents[0]['permissions']);
     $this->assertEquals('textfile.txt', $contents[1]['name']);
     // 27 is correct because create is reserved to folders only - requires more unit tests overall to ensure this
     $this->assertEquals(27, $contents[1]['permissions']);
     $contents = $this->secondView->getDirectoryContent('files/shareddirrestricted');
     $this->assertEquals('subdir', $contents[0]['name']);
     $this->assertEquals(7, $contents[0]['permissions']);
     $this->assertEquals('textfile1.txt', $contents[1]['name']);
     // 3 is correct because create is reserved to folders only
     $this->assertEquals(3, $contents[1]['permissions']);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:18,代码来源:permissions.php

示例9: getAllFiles

 /**
  * go recursively through a dir and collect all files and sub files.
  *
  * @param string $dir relative to the users files folder
  * @return array with list of files relative to the users files folder
  */
 public function getAllFiles($dir)
 {
     $result = array();
     $dirList = array($dir);
     while ($dirList) {
         $dir = array_pop($dirList);
         $content = $this->rootView->getDirectoryContent($dir);
         foreach ($content as $c) {
             if ($c->getType() === 'dir') {
                 $dirList[] = $c->getPath();
             } else {
                 $result[] = $c->getPath();
             }
         }
     }
     return $result;
 }
开发者ID:loulancn,项目名称:core,代码行数:23,代码来源:util.php

示例10: testSingleStorageDeleteFail

 /**
  * Delete should fail is the source file cant be deleted
  */
 public function testSingleStorageDeleteFail()
 {
     /**
      * @var \OC\Files\Storage\Temporary | \PHPUnit_Framework_MockObject_MockObject $storage
      */
     $storage = $this->getMockBuilder('\\OC\\Files\\Storage\\Temporary')->setConstructorArgs([[]])->setMethods(['rename', 'unlink'])->getMock();
     $storage->expects($this->any())->method('rename')->will($this->returnValue(false));
     $storage->expects($this->any())->method('unlink')->will($this->returnValue(false));
     $cache = $storage->getCache();
     Filesystem::mount($storage, [], '/' . $this->user . '/files');
     $this->userView->file_put_contents('test.txt', 'foo');
     $this->assertTrue($storage->file_exists('test.txt'));
     $this->assertFalse($this->userView->unlink('test.txt'));
     $this->assertTrue($storage->file_exists('test.txt'));
     $this->assertTrue($cache->inCache('test.txt'));
     // file should not be in the trashbin
     $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
     $this->assertEquals(0, count($results));
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:22,代码来源:storage.php

示例11: getAllFiles

 /**
  * go recursively through a dir and collect all files and sub files.
  *
  * @param string $dir relative to the users files folder
  * @param string $mountPoint
  * @return array with list of files relative to the users files folder
  */
 public function getAllFiles($dir, $mountPoint = '')
 {
     $result = array();
     $dirList = array($dir);
     while ($dirList) {
         $dir = array_pop($dirList);
         $content = $this->view->getDirectoryContent($dir);
         foreach ($content as $c) {
             // getDirectoryContent() returns the paths relative to the mount points, so we need
             // to re-construct the complete path
             $path = $mountPoint !== '' ? $mountPoint . '/' . $c->getPath() : $c->getPath();
             if ($c['type'] === 'dir') {
                 $dirList[] = \OC\Files\Filesystem::normalizePath($path);
             } else {
                 $result[] = \OC\Files\Filesystem::normalizePath($path);
             }
         }
     }
     return $result;
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:27,代码来源:util.php

示例12: testDeleteFile

 /**
  * @medium
  * test delete file
  */
 function testDeleteFile()
 {
     // generate filename
     $filename = 'tmp-' . uniqid() . '.txt';
     // save file with content
     $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename, $this->dataShort);
     // test that data was successfully written
     $this->assertTrue(is_int($cryptedFile));
     // check if key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename . '.key'));
     // check if share key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
     // delete file
     \OC\FIles\Filesystem::unlink($filename);
     // check if file not exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
     // check if key for admin not exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename . '.key'));
     // check if share key for admin not exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
     // get files
     $trashFiles = $this->view->getDirectoryContent('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/');
     $trashFileSuffix = null;
     // find created file with timestamp
     foreach ($trashFiles as $file) {
         if (strncmp($file['path'], $filename, strlen($filename))) {
             $path_parts = pathinfo($file['name']);
             $trashFileSuffix = $path_parts['extension'];
         }
     }
     // check if we found the file we created
     $this->assertNotNull($trashFileSuffix);
     // check if key for admin not exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix));
     // check if share key for admin not exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix));
     // return filename for next test
     return $filename . '.' . $trashFileSuffix;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:43,代码来源:trashbin.php

示例13: run

 /** {@inheritDoc} */
 public function run(IOutput $out)
 {
     $rootView = new View();
     $dataDirectory = $this->config->getSystemValue('datadirectory', null);
     if (is_null($dataDirectory)) {
         throw new \Exception('No data directory specified');
     }
     $pathToRootCerts = '/files_external/rootcerts.crt';
     foreach ($rootView->getDirectoryContent('', 'httpd/unix-directory') as $fileInfo) {
         $uid = trim($fileInfo->getPath(), '/');
         if ($rootView->file_exists($uid . $pathToRootCerts)) {
             // Delete the existing root certificate
             $rootView->unlink($uid . $pathToRootCerts);
             /**
              * FIXME: The certificate manager does only allow specifying the user
              *        within the constructor. This makes DI impossible.
              */
             // Regenerate the certificates
             $certificateManager = $this->server->getCertificateManager($uid);
             $certificateManager->createCertificateBundle();
         }
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:24,代码来源:UpdateCertificateStore.php

示例14: getDirectoryContent

 /**
  * get the content of a directory
  *
  * @param string $directory path under datadirectory
  * @return array
  */
 public static function getDirectoryContent($directory)
 {
     return self::$defaultInstance->getDirectoryContent($directory);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:10,代码来源:filesystem.php

示例15: getAllChildren

 /**
  * @param \OC\Files\View $view
  * @param string $path
  *
  * @return array
  */
 private static function getAllChildren($view, $path)
 {
     $children = $view->getDirectoryContent($path);
     $childrensFiles = array();
     $fakeRootLength = strlen($view->getRoot());
     for ($i = 0; $i < count($children); $i++) {
         $child = $children[$i];
         $childsPath = substr($child->getPath(), $fakeRootLength);
         if ($view->is_dir($childsPath)) {
             $children = array_merge($children, $view->getDirectoryContent($childsPath));
         } else {
             $childrensFiles[] = $child;
         }
     }
     return $childrensFiles;
 }
开发者ID:unrealbato,项目名称:core,代码行数:22,代码来源:preview.php


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