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


PHP Filesystem::unlink方法代码示例

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


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

示例1: createFile

 /**
  * Creates a new file in the directory
  *
  * Data will either be supplied as a stream resource, or in certain cases
  * as a string. Keep in mind that you may have to support either.
  *
  * After succesful creation of the file, you may choose to return the ETag
  * of the new file here.
  *
  * The returned ETag must be surrounded by double-quotes (The quotes should
  * be part of the actual string).
  *
  * If you cannot accurately determine the ETag, you should not return it.
  * If you don't store the file exactly as-is (you're transforming it
  * somehow) you should also not return an ETag.
  *
  * This means that if a subsequent GET to this new file does not exactly
  * return the same contents of what was submitted here, you are strongly
  * recommended to omit the ETag.
  *
  * @param string $name Name of the file
  * @param resource|string $data Initial payload
  * @throws Sabre_DAV_Exception_Forbidden
  * @return null|string
  */
 public function createFile($name, $data = null)
 {
     if (!\OC\Files\Filesystem::isCreatable($this->path)) {
         throw new \Sabre_DAV_Exception_Forbidden();
     }
     if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
         $info = OC_FileChunking::decodeName($name);
         if (empty($info)) {
             throw new Sabre_DAV_Exception_NotImplemented();
         }
         $chunk_handler = new OC_FileChunking($info);
         $chunk_handler->store($info['index'], $data);
         if ($chunk_handler->isComplete()) {
             $newPath = $this->path . '/' . $info['name'];
             $chunk_handler->file_assemble($newPath);
             return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
         }
     } else {
         $newPath = $this->path . '/' . $name;
         // mark file as partial while uploading (ignored by the scanner)
         $partpath = $newPath . '.part';
         \OC\Files\Filesystem::file_put_contents($partpath, $data);
         //detect aborted upload
         if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
             if (isset($_SERVER['CONTENT_LENGTH'])) {
                 $expected = $_SERVER['CONTENT_LENGTH'];
                 $actual = \OC\Files\Filesystem::filesize($partpath);
                 if ($actual != $expected) {
                     \OC\Files\Filesystem::unlink($partpath);
                     throw new Sabre_DAV_Exception_BadRequest('expected filesize ' . $expected . ' got ' . $actual);
                 }
             }
         }
         // rename to correct path
         \OC\Files\Filesystem::rename($partpath, $newPath);
         // allow sync clients to send the mtime along in a header
         $mtime = OC_Request::hasModificationTime();
         if ($mtime !== false) {
             if (\OC\Files\Filesystem::touch($newPath, $mtime)) {
                 header('X-OC-MTime: accepted');
             }
         }
         return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
     }
     return null;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:71,代码来源:directory.php

示例2: testUnshareFromSelf

 function testUnshareFromSelf()
 {
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     $fileinfo = $this->view->getFileInfo($this->filename);
     $pathinfo = pathinfo($this->filename);
     $duplicate = '/' . $pathinfo['filename'] . ' (2).' . $pathinfo['extension'];
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup', 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($this->filename);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($duplicate);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
     \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::deleteGroup('testGroup');
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:44,代码来源:share.php

示例3: testUnshareChildren

 /**
  * @medium
  */
 function testUnshareChildren()
 {
     $fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
     $this->share(\OCP\Share::SHARE_TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // one folder should be shared with the user
     $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER);
     $this->assertCount(1, $shares);
     // move shared folder to 'localDir'
     \OC\Files\Filesystem::mkdir('localDir');
     $result = \OC\Files\Filesystem::rename($this->folder, '/localDir/' . $this->folder);
     $this->assertTrue($result);
     \OC\Files\Filesystem::unlink('localDir');
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // after the parent directory was deleted the share should be unshared
     $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER);
     $this->assertEmpty($shares);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // the folder for the owner should still exists
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:24,代码来源:unsharechildren.php

示例4: testpreUnlink

 /**
  * @medium
  */
 function testpreUnlink()
 {
     $fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
     $result = \OCP\Share::shareItem('folder', $fileInfo2->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // one folder should be shared with the user
     $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
     $this->assertSame(1, count($sharedFolders));
     // move shared folder to 'localDir'
     \OC\Files\Filesystem::mkdir('localDir');
     $result = \OC\Files\Filesystem::rename($this->folder, '/localDir/' . $this->folder);
     $this->assertTrue($result);
     \OC\Files\Filesystem::unlink('localDir');
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // after the parent directory was deleted the share should be unshared
     $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
     $this->assertTrue(empty($sharedFolders));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // the folder for the owner should still exists
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
 }
开发者ID:samj1912,项目名称:repo,代码行数:25,代码来源:proxy.php

示例5: testUnshareFromSelf

 public function testUnshareFromSelf()
 {
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     $share1 = $this->share(\OCP\Share::SHARE_TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
     $share2 = $this->share(\OCP\Share::SHARE_TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($this->filename);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // both group share and user share should be gone
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->shareManager->deleteShare($share1);
     $this->shareManager->deleteShare($share2);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:22,代码来源:ShareTest.php

示例6: viewToNodeProvider

 public function viewToNodeProvider()
 {
     return [[function () {
         Filesystem::file_put_contents('test.txt', 'asd');
     }, 'preWrite'], [function () {
         Filesystem::file_put_contents('test.txt', 'asd');
     }, 'postWrite'], [function () {
         Filesystem::file_put_contents('test.txt', 'asd');
     }, 'preCreate'], [function () {
         Filesystem::file_put_contents('test.txt', 'asd');
     }, 'postCreate'], [function () {
         Filesystem::mkdir('test.txt');
     }, 'preCreate'], [function () {
         Filesystem::mkdir('test.txt');
     }, 'postCreate'], [function () {
         Filesystem::touch('test.txt');
     }, 'preTouch'], [function () {
         Filesystem::touch('test.txt');
     }, 'postTouch'], [function () {
         Filesystem::touch('test.txt');
     }, 'preCreate'], [function () {
         Filesystem::touch('test.txt');
     }, 'postCreate'], [function () {
         Filesystem::file_put_contents('test.txt', 'asd');
         Filesystem::unlink('test.txt');
     }, 'preDelete'], [function () {
         Filesystem::file_put_contents('test.txt', 'asd');
         Filesystem::unlink('test.txt');
     }, 'postDelete'], [function () {
         Filesystem::mkdir('test.txt');
         Filesystem::rmdir('test.txt');
     }, 'preDelete'], [function () {
         Filesystem::mkdir('test.txt');
         Filesystem::rmdir('test.txt');
     }, 'postDelete']];
 }
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:36,代码来源:hookconnector.php

示例7: testCopy

 function testCopy()
 {
     \OC\Files\Filesystem::file_put_contents("test.txt", "test file");
     $t1 = time();
     // second version is two weeks older, this way we make sure that no
     // version will be expired
     $t2 = $t1 - 60 * 60 * 24 * 14;
     // create some versions
     $v1 = self::USERS_VERSIONS_ROOT . '/test.txt.v' . $t1;
     $v2 = self::USERS_VERSIONS_ROOT . '/test.txt.v' . $t2;
     $v1Copied = self::USERS_VERSIONS_ROOT . '/test2.txt.v' . $t1;
     $v2Copied = self::USERS_VERSIONS_ROOT . '/test2.txt.v' . $t2;
     $this->rootView->file_put_contents($v1, 'version1');
     $this->rootView->file_put_contents($v2, 'version2');
     // execute copy hook of versions app
     \OC\Files\Filesystem::copy("test.txt", "test2.txt");
     $this->assertTrue($this->rootView->file_exists($v1));
     $this->assertTrue($this->rootView->file_exists($v2));
     $this->assertTrue($this->rootView->file_exists($v1Copied));
     $this->assertTrue($this->rootView->file_exists($v2Copied));
     //cleanup
     \OC\Files\Filesystem::unlink('test.txt');
     \OC\Files\Filesystem::unlink('test2.txt');
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:24,代码来源:versions.php

示例8: testMkdirr

 /**
  * @dataProvider dataPaths
  */
 function testMkdirr($path, $expected)
 {
     self::setUpUsers();
     Helper::mkdirr($path, new \OC\Files\View('/' . self::TEST_ENCRYPTION_HELPER_USER1 . '/files'));
     // ignore the filename because we only check for the directories
     $dirParts = array_slice($expected, 0, -1);
     $expectedPath = implode('/', $dirParts);
     $this->assertTrue(\OC\Files\Filesystem::is_dir($expectedPath));
     // cleanup
     \OC\Files\Filesystem::unlink('/' . $expected[0]);
     self::cleanUpUsers();
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:15,代码来源:helper.php

示例9: testPermanentDeleteFile

 /**
  * @medium
  * @brief test delete file forever
  */
 function testPermanentDeleteFile()
 {
     // generate filename
     $filename = 'tmp-' . time() . '.txt';
     // save file with content
     $cryptedFile = file_put_contents('crypt:///' . $this->userId . '/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'));
     // find created file with timestamp
     $query = \OC_DB::prepare('SELECT `timestamp`,`type` FROM `*PREFIX*files_trash`' . ' WHERE `id`=?');
     $result = $query->execute(array($filename))->fetchRow();
     $this->assertTrue(is_array($result));
     // build suffix
     $trashFileSuffix = 'd' . $result['timestamp'];
     // check if key for admin 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 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));
     // get timestamp from file
     $timestamp = str_replace('d', '', $trashFileSuffix);
     // delete file forever
     $this->assertGreaterThan(0, \OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp));
     // check if key for admin not exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/' . $filename . '.' . $trashFileSuffix));
     // check if key for admin not exists
     $this->assertFalse($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->assertFalse($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));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:45,代码来源:trashbin.php

示例10: testUnshareFromSelfFile

 /**
  * if a file gets unshared from self the etag for the recipients root should change
  */
 function testUnshareFromSelfFile()
 {
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
     $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31);
     $beforeUnshareUser2 = \OC\Files\Filesystem::getFileInfo('');
     $etagBeforeUnshareUser2 = $beforeUnshareUser2->getEtag();
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $beforeUnshareUser3 = \OC\Files\Filesystem::getFileInfo('');
     $etagBeforeUnshareUser3 = $beforeUnshareUser3->getEtag();
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OC\Files\Filesystem::unlink($this->folder);
     $this->assertTrue($result);
     $afterUnshareUser2 = \OC\Files\Filesystem::getFileInfo('');
     $etagAfterUnshareUser2 = $afterUnshareUser2->getEtag();
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $afterUnshareUser3 = \OC\Files\Filesystem::getFileInfo('');
     $etagAfterUnshareUser3 = $afterUnshareUser3->getEtag();
     $this->assertTrue(is_string($etagBeforeUnshareUser2));
     $this->assertTrue(is_string($etagBeforeUnshareUser3));
     $this->assertTrue(is_string($etagAfterUnshareUser2));
     $this->assertTrue(is_string($etagAfterUnshareUser3));
     $this->assertTrue($etagBeforeUnshareUser2 !== $etagAfterUnshareUser2);
     $this->assertTrue($etagBeforeUnshareUser3 !== $etagAfterUnshareUser3);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:31,代码来源:updater.php

示例11: testShareAndUnshareFromSelf

 /**
  * user1 share file to a group and to a user2 in the same group. Then user2
  * unshares the file from self. Afterwards user1 should no longer see the
  * single user share to user2. If he re-shares the file to user2 the same target
  * then the group share should be used to group the item
  */
 public function testShareAndUnshareFromSelf()
 {
     $fileinfo = $this->view->getFileInfo($this->filename);
     // share the file to group1 (user2 is a member of this group) and explicitely to user2
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_ALL);
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     // user1 should have to shared files
     $shares = \OCP\Share::getItemsShared('file');
     $this->assertSame(2, count($shares));
     // user2 should have two files "welcome.txt" and the shared file,
     // both the group share and the single share of the same file should be
     // grouped to one file
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(2, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
     // now user2 deletes the share (= unshare from self)
     \OC\Files\Filesystem::unlink($this->filename);
     // only welcome.txt should exists
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(1, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt'));
     // login as user1...
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // ... now user1 should have only one shared file, the group share
     $shares = \OCP\Share::getItemsShared('file');
     $this->assertSame(1, count($shares));
     // user1 shares a gain the file directly to user2
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     // user2 should see again welcome.txt and the shared file
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(2, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
 }
开发者ID:evanjt,项目名称:core,代码行数:41,代码来源:share.php

示例12: testDeleteWithMountPoints

 public function testDeleteWithMountPoints()
 {
     $storage2 = new \OC\Files\Storage\Temporary(array());
     $cache2 = $storage2->getCache();
     Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
     Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
     $view = new View('/' . self::$user . '/files');
     $this->assertTrue($cache2->inCache('foo.txt'));
     $folderCachedData = $view->getFileInfo('folder');
     $substorageCachedData = $cache2->get('');
     Filesystem::unlink('folder/substorage/foo.txt');
     $this->assertFalse($cache2->inCache('foo.txt'));
     $cachedData = $cache2->get('');
     $this->assertInternalType('string', $substorageCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
     $this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
     $cachedData = $view->getFileInfo('folder');
     $this->assertInternalType('string', $folderCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
     $this->assertGreaterThanOrEqual($folderCachedData['mtime'], $cachedData['mtime']);
 }
开发者ID:kebenxiaoming,项目名称:core,代码行数:23,代码来源:updaterlegacy.php

示例13: testDeleteFile

 /**
  * @medium
  * test delete file
  */
 function testDeleteFile()
 {
     // generate filename
     $filename = 'tmp-' . uniqid() . '.txt';
     $filename2 = $filename . '.backup';
     // a second file with similar name
     // save file with content
     $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename, $this->dataShort);
     $cryptedFile2 = file_put_contents('crypt:///' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2, $this->dataShort);
     // test that data was successfully written
     $this->assertTrue(is_int($cryptedFile));
     $this->assertTrue(is_int($cryptedFile2));
     // check if key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename . '.key'));
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename2 . '.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'));
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $filename2 . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
     // delete first 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'));
     // check that second file still exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2));
     // check that key for second file still exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename2 . '.key'));
     // check that share key for second file still exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $filename2 . '.' . \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));
 }
开发者ID:Romua1d,项目名称:core,代码行数:53,代码来源:trashbin.php

示例14: get_job_info

<?php

/*
 * delete_results
 * Created on: Jan 30, 2013 12:30:40 PM
 * 
 * Copyright 2013 EnginSoft S.p.A.
 * All rights reserved
 */
include_once 'neurocloud/lib/common.php';
$study = $_POST["study"];
$jobid = $_POST["jobid"];
$path = "{$study}/results/{$jobid}";
$jobinfo = get_job_info($study, $jobid);
$usedspace = isset($jobinfo["usedspace"]) ? $jobinfo["usedspace"] : "undefined";
insert_job_log($study, $jobid, "deleted results. Used disk space: {$usedspace}");
if (\OC\Files\Filesystem::is_dir($path)) {
    //rmdirr($path);
    \OC\Files\Filesystem::unlink($path);
    // from Owncloud 5.0.0, this will recurse on subdirs (delTree)
}
$execdir = get_job_exec_dir($jobid);
if (is_dir($execdir)) {
    rmdirr($execdir);
}
exit;
开发者ID:v-iacovella,项目名称:NeuroBox,代码行数:26,代码来源:delete_results.php

示例15: add

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function add()
 {
     \OCP\JSON::setContentTypeHeader('application/json');
     if (isset($_POST['FILE']) && strlen(trim($_POST['FILE'])) > 0 && (Tools::CheckURL($_POST['FILE']) || Tools::CheckFilepath($this->TorrentsFolder . '/' . $_POST['FILE'])) && isset($_POST['OPTIONS'])) {
         try {
             if (!$this->AllowProtocolBT && !\OC_User::isAdminUser($this->CurrentUID)) {
                 throw new \Exception((string) $this->L10N->t('You are not allowed to use the BitTorrent protocol'));
             }
             $Target = Tools::CleanString(str_replace('.torrent', '', $_POST['FILE']));
             $OPTIONS = array('dir' => rtrim($this->AbsoluteDownloadsFolder, '/') . '/' . $Target, 'seed-ratio' => $this->BTRatioToReach, 'seed-time' => $this->SeedTime);
             // If target file exists, create a new one
             if (!\OC\Files\Filesystem::is_dir(rtrim($this->DownloadsFolder, '/') . '/' . $Target)) {
                 // Create the target file
                 \OC\Files\Filesystem::mkdir(rtrim($this->DownloadsFolder, '/') . '/' . $Target);
             } else {
                 $OPTIONS['bt-hash-check-seed'] = true;
                 $OPTIONS['check-integrity'] = true;
             }
             if (!is_null($this->MaxDownloadSpeed) && $this->MaxDownloadSpeed > 0) {
                 $OPTIONS['max-download-limit'] = $this->MaxDownloadSpeed . 'K';
             }
             if (!is_null($this->BTMaxUploadSpeed) && $this->BTMaxUploadSpeed > 0) {
                 $OPTIONS['max-upload-limit'] = $this->BTMaxUploadSpeed . 'K';
             }
             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;
                 }
             }
             $AddTorrent = Aria2::AddTorrent(base64_encode(file_get_contents(rtrim($this->AbsoluteTorrentsFolder, '/') . '/' . $_POST['FILE'])), array(), array('Params' => $OPTIONS));
             if (isset($AddTorrent['result']) && !is_null($AddTorrent['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, $AddTorrent['result'], $Target, 'BitTorrent', 1, time()));
                 if (isset($_POST['OPTIONS']['BTRMTorrent']) && strcmp($_POST['OPTIONS']['BTRMTorrent'], "true") == 0) {
                     \OC\Files\Filesystem::unlink($this->TorrentsFolder . '/' . $_POST['FILE']);
                 }
                 sleep(1);
                 $Status = Aria2::TellStatus($AddTorrent['result']);
                 $Progress = $Status['result']['completedLength'] / $Status['result']['totalLength'];
                 return new JSONResponse(array('ERROR' => false, 'MESSAGE' => (string) $this->L10N->t('Download started'), 'GID' => $AddTorrent['result'], 'PROGRESSVAL' => round($Progress * 100, 2) . '%', 'PROGRESS' => Tools::GetProgressString($Status['result']['completedLength'], $Status['result']['totalLength'], $Progress) . ' - ' . $this->L10N->t('Seeders') . ': ' . $Status['result']['numSeeders'], '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' => 'BitTorrent', 'ISTORRENT' => true));
             } else {
                 return new JSONResponse(array('ERROR' => true, 'MESSAGE' => (string) $this->L10N->t('Returned GID is null ! Is Aria2c running as a daemon ?')));
             }
         } 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 or filepath you\'ve just provided')));
     }
 }
开发者ID:venjek,项目名称:ocdownloader,代码行数:60,代码来源:btdownloader.php


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