本文整理汇总了PHP中SplFileInfo::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getPath方法的具体用法?PHP SplFileInfo::getPath怎么用?PHP SplFileInfo::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_does_not_change_not_updated_file()
{
$file = new \SplFileInfo(__FILE__);
$changes = ['data' => ['filePath' => $file->getPath()]];
$originals = ['data' => ['filePath' => $file->getPath()]];
$this->compare($changes, $originals)->shouldReturn(null);
}
示例2: upload
/**
* upload
*
* @param \JInput $input
*/
public static function upload(\JInput $input)
{
try {
$editorPlugin = \JPluginHelper::getPlugin('editors', 'akmarkdown');
if (!$editorPlugin) {
throw new \Exception('Editor Akmarkdown not exists');
}
$params = new Registry($editorPlugin->params);
$files = $input->files;
$field = $input->get('field', 'file');
$type = $input->get('type', 'post');
$allows = $params->get('Upload_AllowExtension', '');
$allows = array_map('strtolower', array_map('trim', explode(',', $allows)));
$file = $files->getVar($field);
$src = $file['tmp_name'];
$name = $file['name'];
$tmp = new \SplFileInfo(JPATH_ROOT . '/tmp/ak-upload/' . $name);
if (empty($file['tmp_name'])) {
throw new \Exception('File not upload');
}
$ext = pathinfo($name, PATHINFO_EXTENSION);
if (!in_array($ext, $allows)) {
throw new \Exception('File extension now allowed.');
}
// Move file to tmp
if (!is_dir($tmp->getPath())) {
\JFolder::create($tmp->getPath());
}
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
\JFile::upload($src, $tmp->getPathname());
$src = $tmp;
$dest = static::getDest($name, $params->get('Upload_S3_Subfolder', 'ak-upload'));
$s3 = new \S3($params->get('Upload_S3_Key'), $params->get('Upload_S3_SecretKey'));
$bucket = $params->get('Upload_S3_Bucket');
$result = $s3::putObject(\S3::inputFile($src->getPathname(), false), $bucket, $dest, \S3::ACL_PUBLIC_READ);
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
if (!$result) {
throw new \Exception('Upload fail.');
}
} catch (\Exception $e) {
$response = new Response();
$response->setBody(json_encode(['error' => $e->getMessage()]));
$response->setMimeType('text/json');
$response->respond();
exit;
}
$return = new \JRegistry();
$return['filename'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$return['file'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$response = new Response();
$response->setBody((string) $return);
$response->setMimeType('text/json');
$response->respond();
}
示例3: write
/**
* Writes the class to a file.
*/
public function write()
{
try {
$dir = $this->path->isDir() ? $this->path->getPathname() : $this->path->getPath();
$path = $dir . '/' . $this->baseClass->getClassName() . $this->baseClass->getExtension();
if (!file_exists($dir)) {
$this->fileSystem->mkdir($dir, 0777, true);
}
//if (!file_exists($path)) {
file_put_contents($path, $this->baseClass->generate());
//}
} catch (IOExceptionInterface $e) {
}
}
示例4: _processArgs
/**
* processes the command line arguments
*
* @param array $args
* @return void
*/
protected function _processArgs($args = array())
{
if (count($args) == 1) {
throw new Exception('no test directory specified');
}
$dir = array_pop($args);
if (!is_dir($dir) && !file_exists($dir)) {
throw new Exception('invalid test directory specified: ' . $dir);
}
// single file
if (!is_dir($dir) && file_exists($dir)) {
$path = $this->_convertDirectoryToPath($dir);
$this->_file = new \SplFileInfo($path);
$this->directory($this->_file->getPath());
}
if (is_dir($dir)) {
$directory = $this->_convertDirectoryToPath($dir);
$this->directory($directory);
}
$coverage_directory = $this->_getArgValue('--coverage-html', $args);
if (!$coverage_directory) {
return;
}
if (!file_exists($coverage_directory)) {
mkdir($coverage_directory);
}
$path = $this->_convertDirectoryToPath($coverage_directory);
$this->coverageDirectory($path);
}
示例5: extractZipArchive
/**
* Extract the zip archive to be imported
*
* @throws \RuntimeException When archive cannot be opened or extracted or does not contain exactly one file file
*/
protected function extractZipArchive()
{
$archive = new \ZipArchive();
$status = $archive->open($this->filePath);
if (true !== $status) {
throw new \RuntimeException(sprintf('Error "%d" occurred while opening the zip archive.', $status));
}
$path = $this->fileInfo->getPath();
$filename = $this->fileInfo->getBasename('.' . $this->fileInfo->getExtension());
$targetDir = sprintf('%s/%s', $path, $filename);
if (!$archive->extractTo($targetDir)) {
throw new \RuntimeException('Error occurred while extracting the zip archive.');
}
$archive->close();
$this->archivePath = $targetDir;
$finder = new Finder();
$files = $finder->in($targetDir)->name('/\\.' . $this->type . '$/i');
$count = $files->count();
if (1 !== $count) {
throw new \RuntimeException(sprintf('Expecting the root directory of the archive to contain exactly 1 file file, found %d', $count));
}
$filesIterator = $files->getIterator();
$filesIterator->rewind();
$this->filePath = $filesIterator->current()->getPathname();
}
示例6: __construct
/**
* Class constructor
*
* @param string $file_name File name
*/
public function __construct($file_name)
{
// Construct a new SplFileInfo object
$spl = new SplFileInfo($file_name);
$this->_name = $spl->getBasename();
$this->_path = $spl->getPath();
self::$instance = $this;
}
示例7: buildElephantFile
public function buildElephantFile($file)
{
$file = new \SplFileInfo($file);
$resultFile = $file->getPath() . DIRECTORY_SEPARATOR . $file->getBasename('.elph') . '.php';
$rewriter = new Rewriter($resultFile);
$rewriter->save();
return $resultFile;
}
示例8: getFileDetailsRaw
/**
* Returns the details about Communicator (current) file
* w/o any kind of verification of file existance
*
* @param string $fileGiven
* @return array
*/
protected function getFileDetailsRaw($fileGiven)
{
$info = new \SplFileInfo($fileGiven);
$aFileBasicDetails = ['File Extension' => $info->getExtension(), 'File Group' => $info->getGroup(), 'File Inode' => $info->getInode(), 'File Link Target' => $info->isLink() ? $info->getLinkTarget() : '-', 'File Name' => $info->getBasename('.' . $info->getExtension()), 'File Name w. Extension' => $info->getFilename(), 'File Owner' => $info->getOwner(), 'File Path' => $info->getPath(), 'Name' => $info->getRealPath(), 'Type' => $info->getType()];
$aDetails = array_merge($aFileBasicDetails, $this->getFileDetailsRawStatistic($info, $fileGiven));
ksort($aDetails);
return $aDetails;
}
示例9: checkDirectory
protected function checkDirectory($path)
{
$outFile = new \SplFileInfo($path);
$directory = $outFile->getPath();
if (!$this->file->exists($directory)) {
$this->file->makeDirectory($directory, 0777, true);
}
}
示例10: let
function let(\SplFileInfo $file, Suite $suite)
{
$file->getFilename()->willReturn(__FILE__);
$file->getPath()->willReturn(__DIR__);
$file->getBasename('.php')->willReturn('SpecSpec');
$this->beConstructedWith($file, $suite, realpath(__DIR__ . '/../../../../..'));
$this->shouldHaveType('Funk\\Specification\\Locator\\Iterator\\Spec');
}
示例11: rename
/**
* Only allowed for internal files (on the server)
*
* @param string $newOnlyName
* @throws \UnexpectedValueException if the file is link
* @return bool
*/
public function rename($newOnlyName)
{
if ($this->file->isFile() === false) {
throw new \UnexpectedValueException('the file can not be link');
}
$this->setPath($this->file->getPath());
$this->setName($newOnlyName);
return rename($this->file->getRealPath(), $this->fullPath);
}
示例12: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$this->processConfiguration($configuration, $configs);
$reflection = new \ReflectionClass($this);
$splFile = new \SplFileInfo($reflection->getFileName());
$loader = new Loader\YamlFileLoader($container, new FileLocator($splFile->getPath() . '/../Resources/config'));
$loader->load('services.yml');
}
示例13: setFilePath
/**
* @param string $filePath
* @throws InvalidArgumentException
*/
public function setFilePath($filePath)
{
$this->fileInfo = new \SplFileInfo($filePath);
$dirInfo = new \SplFileInfo($this->fileInfo->getPath());
if (!$dirInfo->isDir()) {
throw new InvalidArgumentException(sprintf('Directory "%s" does not exists.', $this->fileInfo->getPath()));
} elseif (!$dirInfo->isWritable()) {
throw new InvalidArgumentException(sprintf('Directory "%s" is not writable.', $dirInfo->getRealPath()));
}
}
示例14: getContent
public function getContent()
{
$info = new \SplFileInfo($this->file);
$renderer = new PhpRenderer();
$stack = new TemplatePathStack();
$stack->addPath($info->getPath());
$stack->setDefaultSuffix(pathinfo($this->file, PATHINFO_EXTENSION));
$renderer->setResolver($stack);
return $renderer->render($info->getBasename());
}
示例15: createThumb
/**
* createThumb
*
* @param string $src
*
* @return bool
*/
public static function createThumb($src, $width = 400, $height = 400)
{
$dest = new \SplFileInfo(WINDWALKER_CACHE . '/image/temp/' . md5($src));
Folder::create($dest->getPath());
$image = new Image();
$image->loadFile($src);
$image->cropResize($width, $height, false);
$image->toFile($dest->getPathname() . '.jpg');
return $dest->getPathname() . '.jpg';
}