本文整理汇总了PHP中SplFileInfo::getFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getFileName方法的具体用法?PHP SplFileInfo::getFileName怎么用?PHP SplFileInfo::getFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getFileName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
/**
*
* @param SplFileInfo $file
* @param string $path
* @param RecursiveDirectoryIterator $iterator
* @return boolean
*/
public function call(\SplFileInfo $file, $path, \RecursiveDirectoryIterator $iterator)
{
$firstChar = substr($file->getFileName(), 0, 1);
if (in_array($firstChar, ['.', '_'])) {
return false;
}
if ($file->isDir()) {
return true;
}
if (!in_array($file->getExtension(), $this->extensions)) {
return false;
}
return true;
}
示例2: properties
public function properties($path)
{
$path = $this->preparePath($path);
$file = new \SplFileInfo($path);
$data['Name'] = $file->getFileName();
$data['Type'] = $file->getType();
$data['Size'] = $file->getSize() . ' b';
$data['Location'] = $this->fileSystem->makePathRelative(pathinfo($file->getRealPath(), PATHINFO_DIRNAME), $this->root);
return $data;
}
示例3: SplFileInfo
<?php
/**
* Read file info
* @author Bramus Van Damme <bramus.vandamme@odisee.be>
*/
$filename = __DIR__ . '/testfile.txt';
$fi = new SplFileInfo($filename);
echo '<p>The file ' . $fi->getFileName() . ' was last modified on ' . date('Y-m-d H:i:s', $fi->getMTime()) . '</p>' . PHP_EOL;
echo '<p>The file ' . $fi->getFileName() . ' is ' . ($fi->isDir() ? '' : 'not') . ' a directory</p>' . PHP_EOL;
echo '<p>The file ' . $fi->getFileName() . ' is ' . ($fi->isFile() ? '' : 'not') . ' a file</p>' . PHP_EOL;
echo '<p>The file ' . $fi->getFileName() . ' is ' . ($fi->isLink() ? '' : 'not') . ' a shortcut</p>' . PHP_EOL;
// EOF
示例4: SplFileInfo
<?php
$file = new SplFileInfo('spl_file_info.php');
print 'Nome: ' . $file->getFileName() . '<br>' . PHP_EOL;
print 'Extensão: ' . $file->getExtension() . '<br>' . PHP_EOL;
print 'Tamanho: ' . $file->getSize() . '<br>' . PHP_EOL;
print 'Caminho: ' . $file->getRealPath() . '<br>' . PHP_EOL;
print 'Tipo: ' . $file->getType() . '<br>' . PHP_EOL;
print 'Gravação: ' . $file->isWritable() . '<br>' . PHP_EOL;
示例5: publishFile
/**
* Publishes a file
*
* @param \SplFileInfo $file
*/
protected function publishFile($file)
{
$cache = $this->getFileCache();
$id = $this->hash($file->getRealPath());
if (!array_key_exists($id, $cache)) {
$fileCache = array('sha' => 'cdnManager', 'ver' => $this->startVersion, 'run' => 0);
} else {
$fileCache = $cache[$id];
}
$crc = sha1_file($file->getRealPath());
if ($fileCache['sha'] !== $crc) {
$this->consoleEcho("Updating ", "0;32");
$this->consoleEcho($file->getFileName() . " \r\n", true);
$fileCache['ver'] = $fileCache['ver'] + 1;
$fileCache['sha'] = $crc;
$fileCache['pub'] = $this->assetManager->publish($file->getRealPath(), false, -1, true, $fileCache['ver']);
$fileCache['run'] = $this->timeStamp;
$cache[$id] = $fileCache;
$this->setFileCache($cache);
} else {
$this->consoleEcho("No Change ", "0;33");
$this->consoleEcho($file->getFileName() . "\r\n");
}
}
示例6: internalSort
/**
* File/directory sorting function
* @param SplFileInfo $a First item
* @param SplFileInfo $b Second item
* @return boolean
*/
private function internalSort($a, $b)
{
// Compare name
return $a->getFileName() > $b->getFileName();
}
示例7: glob
echo 'wrote ' . $out_path . $req_uri . "\n";
}
}
/**
* copy php file
*/
$files = glob($pub_path . '/*');
foreach ($files as $file) {
if (!is_file($file)) {
continue;
}
$info = new \SplFileInfo($file);
if ($info->getExtension() != 'php') {
continue;
}
if ($info->getFileName() == 'index.php' || $info->getFileName() == 'phybrid_generator.php') {
continue;
}
copy($file, $out_path . '/' . $info->getFileName());
if ($debug) {
echo 'copied ' . $file . "\n";
}
}
/**
* copy assets files and image files
*/
if (file_exists($pub_path . '/assets')) {
system('cp -pfr ' . $pub_path . '/assets ' . $out_path . '/.');
if ($debug) {
echo "copied assets directory\n";
}