当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFileInfo::getType方法代码示例

本文整理汇总了PHP中SplFileInfo::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getType方法的具体用法?PHP SplFileInfo::getType怎么用?PHP SplFileInfo::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplFileInfo的用法示例。


在下文中一共展示了SplFileInfo::getType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fileUploadFromFile

 /**
  * @param string $filename
  * @return FileUpload
  */
 public static function fileUploadFromFile($filename)
 {
     if (!file_exists($filename)) {
         throw new FileNotExistsException("File '{$filename}' does not exists");
     }
     $file = new \SplFileInfo($filename);
     return new FileUpload(['name' => $file->getBasename(), 'type' => $file->getType(), 'size' => $file->getSize(), 'tmp_name' => $filename, 'error' => 0]);
 }
开发者ID:ondrs,项目名称:upload-manager,代码行数:12,代码来源:Utils.php

示例2: 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;
 }
开发者ID:danielgp,项目名称:common-lib,代码行数:15,代码来源:CommonBasic.php

示例3: get_content

/**
 * Retrieve directory content, directories and files
 *
 * @param Application $app Silex Application
 * @param Request $request Request parameters
 *
 * @return JsonResponse Array of objects
 */
function get_content(Application $app, Request $request)
{
    $dirpath = Utils\check_path($app['cakebox.root'], $request->get('path'));
    if (!isset($dirpath)) {
        $app->abort(400, "Missing parameters");
    }
    $finder = new Finder();
    $finder->followLinks()->depth('< 1')->in("{$app['cakebox.root']}/{$dirpath}")->ignoreVCS(true)->ignoreDotFiles($app['directory.ignoreDotFiles'])->notName($app["directory.ignore"])->sortByType();
    $dirContent = [];
    foreach ($finder as $file) {
        if ($file->isLink()) {
            $linkTo = readlink("{$app['cakebox.root']}/{$dirpath}/{$file->getBasename()}");
            if (file_exists($linkTo) == false) {
                continue;
            }
            $file = new \SplFileInfo($linkTo);
        }
        $pathInfo = [];
        $pathInfo["name"] = $file->getBasename();
        $pathInfo["type"] = $file->getType();
        $pathInfo["mtime"] = $file->getMTime();
        $pathInfo["size"] = Utils\get_size($file);
        $pathInfo["access"] = str_replace('%2F', '/', rawurlencode("{$app['cakebox.access']}/{$dirpath}/{$file->getBasename()}"));
        $pathInfo["extraType"] = "";
        $ext = strtolower($file->getExtension());
        if (in_array($ext, $app["extension.video"])) {
            $pathInfo["extraType"] = "video";
        } else {
            if (in_array($ext, $app["extension.audio"])) {
                $pathInfo["extraType"] = "audio";
            } else {
                if (in_array($ext, $app["extension.image"])) {
                    $pathInfo["extraType"] = "image";
                } else {
                    if (in_array($ext, $app["extension.archive"])) {
                        $pathInfo["extraType"] = "archive";
                    } else {
                        if (in_array($ext, $app["extension.subtitle"])) {
                            $pathInfo["extraType"] = "subtitle";
                        }
                    }
                }
            }
        }
        array_push($dirContent, $pathInfo);
    }
    return $app->json($dirContent);
}
开发者ID:Arkhana,项目名称:Cakebox,代码行数:56,代码来源:directories.php

示例4: fileToModel

 /**
  * Converts a SplFileInfo to a Model
  *
  * @param \SplFileInfo $aFile
  *
  * @return Model
  */
 public static function fileToModel(\SplFileInfo $aFile)
 {
     $model = new \stdClass();
     $model->{'dir'} = $aFile->isDir();
     $model->{'extension'} = $aFile->getExtension();
     $model->{'filename'} = $aFile->getFilename();
     $model->{'path'} = str_replace('\\', '/', $aFile->getPathname());
     if ($aFile->isReadable()) {
         $model->{'last_modified'} = $aFile->getMTime();
         $model->{'size'} = $aFile->getSize();
         $model->{'type'} = $aFile->getType();
     }
     return $model;
 }
开发者ID:elgervb,项目名称:php-handler,代码行数:21,代码来源:JsonUtils.php

示例5: SplFileInfo

            } else {
                //TODO not sure if this is needed!
                if ($key != 'files' && $key != 'dirs') {
                    $f2s = $key . '/' . $val;
                    if (substr($f2s, -3) == 'php') {
                        $output .= 'File: ' . $f2s . PHP_EOL;
                    }
                }
            }
        }
    } else {
        $info = new SplFileInfo($o2s);
        $perms = substr(sprintf('%o', $info->getPerms()), -4);
        $owner = $info->getOwner();
        $group = $info->getGroup();
        $type = $info->getType();
        $size = $info->getSize();
        $scanner = new Scanner($o2s, $eol, $htmlMode, $scannerOptions);
        $scanner->scanFile("all", $patternData, $stringData);
        if (count($scanner->found)) {
            foreach ($scanner->found as $l) {
                $found .= $l;
            }
        } else {
            $found = '';
        }
        //make human readable size
        $size = $scanner->size_readable($size);
    }
} else {
    $ainfo = "The file/folder {$bS}{$o2s}{$bE} does not exist";
开发者ID:xinomilo,项目名称:Ghost-in-the-shell,代码行数:31,代码来源:gis.php

示例6: testDecoratedMethods

 public function testDecoratedMethods()
 {
     $decorated = $this->getMockBuilder('hanneskod\\classtools\\Tests\\MockSplFileInfo')->setConstructorArgs([''])->getMock();
     $decorated->expects($this->once())->method('getRelativePath');
     $decorated->expects($this->once())->method('getRelativePathname');
     $decorated->expects($this->once())->method('getContents');
     $decorated->expects($this->once())->method('getATime');
     $decorated->expects($this->once())->method('getBasename');
     $decorated->expects($this->once())->method('getCTime');
     $decorated->expects($this->once())->method('getExtension');
     $decorated->expects($this->once())->method('getFileInfo');
     $decorated->expects($this->once())->method('getFilename');
     $decorated->expects($this->once())->method('getGroup');
     $decorated->expects($this->once())->method('getInode');
     $decorated->expects($this->once())->method('getLinkTarget');
     $decorated->expects($this->once())->method('getMTime');
     $decorated->expects($this->once())->method('getOwner');
     $decorated->expects($this->once())->method('getPath');
     $decorated->expects($this->once())->method('getPathInfo');
     $decorated->expects($this->once())->method('getPathname');
     $decorated->expects($this->once())->method('getPerms');
     $decorated->expects($this->once())->method('getRealPath');
     $decorated->expects($this->once())->method('getSize');
     $decorated->expects($this->once())->method('getType');
     $decorated->expects($this->once())->method('isDir');
     $decorated->expects($this->once())->method('isExecutable');
     $decorated->expects($this->once())->method('isFile');
     $decorated->expects($this->once())->method('isLink');
     $decorated->expects($this->once())->method('isReadable');
     $decorated->expects($this->once())->method('isWritable');
     $decorated->expects($this->once())->method('openFile');
     $decorated->expects($this->once())->method('setFileClass');
     $decorated->expects($this->once())->method('setInfoClass');
     $decorated->expects($this->once())->method('__toString')->will($this->returnValue(''));
     $fileInfo = new SplFileInfo($decorated);
     $fileInfo->getRelativePath();
     $fileInfo->getRelativePathname();
     $fileInfo->getContents();
     $fileInfo->getATime();
     $fileInfo->getBasename();
     $fileInfo->getCTime();
     $fileInfo->getExtension();
     $fileInfo->getFileInfo();
     $fileInfo->getFilename();
     $fileInfo->getGroup();
     $fileInfo->getInode();
     $fileInfo->getLinkTarget();
     $fileInfo->getMTime();
     $fileInfo->getOwner();
     $fileInfo->getPath();
     $fileInfo->getPathInfo();
     $fileInfo->getPathname();
     $fileInfo->getPerms();
     $fileInfo->getRealPath();
     $fileInfo->getSize();
     $fileInfo->getType();
     $fileInfo->isDir();
     $fileInfo->isExecutable();
     $fileInfo->isFile();
     $fileInfo->isLink();
     $fileInfo->isReadable();
     $fileInfo->isWritable();
     $fileInfo->openFile();
     $fileInfo->setFileClass();
     $fileInfo->setInfoClass();
     (string) $fileInfo;
 }
开发者ID:hanneskod,项目名称:classtools,代码行数:67,代码来源:SplFileInfoTest.php

示例7: 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;
 }
开发者ID:hikmahtiar6,项目名称:drafterbit,代码行数:10,代码来源:Server.php

示例8: SplFileInfo

<?php

include __DIR__ . '/../../../test/sample_dir/fix_mtimes.inc';
$info = new SplFileInfo(__DIR__ . '/../../sample_dir');
if (!$info->isFile()) {
    echo $info->getRealPath();
}
$info = new SplFileInfo(__DIR__ . '/../../sample_dir/file');
var_dump($info->getbaseName());
var_dump($info->getbaseName('.cpp'));
$info->getCTime();
$info->getGroup();
$info->getInode();
$info->getMTime();
$info->getOwner();
$info->getPerms();
$info->getSize();
$info->getType();
$info->isDir();
$info->isFile();
$info->isLink();
$info->isReadable();
$info->isWritable();
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:1795.php

示例9: SplFileInfo

<?php

$info = new SplFileInfo('SplFileInfo.php');
printf("Extension: %s\n", $info->getExtension());
printf("Filename: %s\n", $info->getFilename());
printf("Path: %s\n", $info->getPathname());
printf("RealPath: %s\n", $info->getRealPath());
printf("Type: %s\n", $info->getType());
printf("Size: %s\n", $info->getSize());
printf("Dir: %b, Exec: %b, File: %b, Link: %b, R: %b, W: %b\n", $info->isDir(), $info->isExecutable(), $info->isFile(), $info->isLink(), $info->isReadable(), $info->isWritable());
$file = $info->openFile('r');
foreach ($file as $line) {
    printf("%s", $line);
}
开发者ID:Eldahar,项目名称:PHP_Library,代码行数:14,代码来源:SplFileInfo.php

示例10: 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;
开发者ID:jmoliver,项目名称:php-programando-com-orientacao-a-objeto,代码行数:9,代码来源:spl_file_info.php

示例11: FindDataDirectory

 /**
 *@version 1.0
 *@author Rolando Arriaza , ultima version
 *@todo Funcion para crear un arbol de archivos
 *@param string $directory directorio donde comenzara el arbol
 *@param string|array patron en cual el archivo debe respetar
 *@example  
 * <code>
 *   buscaremos los archivos que inicien en dashboard como dashboard.php o dashboard_img.jpg
 *   $pattern = "dashboard"
 * 
 *   busca archivos con el nombre inicial dashboard y extencion php
 *   $pattern = array("name"=>"dashboard" , "extend"=>"php");
        $pattern = array("name"=>"dashboard" , "extend"=>"php" , "pattern"=>false);
 * </code>
 *@return bool | array false si no existe directorio 
 */
 public function FindDataDirectory($directory, $pattern = null)
 {
     if (!is_dir($directory)) {
         return false;
     }
     $object = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::SELF_FIRST);
     if (SivarApi\Tools\Validation::Is_Empty_OrNull($pattern)) {
         foreach ($object as $key => $value) {
             $class = new SplFileInfo($key);
             if ($class->getType() == "file") {
                 $filename = $class->getFilename();
                 $path = $class->getPath();
                 array_push($this->array_dir, array("root" => $path, "filename" => $filename));
             }
         }
     } else {
         $preg = null;
         if (is_array($pattern)) {
             if (isset($pattern['pattern'])) {
                 $p = $pattern["name"];
                 $ext = $pattern["extend"];
                 $preg = "/^({$p}\\.{$ext})\$/";
             } else {
                 $p = $pattern["name"];
                 $ext = $pattern["extend"];
                 $preg = "/^({$p}\\w+\\.{$ext})\$/";
             }
         } else {
             $preg = "/^({$pattern}\\w+\\.php)\$/";
         }
         foreach ($object as $key => $value) {
             $class = new SplFileInfo($key);
             if ($class->getType() == "file") {
                 $filename = $class->getFilename();
                 $path = $class->getPath();
                 $ext = $class->getExtension();
                 if (preg_match($preg, $filename)) {
                     array_push($this->array_dir, array("root" => $path, "filename" => $filename));
                 }
             }
         }
     }
     return $this->array_dir;
 }
开发者ID:E89son,项目名称:LieisonCMS,代码行数:61,代码来源:Class.Directory.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configHelper = $this->getHelper('configuration');
     /* @var $configHelper GlobalConfigurationHelper */
     $processHelper = $this->getHelper('process');
     /* @var $processHelper ProcessHelper */
     if ($output instanceof ConsoleOutput) {
         $stderr = $output->getErrorOutput();
     } else {
         $stderr = $output;
     }
     $sshDir = $configHelper->getConfiguration()->getSshDirectory();
     $keyFile = new \SplFileInfo($input->getArgument('key') ?: $sshDir . '/id_rsa-' . sha1(mt_rand() . time()));
     // Check if file already exists
     try {
         $keyFile->getType();
         // Throws if file does not exist.
         throw new FileExistsException($keyFile);
     } catch (\RuntimeException $ex) {
         // noop
     }
     OutsideConfiguredRootDirectoryException::assert($keyFile, 'ssh-dir', $configHelper->getConfiguration()->getSshDirectory());
     $sshKeygen = ProcessBuilder::create(['ssh-keygen', '-q', '-f', $keyFile, '-C', $input->getOption('comment'), '-N', ''])->setTimeout(null)->getProcess();
     $processHelper->mustRun($output, $sshKeygen);
     $stderr->writeln(sprintf('Generated key <info>%s</info>', $keyFile->getPathname()), OutputInterface::VERBOSITY_VERBOSE);
     if ($input->getOption('print-public-key')) {
         $output->write(file_get_contents($keyFile->getPathname() . '.pub'), false, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_QUIET);
     }
     if ($input->getOption('target-repository')) {
         $this->getApplication()->find('repository:add')->run(new ArrayInput(['repository' => $input->getOption('target-repository'), 'key' => $keyFile->getPathname(), '--alias' => preg_replace('/^id_rsa-/', '', $keyFile->getFilename())]), $output);
     }
 }
开发者ID:vierbergenlars,项目名称:clic,代码行数:32,代码来源:GenerateCommand.php


注:本文中的SplFileInfo::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。