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


PHP Filesystem::rename方法代码示例

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


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

示例1: put

 /**
  * Updates the data
  *
  * The data argument is a readable stream resource.
  *
  * After a succesful put operation, you may choose to return an ETag. The
  * etag must always be surrounded by double-quotes. These quotes must
  * appear in the actual string you're returning.
  *
  * Clients may use the ETag from a PUT request to later on make sure that
  * when they update the file, the contents haven't changed in the mean
  * time.
  *
  * If you don't plan to store the file byte-by-byte, and you return a
  * different object on a subsequent GET you are strongly recommended to not
  * return an ETag, and just return null.
  *
  * @param resource $data
  * @throws Sabre_DAV_Exception_Forbidden
  * @return string|null
  */
 public function put($data)
 {
     if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
         throw new \Sabre_DAV_Exception_Forbidden();
     }
     // mark file as partial while uploading (ignored by the scanner)
     $partpath = $this->path . '.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, $this->path);
     //allow sync clients to send the mtime along in a header
     $mtime = OC_Request::hasModificationTime();
     if ($mtime !== false) {
         if (\OC\Files\Filesystem::touch($this->path, $mtime)) {
             header('X-OC-MTime: accepted');
         }
     }
     return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:51,代码来源:file.php

示例2: testUnLockAsRecipient

 public function testUnLockAsRecipient()
 {
     $this->loginAsUser($this->ownerUid);
     Filesystem::initMountPoints($this->recipientUid);
     $recipientView = new View('/' . $this->recipientUid . '/files');
     $recipientView->lockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
     $recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
     $this->assertTrue(Filesystem::rename('/foo', '/asd'));
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:9,代码来源:locking.php

示例3: setName

 /**
  * @brief Renames the node
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
     list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
     $newPath = $parentPath . '/' . $newName;
     $oldPath = $this->path;
     \OC\Files\Filesystem::rename($this->path, $newPath);
     $this->path = $newPath;
     $query = OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' . ' WHERE `userid` = ? AND `propertypath` = ?');
     $query->execute(array($newPath, OC_User::getUser(), $oldPath));
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:16,代码来源:node.php

示例4: 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

示例5: 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

示例6: 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

示例7: isset

<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
\OC::$server->getSession()->close();
// Get data
$dir = isset($_POST['dir']) ? (string) $_POST['dir'] : '';
$file = isset($_POST['file']) ? (string) $_POST['file'] : '';
$target = isset($_POST['target']) ? rawurldecode((string) $_POST['target']) : '';
$l = \OC::$server->getL10N('files');
if (\OC\Files\Filesystem::file_exists($target . '/' . $file)) {
    OCP\JSON::error(array("data" => array("message" => $l->t("Could not move %s - File with this name already exists", array($file)))));
    exit;
}
if ($target != '' || strtolower($file) != 'shared') {
    $targetFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file);
    $sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
    try {
        if (\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
            OCP\JSON::success(array("data" => array("dir" => $dir, "files" => $file)));
        } else {
            OCP\JSON::error(array("data" => array("message" => $l->t("Could not move %s", array($file)))));
        }
    } catch (\OCP\Files\NotPermittedException $e) {
        OCP\JSON::error(array("data" => array("message" => $l->t("Permission denied"))));
    } catch (\Exception $e) {
        OCP\JSON::error(array("data" => array("message" => $e->getMessage())));
    }
} else {
    OCP\JSON::error(array("data" => array("message" => $l->t("Could not move %s", array($file)))));
}
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:31,代码来源:move.php

示例8: testRenameWithMountPoints

 public function testRenameWithMountPoints()
 {
     $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('');
     $fooCachedData = $cache2->get('foo.txt');
     Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
     $this->assertFalse($cache2->inCache('foo.txt'));
     $this->assertTrue($cache2->inCache('bar.txt'));
     $cachedData = $cache2->get('bar.txt');
     $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
     $mtime = $cachedData['mtime'];
     $cachedData = $cache2->get('');
     $this->assertInternalType('string', $substorageCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
     // rename can cause mtime change - invalid assert
     //		$this->assertEquals($mtime, $cachedData['mtime']);
     $cachedData = $view->getFileInfo('folder');
     $this->assertInternalType('string', $folderCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
     // rename can cause mtime change - invalid assert
     //		$this->assertEquals($mtime, $cachedData['mtime']);
 }
开发者ID:kebenxiaoming,项目名称:core,代码行数:30,代码来源:updaterlegacy.php

示例9: testPermissionMovedGroupShare

 /**
  * moved mountpoints of a group share should keep the same permission as their parent group share.
  * See #15253
  *
  * @dataProvider dataPermissionMovedGroupShare
  */
 function testPermissionMovedGroupShare($type, $beforePerm, $afterPerm)
 {
     if ($type === 'file') {
         $path = $this->filename;
     } else {
         if ($type === 'folder') {
             $path = $this->folder;
         }
     }
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     // Share item with group
     $share = $this->share(\OCP\Share::SHARE_TYPE_GROUP, $path, self::TEST_FILES_SHARING_API_USER1, 'testGroup', $beforePerm);
     // Login as user 2 and verify the item exists
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($path));
     $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
     $this->assertEquals($beforePerm, $result->getPermissions());
     // Now move the item forcing a new entry in the share table
     \OC\Files\Filesystem::rename($path, "newPath");
     $this->assertTrue(\OC\Files\Filesystem::file_exists('newPath'));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($path));
     // change permissions
     $share->setPermissions($afterPerm);
     $this->shareManager->updateShare($share);
     // Login as user 3 and verify that the permissions are changed
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER3);
     $this->assertNotEmpty($result);
     $this->assertEquals($afterPerm, $result->getPermissions());
     // Login as user 2 and verify that the permissions are changed
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
     $this->assertNotEmpty($result);
     $this->assertEquals($afterPerm, $result->getPermissions());
     $this->assertEquals('/newPath', $result->getTarget());
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->shareManager->deleteShare($share);
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:51,代码来源:sharedmount.php

示例10: testPermissionMovedGroupShare

 /**
  * moved mountpoints of a group share should keep the same permission as their parent group share.
  * See #15253
  *
  * @dataProvider dataPermissionMovedGroupShare
  */
 function testPermissionMovedGroupShare($type, $beforePerm, $afterPerm)
 {
     if ($type === 'file') {
         $path = $this->filename;
     } else {
         if ($type === 'folder') {
             $path = $this->folder;
         }
     }
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     // Share item with group
     $fileinfo = $this->view->getFileInfo($path);
     $this->assertTrue(\OCP\Share::shareItem($type, $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, "testGroup", $beforePerm));
     // Login as user 2 and verify the item exists
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($path));
     $result = \OCP\Share::getItemSharedWithBySource($type, $fileinfo['fileid']);
     $this->assertNotEmpty($result);
     $this->assertEquals($beforePerm, $result['permissions']);
     // Now move the item forcing a new entry in the share table
     \OC\Files\Filesystem::rename($path, "newPath");
     $this->assertTrue(\OC\Files\Filesystem::file_exists('newPath'));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($path));
     // Login as user 1 again and change permissions
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->assertTrue(\OCP\Share::setPermissions($type, $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, "testGroup", $afterPerm));
     // Login as user 3 and verify that the permissions are changed
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $result = \OCP\Share::getItemSharedWithBySource($type, $fileinfo['fileid']);
     $this->assertNotEmpty($result);
     $this->assertEquals($afterPerm, $result['permissions']);
     $groupShareId = $result['id'];
     // Login as user 2 and verify that the permissions are changed
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OCP\Share::getItemSharedWithBySource($type, $fileinfo['fileid']);
     $this->assertNotEmpty($result);
     $this->assertEquals($afterPerm, $result['permissions']);
     $this->assertNotEquals($groupShareId, $result['id']);
     // Also verify in the DB
     $statement = "SELECT `permissions` FROM `*PREFIX*share` WHERE `id`=?";
     $query = \OCP\DB::prepare($statement);
     $result = $query->execute([$result['id']]);
     $shares = $result->fetchAll();
     $this->assertCount(1, $shares);
     $this->assertEquals($afterPerm, $shares[0]['permissions']);
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::unshare($type, $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
 }
开发者ID:sunblade,项目名称:core,代码行数:61,代码来源:sharedmount.php

示例11: getListing


//.........这里部分代码省略.........
                     $group = "";
                     if (substr($name, 0, 1) == "[") {
                         $end = strpos($name, ']');
                         $group = substr($name, 1, $end - 1);
                         $name = substr($name, $end + 1, strlen($name) - $end + 1);
                         $name = trim($name);
                     }
                     // Set array for later checking
                     $filearr[] = $tmpfile;
                     // Check to see if the file is in the DB
                     $fileindb = false;
                     if ($results) {
                         foreach ($results as $result) {
                             if ($result['deleted'] == 0) {
                                 if ($name == $result['name'] && $group == $result['grouping']) {
                                     $fileindb = true;
                                     // If it is in the DB, check if the filesystem file is newer than the DB
                                     if ($result['mtime'] < $info['mtime']) {
                                         // File is newer, this could happen if a user updates a file
                                         $html = "";
                                         $html = \OC\Files\Filesystem::file_get_contents($FOLDER . "/" . $tmpfile);
                                         $this->saveNote('', $result['name'], $result['grouping'], $html, $info['mtime']);
                                         $requery = true;
                                     }
                                 }
                             }
                         }
                     }
                     if (!$fileindb) {
                         // If it's not in the DB, add it.
                         $html = "";
                         if ($html = \OC\Files\Filesystem::file_get_contents($FOLDER . "/" . $tmpfile)) {
                         } else {
                             $html = "";
                         }
                         $this->saveNote('', $name, $group, $html, $info['mtime']);
                         $requery = true;
                     }
                     // We moved the rename down here to overcome the OC issue
                     if ($this->endsWith($tmpfile, ".html")) {
                         $tmpfile = substr($tmpfile, 0, -1);
                         if (!\OC\Files\Filesystem::file_exists($FOLDER . "/" . $tmpfile)) {
                             \OC\Files\Filesystem::rename($FOLDER . "/" . $file, $FOLDER . "/" . $tmpfile);
                         }
                     }
                 }
             }
         }
         if ($requery) {
             $query = \OCP\DB::prepare("SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name");
             $results = $query->execute(array($uid))->fetchAll();
         }
         // Now also make sure the files exist, they may not if the user switched folders in admin.
         if ($results) {
             foreach ($results as $result) {
                 if ($result['deleted'] == 0) {
                     $tmpfile = $result['name'] . ".htm";
                     if ($result['grouping'] != '') {
                         $tmpfile = '[' . $result['grouping'] . '] ' . $result['name'] . '.htm';
                     }
                     $filefound = false;
                     foreach ($filearr as $f) {
                         if ($f == $tmpfile) {
                             $filefound = true;
                             break;
                         }
                     }
                     if (!$filefound) {
                         $content = $this->editNote($result['name'], $result['grouping']);
                         $this->saveNote($FOLDER, $result['name'], $result['grouping'], $content, 0);
                     }
                 }
             }
         }
     }
     // Now loop through and return the listing
     if ($results) {
         $count = 0;
         $now = new DateTime();
         $filetime = new DateTime();
         $l = \OCP\Util::getL10N('ownnote');
         foreach ($results as $result) {
             if ($result['deleted'] == 0 || $showdel == true) {
                 $filetime->setTimestamp($result['mtime']);
                 $timestring = $this->getTimeString($filetime, $now, $l);
                 $f = array();
                 $f['id'] = $result['id'];
                 $f['name'] = $result['name'];
                 $f['group'] = $result['grouping'];
                 $f['timestring'] = $timestring;
                 $f['mtime'] = $result['mtime'];
                 $f['timediff'] = $now->getTimestamp() - $result['mtime'];
                 $f['deleted'] = $result['deleted'];
                 $farray[$count] = $f;
                 $count++;
             }
         }
     }
     return $farray;
 }
开发者ID:tumstech,项目名称:ownnote,代码行数:101,代码来源:backend.php

示例12: testRename

 /**
  * if a folder gets renamed all children mount points should be renamed too
  */
 function testRename()
 {
     $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);
     // make sure that the shared folder exists
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
     \OC\Files\Filesystem::mkdir('oldTarget');
     \OC\Files\Filesystem::mkdir('oldTarget/subfolder');
     \OC\Files\Filesystem::mkdir('newTarget');
     \OC\Files\Filesystem::rename($this->folder, 'oldTarget/subfolder/' . $this->folder);
     // re-login to make sure that the new mount points are initialized
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::rename('/oldTarget', '/newTarget/oldTarget');
     // re-login to make sure that the new mount points are initialized
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists('/newTarget/oldTarget/subfolder/' . $this->folder));
     // cleanup
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $result = \OCP\Share::unshare('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue($result);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:26,代码来源:updater.php

示例13: testGroupingOfShares

 /**
  * if a file was shared as group share and as individual share they should be grouped
  */
 function testGroupingOfShares()
 {
     $fileinfo = $this->view->getFileInfo($this->filename);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Files_Sharing::TEST_FILES_SHARING_API_GROUP1, \OCP\PERMISSION_READ);
     $this->assertTrue($result);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_UPDATE);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OCP\Share::getItemSharedWith('file', null);
     $this->assertTrue(is_array($result));
     // test should return exactly one shares created from testCreateShare()
     $this->assertSame(1, count($result));
     $share = reset($result);
     $this->assertSame(\OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE, $share['permissions']);
     \OC\Files\Filesystem::rename($this->filename, $this->filename . '-renamed');
     $result = \OCP\Share::getItemSharedWith('file', null);
     $this->assertTrue(is_array($result));
     // test should return exactly one shares created from testCreateShare()
     $this->assertSame(1, count($result));
     $share = reset($result);
     $this->assertSame(\OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE, $share['permissions']);
     $this->assertSame($this->filename . '-renamed', $share['file_target']);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // unshare user share
     $result = \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OCP\Share::getItemSharedWith('file', null);
     $this->assertTrue(is_array($result));
     // test should return the remaining group share
     $this->assertSame(1, count($result));
     $share = reset($result);
     // only the group share permissions should be available now
     $this->assertSame(\OCP\PERMISSION_READ, $share['permissions']);
     $this->assertSame($this->filename . '-renamed', $share['file_target']);
 }
开发者ID:Romua1d,项目名称:core,代码行数:39,代码来源:share.php

示例14: testReshareRecipientRenameInReShare

 public function testReshareRecipientRenameInReShare()
 {
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER4);
     Filesystem::rename('/sub1/sub2/inside/file.txt', '/sub1/sub2/inside/renamed.txt');
     $this->assertEtagsForFoldersChanged([self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER4]);
     $this->assertAllUnchanged();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:7,代码来源:EtagPropagationTest.php

示例15: testMoveFolder

 /**
  * test if additional share keys are added if we move a folder to a shared parent
  * @medium
  */
 function testMoveFolder()
 {
     $view = new \OC\Files\View('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
     $filename = '/tmp-' . uniqid();
     $folder = '/folder' . uniqid();
     \OC\Files\Filesystem::mkdir($folder);
     // Save long data as encrypted file using stream wrapper
     $cryptedFile = \OC\Files\Filesystem::file_put_contents($folder . $filename, $this->dataShort);
     // Test that data was successfully written
     $this->assertTrue(is_int($cryptedFile));
     // Get file decrypted contents
     $decrypt = \OC\Files\Filesystem::file_get_contents($folder . $filename);
     $this->assertEquals($this->dataShort, $decrypt);
     $newFolder = '/newfolder/subfolder' . uniqid();
     \OC\Files\Filesystem::mkdir('/newfolder');
     // get the file info from previous created file
     $fileInfo = \OC\Files\Filesystem::getFileInfo('/newfolder');
     $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
     // share the folder
     \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
     \OC\Files\Filesystem::rename($folder, $newFolder);
     // Get file decrypted contents
     $newDecrypt = \OC\Files\Filesystem::file_get_contents($newFolder . $filename);
     $this->assertEquals($this->dataShort, $newDecrypt);
     // check if additional share key for user2 exists
     $this->assertTrue($view->file_exists('files_encryption/share-keys' . $newFolder . '/' . $filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     // tear down
     \OC\Files\Filesystem::unlink($newFolder);
     \OC\Files\Filesystem::unlink('/newfolder');
 }
开发者ID:Combustible,项目名称:core,代码行数:34,代码来源:share.php


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