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


PHP Filesystem::file_exists方法代码示例

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


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

示例1: CheckFilepath

 public static function CheckFilepath($FP)
 {
     if (\OC\Files\Filesystem::file_exists($FP)) {
         return true;
     }
     return false;
 }
开发者ID:samosito,项目名称:ocdownloader,代码行数:7,代码来源:tools.php

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

示例3: validatePath

 /**
  * @NoAdminRequired
  *
  * @param string $path
  * @param string $pass
  */
 public function validatePath($path, $pass)
 {
     if (\OC\Files\Filesystem::file_exists($path)) {
         return "true";
     } else {
         return $path;
     }
 }
开发者ID:jbateman3,项目名称:KeePass-ownCloud,代码行数:14,代码来源:passwordcontroller.php

示例4: thumb

function thumb($path)
{
    $thumb_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/reader';
    if (file_exists($thumb_path . $path)) {
        return new \OC_Image($thumb_path . $path);
    }
    if (!\OC\Files\Filesystem::file_exists($path)) {
        return false;
    }
}
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:10,代码来源:thumbnail.php

示例5: removeShare

 /**
  * @brief remove all shares for a given file if the file was deleted
  *
  * @param string $path
  */
 private static function removeShare($path)
 {
     $fileSource = self::$toRemove[$path];
     if (!\OC\Files\Filesystem::file_exists($path)) {
         $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source`=?');
         try {
             \OC_DB::executeAudited($query, array($fileSource));
         } catch (\Exception $e) {
             \OCP\Util::writeLog('files_sharing', "can't remove share: " . $e->getMessage(), \OCP\Util::WARN);
         }
     }
     unset(self::$toRemove[$path]);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:18,代码来源:updater.php

示例6: savePersonal

 /**
  * @NoAdminRequired
  */
 public function savePersonal($savePath)
 {
     if (is_null($savePath)) {
         $savePath = '/';
     }
     $status = true;
     if (\OC\Files\Filesystem::file_exists($savePath) === false) {
         $status = \OC\Files\Filesystem::mkdir($savePath);
     }
     if ($status) {
         $this->appConfig->setUserValue($this->userId, 'save_path', $savePath);
         $response = array('status' => 'success', 'data' => array('message' => $this->l10n->t('Directory saved successfully.')));
     } else {
         $response = array('status' => 'error', 'data' => array('message' => $this->l10n->t('An error occurred while changing directory.')));
     }
     return $response;
 }
开发者ID:dmccubbing,项目名称:richdocuments,代码行数:20,代码来源:settingscontroller.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     $this->userBackend = new \Test\Util\User\Dummy();
     \OC::$server->getUserManager()->registerBackend($this->userBackend);
     $this->ownerUid = $this->getUniqueID('owner_');
     $this->recipientUid = $this->getUniqueID('recipient_');
     $this->userBackend->createUser($this->ownerUid, '');
     $this->userBackend->createUser($this->recipientUid, '');
     $this->loginAsUser($this->ownerUid);
     Filesystem::mkdir('/foo');
     Filesystem::file_put_contents('/foo/bar.txt', 'asd');
     $fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId();
     \OCP\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->recipientUid, 31);
     $this->loginAsUser($this->recipientUid);
     $this->assertTrue(Filesystem::file_exists('bar.txt'));
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:17,代码来源:locking.php

示例8: __construct

 public function __construct($AppName, IRequest $request, $UserId)
 {
     parent::__construct($AppName, $request);
     $this->userId = $UserId;
     $path = self::PROJECTKIT_PREFIX . DIRECTORY_SEPARATOR;
     if (isset($_GET['containerId'])) {
         $path .= self::PROJECT_PREFIX . (string) $_GET['containerId'] . DIRECTORY_SEPARATOR;
         if (isset($_GET['targetType']) && isset($_GET['targetId'])) {
             switch ($_GET['targetType']) {
                 case TargetType::TASK:
                     $path .= self::TASK_PREFIX;
                     break;
                 case TargetType::ISSUE:
                     $path .= self::ISSUE_PREFIX;
                     break;
                 default:
                     break;
             }
             $path .= (string) $_GET['targetId'] . DIRECTORY_SEPARATOR;
             $_SESSION['targetType'] = $_GET['targetType'];
         } elseif (!isset($_GET['targetType']) && !isset($_GET['targetId'])) {
             $_SESSION['targetType'] = TargetType::PROJECT;
         }
         //use session to save targetType
         $path = Filesystem::normalizePath($path);
         //Create folder for path
         if (!Filesystem::file_exists($path)) {
             try {
                 Filesystem::mkdir($path);
             } catch (\Exception $e) {
                 $result = ['success' => false, 'data' => ['message' => $e->getMessage()]];
                 \OCP\JSON::error($result);
                 exit;
             }
         }
         if (!isset($_GET['dir'])) {
             $params = array_merge($_GET, ["dir" => $path]);
             $url = $_SERVER['PHP_SELF'] . '?' . http_build_query($params);
             header('Location: ' . $url, true, 302);
             exit;
         }
     }
 }
开发者ID:fproject,项目名称:apps,代码行数:43,代码来源:pagecontroller.php

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

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

示例11: tryLoad

 /**
  * Tries to read the file $this->file, and to decode it as a KeePass 2.x
  * database, using the key $this->key. Returns true if the operation was
  * successful, or false otherwise. In case of success, the array
  * $this->entries will contain the resulting list of entries.
  *
  * @return boolean
  */
 public function tryLoad()
 {
     if ($this->loaded) {
         return $this->rawEntries != null;
     }
     $this->loaded = true;
     if (!\OC\Files\Filesystem::file_exists($this->file)) {
         KeePassPHP::raiseError("Impossible to read " . $this->file);
         return false;
     }
     KeePassPHP::printDebug("Attempting to load database from " . $this->file);
     $resReader = RessourceReader::openFile($this->file);
     if (!$resReader) {
         KeePassPHP::raiseError("Unable to open file " . $this->file);
         return false;
     }
     if (!$this->tryParse($resReader)) {
         KeePassPHP::printDebug("  ... attempt failed !");
         return false;
     }
     KeePassPHP::printDebug("  ... attempt succeeded !");
     return true;
 }
开发者ID:jbateman3,项目名称:KeePass-ownCloud,代码行数:31,代码来源:kdbximporter.php

示例12: get

 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $files ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) === 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         $get_type = GET_TYPE::ZIP_FILES;
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         $filename = $dir . '/' . $name;
     } else {
         $filename = $dir . '/' . $files;
         if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
             $get_type = GET_TYPE::ZIP_DIR;
             // downloading root ?
             if ($files === '') {
                 $name = 'download.zip';
             } else {
                 $name = $files . '.zip';
             }
         } else {
             $get_type = GET_TYPE::FILE;
             $name = $files;
         }
     }
     if ($get_type === GET_TYPE::FILE) {
         $zip = false;
         if ($xsendfile && OC_App::isEnabled('files_encryption')) {
             $xsendfile = false;
         }
     } else {
         $zip = new ZipStreamer(false);
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name, $zip);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $name);
         $tmpl->printPage();
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($only_header) {
         return;
     }
     if ($zip) {
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         if ($get_type === GET_TYPE::ZIP_FILES) {
             foreach ($files as $file) {
                 $file = $dir . '/' . $file;
                 if (\OC\Files\Filesystem::is_file($file)) {
                     $fh = \OC\Files\Filesystem::fopen($file, 'r');
                     $zip->addFileFromStream($fh, basename($file));
                     fclose($fh);
                 } elseif (\OC\Files\Filesystem::is_dir($file)) {
                     self::zipAddDir($file, $zip);
                 }
             }
         } elseif ($get_type === GET_TYPE::ZIP_DIR) {
             $file = $dir . '/' . $files;
             self::zipAddDir($file, $zip);
         }
         $zip->finalize();
         set_time_limit($executionTime);
     } else {
         if ($xsendfile) {
             $view = \OC\Files\Filesystem::getView();
             /** @var $storage \OC\Files\Storage\Storage */
             list($storage) = $view->resolvePath($filename);
             if ($storage->isLocal()) {
                 self::addSendfileHeader($filename);
             } else {
                 \OC\Files\Filesystem::readfile($filename);
             }
         } else {
             \OC\Files\Filesystem::readfile($filename);
         }
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:98,代码来源:files.php

示例13: array

$l10n = \OC::$server->getL10N('files');
$result = array('success' => false, 'data' => NULL);
try {
    \OC\Files\Filesystem::getView()->verifyPath($dir, $fileName);
} catch (\OCP\Files\InvalidPathException $ex) {
    $result['data'] = ['message' => $ex->getMessage()];
    OCP\JSON::error($result);
    return;
}
if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
    $result['data'] = array('message' => (string) $l10n->t('The target folder has been moved or deleted.'), 'code' => 'targetnotfound');
    OCP\JSON::error($result);
    exit;
}
$target = $dir . '/' . $fileName;
if (\OC\Files\Filesystem::file_exists($target)) {
    $result['data'] = array('message' => (string) $l10n->t('The name %s is already used in the folder %s. Please choose a different name.', array($fileName, $dir)));
    OCP\JSON::error($result);
    exit;
}
$success = false;
$templateManager = OC_Helper::getFileTemplateManager();
$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target);
$content = $templateManager->getTemplate($mimeType);
try {
    if ($content) {
        $success = \OC\Files\Filesystem::file_put_contents($target, $content);
    } else {
        $success = \OC\Files\Filesystem::touch($target);
    }
} catch (\Exception $e) {
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:newfile.php

示例14: testExpireOldFilesShared

 /**
  * test expiration of files older then the max storage time defined for the trash
  * in this test we delete a shared file and check if both trash bins, the one from
  * the owner of the file and the one from the user who deleted the file get expired
  * correctly
  */
 public function testExpireOldFilesShared()
 {
     $currentTime = time();
     $folder = "trashTest-" . $currentTime . '/';
     $expiredDate = $currentTime - 3 * 24 * 60 * 60;
     // create some files
     \OC\Files\Filesystem::mkdir($folder);
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-1.txt', 'file1');
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-2.txt', 'file2');
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-3.txt', 'file3');
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-4.txt', 'file4');
     //share user1-4.txt with user2
     $fileInfo = \OC\Files\Filesystem::getFileInfo($folder);
     $result = \OCP\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_TRASHBIN_USER2, 31);
     $this->assertTrue($result);
     // delete them so that they end up in the trash bin
     \OC\Files\Filesystem::unlink($folder . 'user1-1.txt');
     \OC\Files\Filesystem::unlink($folder . 'user1-2.txt');
     \OC\Files\Filesystem::unlink($folder . 'user1-3.txt');
     $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
     $this->assertSame(3, count($filesInTrash));
     // every second file will get a date in the past so that it will get expired
     $this->manipulateDeleteTime($filesInTrash, $this->trashRoot1, $expiredDate);
     // login as user2
     self::loginHelper(self::TEST_TRASHBIN_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($folder . "user1-4.txt"));
     // create some files
     \OC\Files\Filesystem::file_put_contents('user2-1.txt', 'file1');
     \OC\Files\Filesystem::file_put_contents('user2-2.txt', 'file2');
     // delete them so that they end up in the trash bin
     \OC\Files\Filesystem::unlink('user2-1.txt');
     \OC\Files\Filesystem::unlink('user2-2.txt');
     $filesInTrashUser2 = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2, 'name');
     $this->assertSame(2, count($filesInTrashUser2));
     // every second file will get a date in the past so that it will get expired
     $this->manipulateDeleteTime($filesInTrashUser2, $this->trashRoot2, $expiredDate);
     \OC\Files\Filesystem::unlink($folder . 'user1-4.txt');
     $this->runCommands();
     $filesInTrashUser2AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2);
     // user2-1.txt should have been expired
     $this->verifyArray($filesInTrashUser2AfterDelete, array('user2-2.txt', 'user1-4.txt'));
     self::loginHelper(self::TEST_TRASHBIN_USER1);
     // user1-1.txt and user1-3.txt should have been expired
     $filesInTrashUser1AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
     $this->verifyArray($filesInTrashUser1AfterDelete, array('user1-2.txt', 'user1-4.txt'));
 }
开发者ID:loulancn,项目名称:core,代码行数:52,代码来源:trashbin.php

示例15: file_assemble

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


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