本文整理汇总了PHP中Cake\Filesystem\File::pwd方法的典型用法代码示例。如果您正苦于以下问题:PHP File::pwd方法的具体用法?PHP File::pwd怎么用?PHP File::pwd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\File
的用法示例。
在下文中一共展示了File::pwd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tidyErrors
/**
* Run the html string through tidy, and return the (raw) errors. pass back a reference to the
* normalized string so that the error messages can be linked to the line that caused them.
*
* @param string $in ''
* @param string &$out ''
* @return string
*/
public function tidyErrors($in = '', &$out = '')
{
$out = preg_replace('@>\\s*<@s', ">\n<", $in);
// direct access? windows etc
if (function_exists('tidy_parse_string')) {
$tidy = tidy_parse_string($out, array(), 'UTF8');
$tidy->cleanRepair();
$errors = $tidy->errorBuffer . "\n";
return $errors;
}
// cli
$File = new File(rtrim(TMP, DS) . DS . rand() . '.html', true);
$File->write($out);
$path = $File->pwd();
$errors = $path . '.err';
$this->_exec("tidy -eq -utf8 -f {$errors} {$path}");
$File->delete();
if (!file_exists($errors)) {
return '';
}
$Error = new File($errors);
$errors = $Error->read();
$Error->delete();
return $errors;
}
示例2: testNoPartialPathBeingSetForNonExistentPath
/**
* Tests that no path is being set for passed file paths that
* do not exist.
*
* @return void
*/
public function testNoPartialPathBeingSetForNonExistentPath()
{
$TmpFile = new File('/non/existent/file');
$this->assertNull($TmpFile->pwd());
$this->assertNull($TmpFile->path);
}
示例3: _getFromUrl
/**
* Prepares install from remote URL.
*
* @return bool True on success
*/
protected function _getFromUrl()
{
try {
$http = new Client(['redirect' => 3]);
// follow up to 3 redirections
$response = $http->get($this->params['source'], [], ['headers' => ['X-Requested-With' => 'XMLHttpRequest']]);
} catch (\Exception $ex) {
$response = false;
$this->err(__d('installer', 'Could not download the package. Details: {0}', $ex->getMessage()));
return false;
}
if ($response && $response->isOk()) {
$this->params['source'] = TMP . substr(md5($this->params['source']), 24) . '.zip';
$file = new File($this->params['source']);
$responseBody = $response->body();
if (is_readable($file->pwd())) {
$file->delete();
}
if (!empty($responseBody) && $file->create() && $file->write($responseBody, 'w+', true)) {
$file->close();
return $this->_getFromFile();
$this->err(__d('installer', 'Unable to extract the package.'));
return false;
}
$this->err(__d('installer', 'Unable to download the file, check write permission on "{0}" directory.', [TMP]));
return false;
}
$this->err(__d('installer', 'Could not download the package, no .ZIP file was found at the given URL.'));
return false;
}
示例4: testMime
/**
* Test mime()
*
* @return void
*/
public function testMime()
{
$this->skipIf(!function_exists('finfo_open') && !function_exists('mime_content_type'), 'Not able to read mime type');
$path = TEST_APP . 'webroot/img/cake.power.gif';
$file = new File($path);
$expected = 'image/gif';
if (function_exists('mime_content_type') && mime_content_type($file->pwd()) === false) {
$expected = false;
}
$this->assertEquals($expected, $file->mime());
}