本文整理汇总了PHP中IOHelper::getRealPath方法的典型用法代码示例。如果您正苦于以下问题:PHP IOHelper::getRealPath方法的具体用法?PHP IOHelper::getRealPath怎么用?PHP IOHelper::getRealPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOHelper
的用法示例。
在下文中一共展示了IOHelper::getRealPath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRealPath
/**
* @return mixed
*/
public function getRealPath()
{
if (!$this->_realPath) {
$this->_realPath = IOHelper::getRealPath($this->path);
}
return $this->_realPath;
}
示例2: compress
/**
* @param $source
* @param $destZip
*
* @return bool 'true' if the zip was successfully created, 'false' if not.
*/
public static function compress($source, $destZip)
{
$source = IOHelper::normalizePathSeparators($source);
$destZip = IOHelper::normalizePathSeparators($destZip);
if (!IOHelper::folderExists($source) && !IOHelper::fileExists($destZip)) {
Craft::log('Tried to zip the contents of ' . $source . ' to ' . $destZip . ', but the source path does not exist.', LogLevel::Error);
return false;
}
if (IOHelper::fileExists($destZip)) {
IOHelper::deleteFile($destZip);
}
IOHelper::createFile($destZip);
craft()->config->maxPowerCaptain();
$zip = static::_getZipInstance($destZip);
return $zip->zip(IOHelper::getRealPath($source), IOHelper::getRealPath($destZip));
}
示例3: doFileUpdate
/**
* @static
*
* @param $manifestData
* @param $sourceTempFolder
* @return bool
* @return bool
*/
public static function doFileUpdate($manifestData, $sourceTempFolder)
{
try {
foreach ($manifestData as $row) {
if (static::isManifestVersionInfoLine($row)) {
continue;
}
$folder = false;
$rowData = explode(';', $row);
if (static::isManifestLineAFolder($rowData[0])) {
$folder = true;
$tempPath = static::cleanManifestFolderLine($rowData[0]);
} else {
$tempPath = $rowData[0];
}
$destFile = IOHelper::normalizePathSeparators(craft()->path->getAppPath() . $tempPath);
$sourceFile = IOHelper::getRealPath(IOHelper::normalizePathSeparators($sourceTempFolder . '/app/' . $tempPath));
switch (trim($rowData[1])) {
// update the file
case PatchManifestFileAction::Add:
if ($folder) {
Craft::log('Updating folder: ' . $destFile, LogLevel::Info, true);
$tempFolder = rtrim($destFile, '/') . StringHelper::UUID() . '/';
$tempTempFolder = rtrim($destFile, '/') . '-tmp/';
IOHelper::createFolder($tempFolder);
IOHelper::copyFolder($sourceFile, $tempFolder);
IOHelper::rename($destFile, $tempTempFolder);
IOHelper::rename($tempFolder, $destFile);
IOHelper::clearFolder($tempTempFolder);
IOHelper::deleteFolder($tempTempFolder);
} else {
Craft::log('Updating file: ' . $destFile, LogLevel::Info, true);
IOHelper::copyFile($sourceFile, $destFile);
}
break;
}
}
} catch (\Exception $e) {
Craft::log('Error updating files: ' . $e->getMessage(), LogLevel::Error);
UpdateHelper::rollBackFileChanges($manifestData);
return false;
}
return true;
}
示例4: getUnwritableFolders
/**
* Checks to see if Craft can write to a defined set of folders/files that are needed for auto-update to work.
*
* @return array|null
*/
public function getUnwritableFolders()
{
$checkPaths = array(craft()->path->getAppPath(), craft()->path->getPluginsPath());
$errorPath = null;
foreach ($checkPaths as $writablePath) {
if (!IOHelper::isWritable($writablePath)) {
$errorPath[] = IOHelper::getRealPath($writablePath);
}
}
return $errorPath;
}
示例5: getSourceFileSystemPath
/**
* Get the file system path for upload source.
*
* @param LocalAssetSourceType $sourceType The SourceType.
*
* @return string
*/
protected function getSourceFileSystemPath(LocalAssetSourceType $sourceType = null)
{
$path = is_null($sourceType) ? $this->getBasePath() : $sourceType->getBasePath();
$path = IOHelper::getRealPath($path);
return $path;
}
示例6: _getPathsForUrl
/**
* Get paths for an external file (really external, or on an external source type)
*
* @param $image
* @throws Exception
*/
private function _getPathsForUrl($image)
{
$urlParts = parse_url($image);
$pathParts = pathinfo($urlParts['path']);
$hashRemoteUrl = craft()->imager->getSetting('hashRemoteUrl');
if ($hashRemoteUrl) {
if (is_string($hashRemoteUrl) && $hashRemoteUrl == 'host') {
$parsedDirname = substr(md5($urlParts['host']), 0, 10) . $pathParts['dirname'];
} else {
$parsedDirname = md5($urlParts['host'] . $pathParts['dirname']);
}
} else {
$parsedDirname = str_replace('.', '_', $urlParts['host']) . $pathParts['dirname'];
}
$this->sourcePath = craft()->path->getRuntimePath() . 'imager/' . $parsedDirname . '/';
$this->targetPath = craft()->imager->getSetting('imagerSystemPath') . $parsedDirname . '/';
$this->targetUrl = craft()->imager->getSetting('imagerUrl') . $parsedDirname . '/';
$this->sourceFilename = $this->targetFilename = $pathParts['basename'];
// check if the temp path for remote files exists or can be created.
if (!IOHelper::getRealPath($this->sourcePath)) {
IOHelper::createFolder($this->sourcePath, craft()->config->get('defaultFolderPermissions'), true);
if (!IOHelper::getRealPath($this->sourcePath)) {
throw new Exception(Craft::t('Temp folder “{sourcePath}” does not exist and could not be created', array('sourcePath' => $this->sourcePath)));
}
}
// check if the file is already downloaded
if (!IOHelper::fileExists($this->sourcePath . $this->sourceFilename) || IOHelper::getLastTimeModified($this->sourcePath . $this->sourceFilename)->format('U') + craft()->imager->getSetting('cacheDurationRemoteFiles') < time()) {
$this->_downloadFile($this->sourcePath . $this->sourceFilename, $image);
if (!IOHelper::fileExists($this->sourcePath . $this->sourceFilename)) {
throw new Exception(Craft::t('File could not be downloaded and saved to “{sourcePath}”', array('sourcePath' => $this->sourcePath)));
}
}
}
示例7: getViewFileInternal
/**
* Looks for the template under the specified directory.
*
* @access protected
* @param string $templatePath the folder containing the views
* @param string $templateName template name (either 'exception' or 'error')
* @param integer $code HTTP status code
* @param string $type A string description of the type of error.
* @param string $srcLanguage the language that the template is in
*
* @return string template path
*/
protected function getViewFileInternal($templatePath, $templateName, $code, $type, $srcLanguage = null)
{
if (strpos($templatePath, '/framework/') !== false) {
$extension = 'php';
} else {
$extension = 'html';
// Grab the numeric template from the code unless we're looking in the "_special" directory and it's not a Twig template syntax error
if ($code && is_numeric($code) && strpos($templateName, '_special') === false && $type != 'Template Syntax Error') {
// If it's a 200 HttpException, use the error template.
if ((string) $code == '200') {
$templateName = 'error';
} else {
$templateName = (string) $code;
}
}
}
if ($templateName == 'error') {
if (!empty($code)) {
$templateFile = craft()->findLocalizedFile(IOHelper::getRealPath($templatePath . '/' . $templateName . '.' . $extension), $srcLanguage);
if (IOHelper::fileExists($templateFile)) {
return IOHelper::getRealPath($templateFile);
}
return null;
}
}
$templateFile = craft()->findLocalizedFile(IOHelper::getRealPath($templatePath . '/' . $templateName . '.' . $extension), $srcLanguage);
if (IOHelper::fileExists($templateFile)) {
$templateFile = IOHelper::getRealPath($templateFile);
}
return $templateFile;
}
示例8: run
/**
*/
public function run()
{
$this->init();
$installResult = InstallStatus::Success;
foreach ($this->_requirements as $requirement) {
if ($requirement->getResult() == RequirementResult::Failed) {
$installResult = InstallStatus::Failure;
break;
} else {
if ($requirement->getResult() == RequirementResult::Warning) {
$installResult = InstallStatus::Warning;
}
}
}
$writableFolders = $this->_getWritableFolders();
$errorFolders = null;
foreach ($writableFolders as $writableFolder) {
if (!IOHelper::isWritable($writableFolder)) {
$errorFolders[] = IOHelper::getRealPath($writableFolder);
$installResult = InstallStatus::Failure;
}
}
$this->_result = $installResult;
$this->_serverInfo = $this->_calculateServerInfo();
$this->_errorFolders = $errorFolders;
}