本文整理汇总了PHP中SplFileInfo::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getFilename方法的具体用法?PHP SplFileInfo::getFilename怎么用?PHP SplFileInfo::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register($fileinfo)
{
//parse module
if (!$fileinfo instanceof \SplFileInfo) {
$fileinfo = new \SplFileInfo($fileinfo);
}
echo sprintf("scan module %s in folder %s\n", $fileinfo->getFilename(), $fileinfo->getPathname());
$info_filename = $fileinfo->getPathname() . DIRECTORY_SEPARATOR . 'module.info';
$module_info = parse_ini_file($info_filename);
if (!isset($module_info['c_name'])) {
$module_info['c_name'] = $fileinfo->getFilename();
}
$dbal = DBAL::insert(\ORC\APP\Module::TABLENAME_MODULE);
$dbal->set('name', $module_info['name']);
$dbal->set('c_name', $module_info['c_name']);
$dbal->set('description', empty($module_info['description']) ? '' : $module_info['description']);
$dbal->set('dependence', empty($module_info['dependence']) ? '' : implode(',', $module_info['dependence']));
//$dbal->set('permissions', empty($module_info['permissions']) ? '' : implode(',', $module_info['permissions']));
$dbal->setDuplicate(array('name', 'description', 'dependence'));
$dbal->execute();
echo "\tdb done.\n";
if (!empty($module_info['permissions'])) {
$dbal = DBAL::insert(\ORC\APP\Module::TABLENAME_PERMS);
foreach ($module_info['permissions'] as $perm) {
$dbal->set('perm', $perm);
$dbal->setDuplicate('perm');
$dbal->execute();
}
echo "\tpermission done.\n";
}
//check actions
$folder = $fileinfo->getPathname() . DIRECTORY_SEPARATOR . 'actions';
$this->scanActions($module_info['c_name'], $folder);
}
示例2: importSingleMovie
public function importSingleMovie(\SplFileInfo $source)
{
if (!$source->isReadable()) {
return $this->output->writelnError(sprintf("File %s not readable", $source->getFilename()));
}
$this->output->writelnInfo(sprintf("Importing %s ...", $source->getRealPath()));
$file = $source->openFile();
/** @var Movies $movie */
$movie = $this->getMovie($file->fread($file->getSize()), $file->getBasename('.html'));
if (!$movie) {
return $this->output->writelnError(sprintf("Not found dmm id", $source->getFilename()));
}
$this->currentDmmId = $movie->banngo;
if (Movies::findFirstById($movie->id)) {
return $this->output->writelnWarning(sprintf("Movie %s already exists, insert skipped", $movie->banngo));
}
/** @var Mysql $db */
$db = $this->getDI()->get('dbMaster');
$db->begin();
if (false === $movie->save()) {
$db->rollback();
return $this->output->writelnError(sprintf("Movie saving failed by %s", implode(',', $movie->getMessages())));
}
$db->commit();
$this->output->writelnSuccess(sprintf("Movie %s saving success as %s, detail: %s", $movie->banngo, $movie->id, ''));
}
示例3: move
public function move($path)
{
$newLocation = rtrim($path, '/\\') . DIRECTORY_SEPARATOR . $this->file->getFilename();
if (false === rename($this->file->getPathname(), $newLocation)) {
throw new \RuntimeException('The file can not be moved');
}
$this->unlinkOnDestroy = false;
return new \SplFileInfo($newLocation);
}
示例4: __construct
/**
* @param string $file
* @param string $type
* @param NULL|string $info
* @throws iDefendFileNotFoundException
*/
public function __construct($file, $type = self::DEFAULT_TYPE, $info = NULL)
{
if (!file_exists($file)) {
throw new iDefendFileNotFoundException("File {$file} does not exists");
}
$this->fileInfo = new \SplFileInfo($file);
$this->filename = $this->fileInfo->getFilename();
$this->type = $type;
$this->info = $info;
}
示例5: isIgnored
protected static function isIgnored(\SplFileInfo $file, $ignore)
{
if (in_array($file->getFilename(), static::$IGNORED)) {
return true;
}
if ($file->isDir() && in_array($file->getFilename(), $ignore['folders'])) {
return true;
}
if (!$file->isDir() && in_array($file->getFilename(), $ignore['files'])) {
return true;
}
return false;
}
示例6: info
public function info()
{
if (!isset($this->info)) {
$this->info = new StorageInfo(array('name' => $this->file->getFilename(), 'hash' => $this->isReadable() ? $this->getHash() : null, 'format' => $this->getFormat(), 'size' => $this->isReadable() ? $this->file->getSize() : 0, 'count' => $this->isReadable() ? count($this->reader()) : 0));
}
return $this->info;
}
示例7:
function it_cuts_the_filename_if_it_is_too_long(\SplFileInfo $file)
{
$file->getFilename()->willReturn('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.pdf');
$file->getExtension()->willReturn('pdf');
$pathInfo = $this->generate($file);
$pathInfo->shouldBeValidPathInfo('Lorem_ipsum_dolor_sit_amet__consectetur_adipiscing_elit__sed_do_eiusmod_tempor_incididunt_ut_la.pdf');
}
示例8: __construct
public function __construct($path, $source = null)
{
if (!file_exists($path)) {
throw new \Exception("{$path} file Not Found");
}
$this->time_create = time();
$this->name = session_id() . '_' . md5($path);
$file = new \SplFileInfo($path);
$this->file_name_no_extension = str_replace('.' . $file->getExtension(), '', $file->getFilename());
$this->type = $file->getExtension();
$this->file_name = $file->getFilename();
$this->path = $path;
$this->dir = dirname($path);
$this->modefy = $file->getMTime();
$this->source = $source;
}
示例9: deployProcess
public function deployProcess(\SplFileInfo $file, $name = NULL)
{
$builder = new DeploymentBuilder($name === NULL ? $file->getFilename() : $name);
$builder->addExtensions($file->getExtension());
$builder->addResource($file->getFilename(), $file);
return $this->deploy($builder);
}
示例10: loadMessages
/**
* {@inheritdoc}
*/
public function loadMessages(\SplFileInfo $file, $locale, $domain, $format = null)
{
$format = $format ?: $file->getExtension();
if (!isset($this->loaders[$format])) {
throw new \InvalidArgumentException(sprintf('Unable to import file %s: ' . 'there is no loader associated with format "%s".', $file->getFilename(), $format));
}
return $this->loaders[$format]->load($file->getPathname(), $locale, $domain);
}
示例11: getExtension
/**
* Returns extension of file
*
* @return string $extension or null if file has no extension
*/
public function getExtension()
{
$extension = pathinfo(parent::getFilename(), PATHINFO_EXTENSION);
if (!empty($extension)) {
return $extension;
}
return null;
}
示例12: 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;
}
示例13: 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');
}
示例14: testCreateFromDataAndSpec
public function testCreateFromDataAndSpec()
{
$specName = $this->getFaker()->word;
$spec = new FileSpec('', array(), 0, "\n");
$this->specLoader->shouldReceive('loadSpec')->once()->with($specName)->andReturn($spec);
$file = new \SplFileInfo(__DIR__ . '/../Fixtures/fixed_width.txt');
$lines = explode("\n", file_get_contents($file->getRealPath()));
$this->assertEquals(new InMemoryFile($file->getFilename(), strlen($lines[0]), $lines, "\n"), $this->factory->createFromFileAndSpec($file, $specName));
}
示例15: createFileFromFileInfo
/**
* create file from SplFileInfo
*
* @param SplFileInfo $file
* @return Post
*/
private function createFileFromFileInfo(\SplFileInfo $file)
{
$post = new Post($this->getFilter());
$post->setText(file_get_contents((string) $file));
$post->setIdentifier(str_replace('.markdown', '', $file->getFilename()));
$post->setCreated($file->getCTime());
$post->setModified($file->getMTime());
$matches = array();
$found = preg_match('/#.*/', $post->getText(), $matches);
if ($found === false) {
$title = $file->getFilename();
} else {
$title = ltrim(array_shift($matches), '#');
}
$post->setTitle($title);
//parse title out of body text
return $post;
}