• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Filesystem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: generatePDF

 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
开发者ID:pstaender,项目名称:ShopSystem,代码行数:28,代码来源:ShopInvoice.php


示例2: processThumb

 public function processThumb($imgsrc, $_id, $isUrl = true)
 {
     $_id = empty($_id) ? $this->_id : $_id;
     $storage = Yii::app()->params['feed_path'];
     $temp = Yii::app()->params['temp'];
     $fileInfo = explode('.', $imgsrc);
     $fileType = $fileInfo[count($fileInfo) - 1];
     $fileName = 'tmp_' . $_id . "." . $fileType;
     $tmpFile = $temp . DS . $fileName;
     if ($isUrl) {
         $res_get_file = FileRemote::getFromUrl($imgsrc, $tmpFile);
     } else {
         $fileSystem = new Filesystem();
         $res_get_file = $fileSystem->copy($imgsrc, $tmpFile);
     }
     if (file_exists($tmpFile)) {
         $fileDest = StorageHelper::generalStoragePath($_id, $fileType, $storage);
         /*$fileSystem = new Filesystem();
           $copy = $fileSystem->copy($tmpFile,$fileDest);*/
         $width = Yii::app()->params['profile_image']['thumb']['width'];
         $height = Yii::app()->params['profile_image']['thumb']['height'];
         $resizeObj = new ResizeImage($tmpFile);
         $rs = $resizeObj->resizeImage($width, $height, 0);
         $res = $resizeObj->saveImage($fileDest, 100);
         if ($resizeObj) {
             $feed = self::model()->findByPk(new MongoId($_id));
             $fileDest = str_replace($storage, '', $fileDest);
             $feed->thumb = $fileDest;
             $res = $feed->save();
             return $res;
         }
     } else {
         throw new Exception("create file temp error!", 7);
     }
 }
开发者ID:phuongitvn,项目名称:vdh,代码行数:35,代码来源:FeedModel.php


示例3: beforeGetContentBody

 protected function beforeGetContentBody()
 {
     $sn = time();
     $i = 0;
     $tmpFile = $temp = Yii::app()->params['temp'];
     $storage = Yii::app()->params['feed_path'];
     $cdn = Yii::app()->params['cdn_url'];
     $contentParttern = $this->config['content_pattern'];
     foreach ($this->html->find("{$contentParttern} img") as $e) {
         $imgSrc = $e->src;
         if (!empty($imgSrc)) {
             $fileInfo = explode('.', $imgSrc);
             $fileType = $fileInfo[count($fileInfo) - 1];
             $fileName = 'tmp_' . $sn . $i . "." . $fileType;
             $sfile = $tmpFile . DS . $fileName;
             $res_get_file = FileRemote::getFromUrl($imgSrc, $sfile);
             if ($res_get_file && file_exists($sfile)) {
                 $fileDest = StorageHelper::generalStoragePath($sn . $i, $fileType, $storage);
                 $fileSystem = new Filesystem();
                 $copy = $fileSystem->copy($sfile, $fileDest);
                 if ($copy) {
                     echo $fileDest . "\n";
                     $fileDestUrl = str_replace($storage, $cdn, $fileDest);
                     $fileDestUrl = str_replace(DS, "/", $fileDestUrl);
                     echo $fileDestUrl . "\n";
                     $e->src = $fileDestUrl;
                     echo 'replace file content success' . "\n";
                 } else {
                     echo 'replace file content error' . "\n";
                 }
             }
             $i++;
         }
     }
 }
开发者ID:phuongitvn,项目名称:vdh,代码行数:35,代码来源:Cnet.php


示例4: deleteTmpDir

 protected function deleteTmpDir($testCase)
 {
     if (!file_exists($dir = sys_get_temp_dir() . '/' . Kernel::VERSION . '/' . $testCase)) {
         return;
     }
     $fs = new Filesystem();
     $fs->remove($dir);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:8,代码来源:WebTestCase.php


示例5: render

 public function render()
 {
     if (!empty($this->sPath)) {
         $oFilesystem = new Filesystem();
         $sFileContents = $oFilesystem->getFileContents($this->sPath);
         return $this->processMarkdown($sFileContents);
     }
     return null;
 }
开发者ID:rbnvrw,项目名称:crispus,代码行数:9,代码来源:Block.php


示例6: testShouldMoveFilesThatNeedEspecialPermissions

 public function testShouldMoveFilesThatNeedEspecialPermissions()
 {
     $filesystem = new Filesystem();
     $file = '/app/tmp/file';
     $target = '/system/root/';
     $return = $filesystem->sysMove($file, $target);
     $this->assertRegExp('/sudo mv -v/', $return);
     $this->assertRegExp('/\\/app\\/tmp\\/file/', $return);
     $this->assertRegExp('/\\/system\\/root\\//', $return);
 }
开发者ID:nocttuam,项目名称:marvin,代码行数:10,代码来源:FilesystemTest.php


示例7: processAvatar

 public static function processAvatar($model, $source, $type = "artist")
 {
     try {
         $fileSystem = new Filesystem();
         $alowSize = Yii::app()->params['imageSize'];
         $maxSize = max($alowSize);
         $folderMax = "s0";
         foreach ($alowSize as $folder => $size) {
             // Create folder by ID
             $fileSystem->mkdirs($model->getAvatarPath($model->id, $folder, true));
             @chmod($model->getAvatarPath($model->id, $folder, true), 0755);
             // Get link file by ID
             $savePath[$folder] = $model->getAvatarPath($model->id, $folder);
             if ($size == $maxSize) {
                 $folderMax = $folder;
             }
         }
         // Delete file if exists
         if (file_exists($savePath[$folder])) {
             $fileSystem->remove($savePath);
         }
         if (file_exists($source)) {
             list($width, $height) = getimagesize($source);
             $imgCrop = new ImageCrop($source, 0, 0, $width, $height);
             // aspect ratio for image size
             $aspectRatioW = $aspectRatioH = 1;
             if ($type == "video") {
                 $videoAspectRatio = Yii::app()->params['videoResolutionRate'];
                 list($aspectRatioW, $aspectRatioH) = explode(":", $videoAspectRatio);
             }
             $res = array();
             foreach ($savePath as $k => $v) {
                 $desWidth = $alowSize[$k];
                 $desHeight = round($alowSize[$k] * intval($aspectRatioH) / intval($aspectRatioW));
                 if (file_exists($v) && is_file($v)) {
                     @unlink($v);
                 }
                 if ($width > 4000) {
                     self::ImageCropPro($v, $source, $desWidth, $desHeight, 70);
                 } else {
                     if ($k == $folderMax) {
                         $imgCrop->resizeRatio($v, $desWidth, $desHeight, 70);
                     } else {
                         $imgCrop->resizeCrop($v, $desWidth, $desHeight, 70);
                     }
                 }
             }
             if ($type != "video") {
                 $fileSystem->remove($source);
             }
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:55,代码来源:AvatarHelper.php


示例8: testIfRetrievingTheFilesWorks

 public function testIfRetrievingTheFilesWorks()
 {
     $config = \Mockery::mock('eXistenZNL\\PermCheck\\Config\\Config');
     $filesystem = new Filesystem($config, dirname(__FILE__));
     $files = array(__FILE__);
     $result = array();
     foreach ($filesystem->getFiles() as $file) {
         $result[] = $file->getPathname();
     }
     $this->assertEquals($files, $result);
 }
开发者ID:renatomefidf,项目名称:eXistenZNL-PermCheck,代码行数:11,代码来源:FilesystemTest.php


示例9: manageConfigs

 public function manageConfigs()
 {
     $fileSystem = new Filesystem();
     $files = $fileSystem->files(__DIR__ . '/config');
     if (!empty($files)) {
         foreach ($files as $file) {
             $name = explode('/', $file);
             $this->mergeConfigFrom($file, str_replace('.php', '', $name[count($name) - 1]));
         }
     }
 }
开发者ID:shannonp63,项目名称:boojbit,代码行数:11,代码来源:BoojBitServiceProvider.php


示例10: moveDefaultTemplate

 private function moveDefaultTemplate()
 {
     $this->log('Moving default template...');
     $fileDir = $this->container->getParameter('claroline.param.files_directory');
     $defaultTemplate = $this->container->getParameter('claroline.param.default_template');
     $newTemplateDir = $fileDir . '/templates';
     $newTemplate = $newTemplateDir . '/default.zip';
     $fs = new Filesystem();
     $fs->mkdir($newTemplateDir);
     $fs->copy($defaultTemplate, $newTemplate);
 }
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:Updater050003.php


示例11: generalStoragePath

 public static function generalStoragePath($objId, $fileType = 'jpg', $storage, $isUrl = false)
 {
     $year = date('Y');
     $month = date('m');
     $day = date('d');
     $sep = $isUrl ? '/' : DS;
     $exPath = $year . $sep . $month . $sep . $day;
     $filePath = $storage . $sep . $exPath;
     $fileSystem = new Filesystem();
     $res = $fileSystem->mkdirs($filePath, '0755');
     return $filePath . $sep . $objId . '.' . $fileType;
 }
开发者ID:phuongitvn,项目名称:vdh,代码行数:12,代码来源:StorageHelper.php


示例12: testIfRetrievingTheFilesWorks

 public function testIfRetrievingTheFilesWorks()
 {
     /** @var Config|MockInterface $config */
     $config = \Mockery::mock(new Config());
     $filesystem = new Filesystem($config, __DIR__);
     $files = array(__FILE__);
     $result = array();
     foreach ($filesystem->getFiles() as $file) {
         $result[] = $file->getPathname();
     }
     $this->assertEquals($files, $result);
 }
开发者ID:eXistenZNL,项目名称:PermCheck,代码行数:12,代码来源:FilesystemTest.php


示例13: __construct

 public function __construct($sConfigFile = 'config.json')
 {
     $oFilesystem = new Filesystem();
     $sContents = $oFilesystem->getFileContents($sConfigFile);
     if (!empty($sContents)) {
         $this->_aConfig = json_decode($sContents, true);
         if (empty($this->_aConfig)) {
             throw new BadConfigException(sprintf($this->sError, $sConfigFile, $this->getJSONError(json_last_error())));
         }
     } else {
         throw new BadConfigException("Config file is empty: " . $sConfigFile);
     }
 }
开发者ID:rbnvrw,项目名称:crispus,代码行数:13,代码来源:Config.php


示例14: test_symlink_removal

 public function test_symlink_removal()
 {
     $test_dir = 'tests/test-data/symlinks';
     $test_link = $test_dir . '/points_nowhere';
     if (is_dir($test_dir)) {
         $this->rmdir_recursive($test_dir);
     }
     mkdir($test_dir);
     symlink("does_not_exist", $test_link);
     $fs = new Filesystem();
     $fs->remove($test_dir);
     $this->assertFalse(is_link($test_link) || is_file($test_link));
 }
开发者ID:alexanderwanyoike,项目名称:php-filesystem,代码行数:13,代码来源:FilesystemTest.php


示例15: homeify

 /**
  * Replaces the `~` symbol with the user home path.
  *
  * @param string $path
  * @return string The path with the `~` replaced with the user home path if any.
  */
 public static function homeify($path, Filesystem $filesystem = null)
 {
     if (!is_string($path)) {
         throw new \InvalidArgumentException('Paht must be a string');
     }
     if (empty($filesystem)) {
         $filesystem = new Filesystem();
     }
     $userHome = $filesystem->getUserHome();
     if (!(empty($userHome) && false !== strpos($path, '~'))) {
         $path = str_replace('~', $userHome, $path);
     }
     return $path;
 }
开发者ID:LeRondPoint,项目名称:wp-browser,代码行数:20,代码来源:Utils.php


示例16: complete

 /**
  * Completes the job by zipping up the generated export and creating an
  * export record for it.
  */
 protected function complete()
 {
     $siteTitle = SiteConfig::current_site_config()->Title;
     $filename = preg_replace('/[^a-zA-Z0-9-.+]/', '-', sprintf('%s-%s.zip', $siteTitle, date('c')));
     $dir = Folder::findOrMake(SiteExportExtension::EXPORTS_DIR);
     $dirname = ASSETS_PATH . '/' . SiteExportExtension::EXPORTS_DIR;
     $pathname = "{$dirname}/{$filename}";
     SiteExportUtils::zip_directory($this->tempDir, "{$dirname}/{$filename}");
     Filesystem::removeFolder($this->tempDir);
     $file = new File();
     $file->ParentID = $dir->ID;
     $file->Title = $siteTitle . ' ' . date('c');
     $file->Filename = $dir->Filename . $filename;
     $file->write();
     $export = new SiteExport();
     $export->ParentClass = $this->rootClass;
     $export->ParentID = $this->rootId;
     $export->Theme = $this->theme;
     $export->BaseUrlType = ucfirst($this->baseUrlType);
     $export->BaseUrl = $this->baseUrl;
     $export->ArchiveID = $file->ID;
     $export->write();
     if ($this->email) {
         $email = new Email();
         $email->setTo($this->email);
         $email->setTemplate('SiteExportCompleteEmail');
         $email->setSubject(sprintf('Site Export For "%s" Complete', $siteTitle));
         $email->populateTemplate(array('SiteTitle' => $siteTitle, 'Link' => $file->getAbsoluteURL()));
         $email->send();
     }
 }
开发者ID:rodneyway,项目名称:silverstripe-siteexporter,代码行数:35,代码来源:SiteExportJob.php


示例17: save

 public function save()
 {
     if (!$this->getMailKey()) {
         $this->setMailKey(Filesystem::readRandomCharacters(20));
     }
     return parent::save();
 }
开发者ID:Houzz,项目名称:phabricator,代码行数:7,代码来源:PhabricatorOwnersPackage.php


示例18: get

 public static function get()
 {
     $rmFile = preg_replace("/\\/\\*([^x00]*)\\*?\\/?\\*\\//U", "", Filesystem::getFileContent(Config::ROADMAP));
     $roadMap = JSON::decode($rmFile, true);
     $tmpl = self::$_attr;
     $cnt = 0;
     $good = is_array($roadMap);
     //print_r( $roadMap ); die;
     for ($i = 0; $good && is_array($roadMap) && $i < count($roadMap); $i++) {
         $el = $roadMap[$i];
         foreach ($el as $k => $v) {
             if (($pos = array_search($k, $tmpl)) !== FALSE) {
                 $tmpl[$pos] = "asnfcjrwpht984fh9prewgf84fds";
                 $cnt++;
             }
         }
         $good = $cnt == count(self::$_attr);
     }
     if ($good) {
         return $roadMap;
     } else {
         self::raiseException(ERR_ROADMAP);
         return NULL;
     }
 }
开发者ID:nirwander,项目名称:holkinsengine,代码行数:25,代码来源:RoadMap.class.php


示例19: loadSkinSpecification

 private static function loadSkinSpecification($path)
 {
     $config_path = $path . DIRECTORY_SEPARATOR . 'skin.json';
     $config = array();
     if (Filesystem::pathExists($config_path)) {
         $config = Filesystem::readFile($config_path);
         try {
             $config = phutil_json_decode($config);
         } catch (PhutilJSONParserException $ex) {
             throw new PhutilProxyException(pht("Skin configuration file '%s' is not a valid JSON file.", $config_path), $ex);
         }
         $type = idx($config, 'type', self::TYPE_BASIC);
     } else {
         $type = self::TYPE_BASIC;
     }
     $spec = new PhameSkinSpecification();
     $spec->setRootDirectory($path);
     $spec->setConfig($config);
     switch ($type) {
         case self::TYPE_BASIC:
             $spec->setSkinClass('PhameBasicTemplateBlogSkin');
             break;
         case self::TYPE_ADVANCED:
             $spec->setSkinClass($config['class']);
             $spec->addPhutilLibrary($path . DIRECTORY_SEPARATOR . 'src');
             break;
         default:
             throw new Exception(pht('Unknown skin type!'));
     }
     $spec->setType($type);
     return $spec;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:32,代码来源:PhameSkinSpecification.php


示例20: setUp

 public function setUp()
 {
     parent::setUp();
     $this->logInWithPermission('ADMIN');
     Versioned::reading_stage('Stage');
     // Set backend root to /AssetFieldTest
     AssetStoreTest_SpyStore::activate('AssetFieldTest');
     $create = function ($path) {
         Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
     };
     // Write all DBFile references
     foreach (AssetFieldTest_Object::get() as $object) {
         $path = AssetStoreTest_SpyStore::getLocalPath($object->File);
         $create($path);
     }
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $path = AssetStoreTest_SpyStore::getLocalPath($file);
         $create($path);
     }
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:25,代码来源:AssetFieldTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Filter类代码示例发布时间:2022-05-23
下一篇:
PHP FilesModel类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap