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

PHP FileWriter类代码示例

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

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



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

示例1: resetCrontab

 public static function resetCrontab()
 {
     $cron_file = 'cron.txt';
     $cron = new FileWriter($cron_file, 'a');
     $setSessionPath = '/home1/enderrac/SpirePHP/setSessionWinner.php';
     $stm = "SELECT EXTRACT(MINUTE from end_ts) as minute, " . "\tEXTRACT(HOUR from end_ts) as hour, " . "\tEXTRACT(day from end_ts) as day_of_month, " . "\tEXTRACT(MONTH from end_ts) as month, " . "\tEXTRACT(dow from end_ts) as day_of_week, " . "\tid " . "FROM SPIRE.SESSIONS ";
     $result = ConnDB::query_db($stm);
     $fnHash = null;
     if (!$result) {
         $cron->writeLine("ERROR");
         $fnHash = MyUtil::fnOk(false, "SQL Error getting Session Info", null);
     } else {
         while ($row = pg_fetch_assoc($result)) {
             $cron->writeLine($row['minute'] . " " . $row['hour'] . " " . $row['day_of_month'] . " " . $row['month'] . " " . $row['day_of_week'] . " {$setSessionPath} " . $row['id']);
         }
         $rmCron = shell_exec('crontab -r');
         if ($rmCron != null) {
             $setCron = shell_exec('crontab $cron_file');
             if ($setCron != null) {
                 $delCronTmp = shell_exec('rm $cron_file');
                 if ($delCronTmp != null) {
                     $fnHash = MyUtil::fnOk(true, "Updated Cron and Session", null);
                 }
                 $fnHash = MyUtil::fnOk(false, "Cron Tmp File not Deleted", null);
             }
             $fnHash = MyUtil::fnOk(false, "Cron not set to tmp", null);
         } else {
             $fnHash = MyUtil::fnOk(false, "Original cron not deleted", null);
         }
         return $fnHash;
     }
     return $fnHash;
 }
开发者ID:jls14,项目名称:SpireSessions,代码行数:33,代码来源:Crontab.php


示例2: getWinningVideoId

 public static function getWinningVideoId($id)
 {
     $logger = new FileWriter('win_id_log', 'a');
     if (!is_integer($id) || $id <= 0) {
         $fnOk = MyUtil::fnOk(false, "Invalid Session ID: {$id}" . !is_integer($id) . "-" . ($id <= 0), null);
         $logger->writeLog($fnOk['reason']);
         return $fnOk;
     }
     $stm = "SELECT COALESCE(winner_video_id, 0) as winner_video_id FROM " . self::$table_name . " WHERE id = {$id}";
     $logger->writeLog($stm);
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     $row = pg_fetch_assoc($result);
     if ($row['winner_video_id'] > 0) {
         return MyUtil::fnOk(true, "Video Id Found", $row['winner_video_id']);
     } else {
         $stm = " SELECT COALESCE(id, 0) as winner_video_id " . " FROM spire.videos " . " WHERE session_id = {$id} " . "  AND votes = (SELECT MAX(votes) FROM spire.videos WHERE session_id = {$id})";
         $logger->writeLog($stm);
         $result = ConnDB::query_db($stm);
         if (!$result) {
             return MyUtil::fnOk(false, "SQL Error", null);
         }
         $row = pg_fetch_assoc($result);
         if ($row['winner_video_id'] > 0) {
             return MyUtil::fnOk(true, "Video Id Found", $row['winner_video_id']);
         } else {
             return MyUtil::fnOk(false, "Video Id Not Found", null);
         }
     }
 }
开发者ID:jls14,项目名称:SpireSessions,代码行数:32,代码来源:SessionDAO.php


示例3: testWriter

 public function testWriter()
 {
     $filename = tempnam(sys_get_temp_dir(), 'phpwriter');
     $writer = new FileWriter($filename);
     $writer->write('some text');
     $writer->close();
     $this->assertEquals('some text', file_get_contents($filename));
     // clean up temp file
     unlink($filename);
 }
开发者ID:jrdnull,项目名称:phpwriter,代码行数:10,代码来源:FileWriterTest.php


示例4: connect

 /**
  * Returns routes to connect to the given application.
  *
  * @param Application $app An Application instance
  *
  * @return ControllerCollection A ControllerCollection instance
  */
 public function connect(Application $app)
 {
     $controllers = $app['controllers_factory'];
     $controllers->get('{_locale}', function ($_locale) use($app) {
         $directoryTrans = __DIR__ . '/../../../../../../app/trans/en.json';
         $oldCatalogue = new DataCatalogue();
         $oldCatalogue->load($directoryTrans, 'json', 'en');
         $extractor = new FileExtractor($this->twig);
         $catalogue = $extractor->extract();
         $fileWriter = new FileWriter();
         $fileWriter->write($catalogue, $directoryTrans, 'json');
         return $app['twig']->render('Demo/Default/test.html.twig');
     })->bind('blueLinesHome');
     return $controllers;
 }
开发者ID:selmanouni,项目名称:blue-lines,代码行数:22,代码来源:DefaultControllerProvider.php


示例5: save

 public static function save(Utility $utility)
 {
     $file = UTILITIES . "/{$utility->name}";
     FileWriter::write($file, $utility->body, Symphony::Configuration()->core()->symphony->{'file-write-mode'});
     //General::writeFile($file, $utility->body,Symphony::Configuration()->core()->symphony->{'file-write-mode'});
     return file_exists($file);
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:7,代码来源:class.utility.php


示例6: mergeBehaviorChangesIfIncludeEmptyValuesIsFalse

 /**
  *
  * @test
  */
 public function mergeBehaviorChangesIfIncludeEmptyValuesIsFalse()
 {
     $testString1 = 'extConf';
     // install tool is empty in local configuration, leave remote setting intact...
     $testString2 = "'installToolPassword' => '2ccbdfbea4716a57da75f4c8e8d651ac',";
     $this->fileWriter->expects($this->once())->method('write')->with($this->logicalAnd($this->stringContains($testString1), $this->stringContains($testString2)));
     $this->task->setBase($this->base);
     $this->task->setUpdate($this->update);
     $this->task->setIncludeEmptyValues(FALSE);
     $this->task->addFileWriter($this->fileWriter);
     $this->task->main();
 }
开发者ID:dreadlabs,项目名称:typo3-cms-phing-helper,代码行数:16,代码来源:MergeLocalConfigurationTaskTest.php


示例7: CreateSongFile

 private function CreateSongFile($title, $artist, $viewModel)
 {
     if (strlen($title) < 1) {
         $viewModel->HasErrors = true;
         $viewModel->Message = 'Song title is required, sorry.';
         return false;
     }
     try {
         $fWriter = new FileWriter();
         $viewModel->Id = $fWriter->MakeFile($title, $artist);
         $viewModel->HasErrors = strlen($viewModel->Id) < 1;
         if ($viewModel->HasErrors) {
             $viewModel->Message = '(e:803) Something\'s gone wrong whilst saving.';
             return false;
         }
     } catch (Exception $e) {
         $viewModel->Message = '(e:805) Something\'s gone wrong whilst saving.';
         return false;
     }
     $viewModel->ContinueUri = Ugs::MakeUri(Actions::Edit, $viewModel->Id);
     return true;
 }
开发者ID:hikusukih,项目名称:UkeGeeks,代码行数:22,代码来源:Ajax_NewSong_Vmb.php


示例8: transform

 private function transform(DOMDocument $document)
 {
     $dir = new PhingFile($this->toDir);
     if (!$dir->exists()) {
         throw new BuildException("Directory '" . $this->toDir . "' does not exist");
     }
     $xslfile = $this->getStyleSheet();
     $xsl = new DOMDocument();
     $xsl->load($xslfile->getAbsolutePath());
     $proc = new XSLTProcessor();
     $proc->importStyleSheet($xsl);
     if ($this->format == "noframes") {
         $writer = new FileWriter(new PhingFile($this->toDir, "checkstyle-noframes.html"));
         $writer->write($proc->transformToXML($document));
         $writer->close();
     } else {
         ExtendedFileStream::registerStream();
         // no output for the framed report
         // it's all done by extension...
         $dir = new PhingFile($this->toDir);
         $proc->setParameter('', 'output.dir', $dir->getAbsolutePath());
         $proc->transformToXML($document);
     }
 }
开发者ID:hellogerard,项目名称:pox-framework,代码行数:24,代码来源:CheckstyleReportTask.php


示例9: export_table_csv_utf8

 /**
  * Export tabular data to CSV-file
  * @param array $data
  * @param string $filename
  */
 public static function export_table_csv_utf8($data, $filename = 'export')
 {
     if (empty($data)) {
         return false;
     }
     $path = Chamilo::temp_file();
     $converter = new Utf8Encoder(null, true);
     $file = FileWriter::create($path, $converter);
     $file = CsvWriter::create($file);
     foreach ($data as $row) {
         $file->put($row);
     }
     $file->close();
     DocumentManager::file_send_for_download($path, false, $filename . '.csv');
     unlink($path);
     exit;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:22,代码来源:export.lib.inc.php


示例10: main

 public function main()
 {
     if (NULL === $this->base) {
         throw new BuildException('You must specify the base file!');
     }
     if (NULL === $this->update) {
         throw new BuildException('You must specify the update file!');
     }
     $baseConfiguration = (array) (include $this->base->getAbsolutePath());
     $updateConfiguration = (array) (include $this->update->getAbsolutePath());
     $mergedConfiguration = ArrayUtility::array_merge_recursive_overrule($baseConfiguration, $updateConfiguration, FALSE, $this->includeEmptyValues);
     $configuration = new ConfigurationUtility($mergedConfiguration);
     $phpCode = $configuration->getLocalConfigurationArray();
     if (NULL === $this->fileWriter) {
         $this->addFileWriter();
     }
     $this->fileWriter->write($phpCode);
     $this->fileWriter->close();
 }
开发者ID:dreadlabs,项目名称:typo3-cms-phing-helper,代码行数:19,代码来源:MergeLocalConfigurationTask.php


示例11: ServletContext

 function ServletContext($web_xml_file)
 {
     $web_xml_file = new File($web_xml_file);
     if (File::validClass($web_xml_file) && $web_xml_file->exists()) {
         $this->file =& $web_xml_file;
         $cache_file = new File($web_xml_file->getFilePath() . 'cached');
         $valid_cache = FALSE;
         if ($cache_file->exists() && $web_xml_file->lastModified() == $cache_file->lastModified()) {
             $this->config = @unserialize(FileReader::readFileContent($cache_file));
             if (ServletContext::validClass($this->config)) {
                 $valid_cache = TRUE;
             }
         }
         if (!$valid_cache) {
             $this->config =& ServletXMLConfigReader::readXMLConfig(new FileReader($web_xml_file));
             FileWriter::writeToFile($cache_file, serialize($this->config), $web_xml_file->lastModified());
         }
     }
     if (isset($this->config)) {
         $this->initServletContext();
     }
 }
开发者ID:alexpagnoni,项目名称:jphp,代码行数:22,代码来源:ServletContext.php


示例12: store

 /**
  * Stores current properties to specified file.
  * 
  * @param PhingFile $file File to create/overwrite with properties.
  * @param string $header Header text that will be placed (within comments) at the top of properties file.
  * @return void
  * @throws IOException - on error writing properties file.
  */
 function store(PhingFile $file = null, $header = null)
 {
     if ($file == null) {
         $file = $this->file;
     }
     if ($file == null) {
         throw new IOException("Unable to write to empty filename");
     }
     // stores the properties in this object in the file denoted
     // if file is not given and the properties were loaded from a
     // file prior, this method stores them in the file used by load()
     try {
         $fw = new FileWriter($file);
         if ($header !== null) {
             $fw->write("# " . $header . PHP_EOL);
         }
         $fw->write($this->toString());
         $fw->close();
     } catch (IOException $e) {
         throw new IOException("Error writing property file: " . $e->getMessage());
     }
 }
开发者ID:namesco,项目名称:phing,代码行数:30,代码来源:Properties.php


示例13: main

 /**
  * Execute the input script with Velocity
  *
  * @throws BuildException
  *                        BuildExceptions are thrown when required attributes are missing.
  *                        Exceptions thrown by Velocity are rethrown as BuildExceptions.
  */
 public function main()
 {
     // Make sure the template path is set.
     if (empty($this->templatePath)) {
         throw new BuildException("The template path needs to be defined!");
     }
     // Make sure the control template is set.
     if ($this->controlTemplate === null) {
         throw new BuildException("The control template needs to be defined!");
     }
     // Make sure the output directory is set.
     if ($this->outputDirectory === null) {
         throw new BuildException("The output directory needs to be defined!");
     }
     // Make sure there is an output file.
     if ($this->outputFile === null) {
         throw new BuildException("The output file needs to be defined!");
     }
     // Setup Smarty runtime.
     // Smarty uses one object to store properties and to store
     // the context for the template (unlike Velocity).  We setup this object, calling it
     // $this->context, and then initControlContext simply zeros out
     // any assigned variables.
     //
     // Use the smarty backwards compatibility layer if existent.
     if (class_exists('SmartyBC')) {
         $this->context = new SmartyBC();
     } else {
         $this->context = new Smarty();
     }
     if ($this->compilePath !== null) {
         $this->log("Using compilePath: " . $this->compilePath);
         $this->context->compile_dir = $this->compilePath;
     }
     if ($this->configPath !== null) {
         $this->log("Using configPath: " . $this->configPath);
         $this->context->config_dir = $this->configPath;
     }
     if ($this->forceCompile !== null) {
         $this->context->force_compile = $this->forceCompile;
     }
     if ($this->leftDelimiter !== null) {
         $this->context->left_delimiter = $this->leftDelimiter;
     }
     if ($this->rightDelimiter !== null) {
         $this->context->right_delimiter = $this->rightDelimiter;
     }
     if ($this->templatePath !== null) {
         $this->log("Using templatePath: " . $this->templatePath);
         $this->context->template_dir = $this->templatePath;
     }
     $smartyCompilePath = new PhingFile($this->context->compile_dir);
     if (!$smartyCompilePath->exists()) {
         $this->log("Compile directory does not exist, creating: " . $smartyCompilePath->getPath(), Project::MSG_VERBOSE);
         if (!$smartyCompilePath->mkdirs()) {
             throw new BuildException("Smarty needs a place to compile templates; specify a 'compilePath' or create " . $this->context->compile_dir);
         }
     }
     // Make sure the output directory exists, if it doesn't
     // then create it.
     $file = new PhingFile($this->outputDirectory);
     if (!$file->exists()) {
         $this->log("Output directory does not exist, creating: " . $file->getAbsolutePath());
         $file->mkdirs();
     }
     $path = $this->outputDirectory . DIRECTORY_SEPARATOR . $this->outputFile;
     $this->log("Generating to file " . $path);
     $writer = new FileWriter($path);
     // The generator and the output path should
     // be placed in the init context here and
     // not in the generator class itself.
     $c = $this->initControlContext();
     // Set any variables that need to always
     // be loaded
     $this->populateInitialContext($c);
     // Feed all the options into the initial
     // control context so they are available
     // in the control/worker templates.
     if ($this->contextProperties !== null) {
         foreach ($this->contextProperties->keys() as $property) {
             $value = $this->contextProperties->getProperty($property);
             // Special exception (from Texen)
             // for properties ending in file.contents:
             // in that case we dump the contents of the file
             // as the "value" for the Property.
             if (StringHelper::endsWith("file.contents", $property)) {
                 // pull in contents of file specified
                 $property = substr($property, 0, strpos($property, "file.contents") - 1);
                 // reset value, and then
                 // read in teh contents of the file into that var
                 $value = "";
                 $f = new PhingFile($this->project->resolveFile($value)->getCanonicalPath());
                 if ($f->exists()) {
//.........这里部分代码省略.........
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:101,代码来源:SmartyTask.php


示例14: transform

 /**
  * Transforms the DOM document
  */
 protected function transform(DOMDocument $document)
 {
     if (!$this->toDir->exists()) {
         throw new BuildException("Directory '" . $this->toDir . "' does not exist");
     }
     $xslfile = $this->getStyleSheet();
     $xsl = new DOMDocument();
     $xsl->load($xslfile->getAbsolutePath());
     $proc = new XSLTProcessor();
     if (defined('XSL_SECPREF_WRITE_FILE')) {
         if (version_compare(PHP_VERSION, '5.4', "<")) {
             ini_set("xsl.security_prefs", XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
         } else {
             $proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
         }
     }
     $proc->importStyleSheet($xsl);
     $proc->setParameter('', 'output.sorttable', $this->useSortTable);
     if ($this->format == "noframes") {
         $writer = new FileWriter(new PhingFile($this->toDir, "phpunit-noframes.html"));
         $writer->write($proc->transformToXML($document));
         $writer->close();
     } else {
         ExtendedFileStream::registerStream();
         $toDir = (string) $this->toDir;
         // urlencode() the path if we're on Windows
         if (FileSystem::getFileSystem()->getSeparator() == '\\') {
             $toDir = urlencode($toDir);
         }
         // no output for the framed report
         // it's all done by extension...
         $proc->setParameter('', 'output.dir', $toDir);
         $proc->transformToXML($document);
         ExtendedFileStream::unregisterStream();
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:39,代码来源:PHPUnitReportTask.php


示例15: store

 /**
  * Stores current properties to specified file.
  * 
  * @param PhingFile $file File to create/overwrite with properties.
  * @param string $header Header text that will be placed (within comments) at the top of properties file.
  * @return void
  * @throws IOException - on error writing properties file.
  */
 function store(PhingFile $file, $header = null)
 {
     // stores the properties in this object in the file denoted
     // if file is not given and the properties were loaded from a
     // file prior, this method stores them in the file used by load()
     try {
         $fw = new FileWriter($file);
         $fw->open();
         if ($header !== null) {
             $fw->write("# " . $header . Phing::getProperty("line.separator"));
         }
         $fw->write($this->toString());
         $fw->close();
     } catch (IOException $e) {
         throw new IOException("Error writing property file: " . $e->getMessage());
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:25,代码来源:Properties.php


示例16: main

 /**
  * Execute lint check against PhingFile or a FileSet
  */
 public function main()
 {
     if (!isset($this->file) and count($this->filesets) == 0) {
         throw new BuildException("Missing either a nested fileset or attribute 'file' set");
     }
     if ($this->file instanceof PhingFile) {
         $this->lint($this->file->getPath());
     } else {
         // process filesets
         $project = $this->getProject();
         foreach ($this->filesets as $fs) {
             $ds = $fs->getDirectoryScanner($project);
             $files = $ds->getIncludedFiles();
             $dir = $fs->getDir($this->project)->getPath();
             foreach ($files as $file) {
                 $this->lint($dir . DIRECTORY_SEPARATOR . $file);
             }
         }
     }
     // write list of 'bad files' to file (if specified)
     if ($this->tofile) {
         $writer = new FileWriter($this->tofile);
         foreach ($this->badFiles as $file => $messages) {
             foreach ($messages as $msg) {
                 $writer->write($file . "=" . $msg . PHP_EOL);
             }
         }
         $writer->close();
     }
     // save list of 'bad files' with errors to property errorproperty (if specified)
     if ($this->errorProperty) {
         $message = '';
         foreach ($this->badFiles as $file => $messages) {
             foreach ($messages as $msg) {
                 $message .= $file . "=" . $msg . PHP_EOL;
             }
         }
         $this->project->setProperty($this->errorProperty, $message);
     }
     if ($this->haltOnFailure && $this->hasErrors) {
         throw new BuildException('Syntax error(s) in PHP files: ' . implode(', ', $this->badFiles));
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:46,代码来源:PhpLintTask.php


示例17: main

 /**
  * Default constructor.
  * @return     void
  * @throws     BuildException
  */
 public function main()
 {
     $this->log("Propel - CreoleToXMLSchema starting");
     $this->log("Your DB settings are:");
     $this->log("driver : " . ($this->dbDriver ? $this->dbDriver : "(default)"));
     $this->log("URL : " . $this->dbUrl);
     //(not yet supported) $this->log("schema : " . $this->dbSchema);
     //DocumentTypeImpl docType = new DocumentTypeImpl(null, "database", null,
     //	   "http://jakarta.apache.org/turbine/dtd/database.dtd");
     $this->doc = new DOMDocument('1.0', 'utf-8');
     $this->doc->formatOutput = true;
     // pretty printing
     $this->doc->appendChild($this->doc->createComment("Autogenerated by CreoleToXMLSchema!"));
     try {
         $this->generateXML();
         $this->log("Writing XML to file: " . $this->xmlSchema);
         $outFile = new PhingFile($this->xmlSchema);
         $out = new FileWriter($outFile);
         $xmlstr = $this->doc->saveXML();
         $out->write($xmlstr);
         $out->close();
     } catch (Exception $e) {
         $this->log("There was an error building XML from metadata: " . $e->getMessage(), PROJECT_MSG_ERR);
     }
     $this->log("Propel - CreoleToXMLSchema finished");
 }
开发者ID:nmicht,项目名称:tlalokes-in-acst,代码行数:31,代码来源:PropelCreoleTransformTask.php


示例18: main

 /**
  * Execute lint check against PhingFile or a FileSet
  */
 public function main()
 {
     if (!isset($this->file) and count($this->filesets) == 0) {
         throw new BuildException("Missing either a nested fileset or attribute 'file' set");
     }
     exec($this->executable, $output);
     if (!preg_match('/JavaScript\\sLint/', implode('', $output))) {
         throw new BuildException('Javascript Lint not found');
     }
     if ($this->file instanceof PhingFile) {
         $this->lint($this->file->getPath());
     } else {
         // process filesets
         $project = $this->getProject();
         foreach ($this->filesets as $fs) {
             $ds = $fs->getDirectoryScanner($project);
             $files = $ds->getIncludedFiles();
             $dir = $fs->getDir($this->project)->getPath();
             foreach ($files as $file) {
                 $this->lint($dir . DIRECTORY_SEPARATOR . $file);
             }
         }
     }
     // write list of 'bad files' to file (if specified)
     if ($this->tofile) {
         $writer = new FileWriter($this->tofile);
         foreach ($this->badFiles as $file => $messages) {
             foreach ($messages as $msg) {
                 $writer->write($file . "=" . $msg . PHP_EOL);
             }
         }
         $writer->close();
     }
     if ($this->haltOnFailure && $this->hasErrors) {
         throw new BuildException('Syntax error(s) in JS files:' . implode(', ', array_keys($this->badFiles)));
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:40,代码来源:JslLintTask.php


示例19: appendFile

 private function appendFile(FileWriter $writer, PhingFile $f)
 {
     $in = FileUtils::getChainedReader(new FileReader($f), $this->filterChains, $this->project);
     while (-1 !== ($buffer = $in->read())) {
         // -1 indicates EOF
         $writer->write($buffer);
     }
     $this->log("Appending contents of " . $f->getPath() . " to " . $this->to->getPath());
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:9,代码来源:AppendTask.php


示例20: main

 /** Append the file(s). */
 function main()
 {
     if ($this->file === null && empty($this->filesets)) {
         throw new BuildException("You must specify a file or fileset(s) for the <reflexive> task.");
     }
     // compile a list of all files to modify, both file attrib and fileset elements
     // can be used.
     $files = array();
     if ($this->file !== null) {
         $files[] = $this->file;
     }
     if (!empty($this->filesets)) {
         $filenames = array();
         foreach ($this->filesets as $fs) {
             try {
                 $ds = $fs->getDirectoryScanner($this->project);
                 $filenames = $ds->getIncludedFiles();
                 // get included filenames
                 $dir = $fs->getDir($this->project);
                 foreach ($filenames as $fname) {
                     $files[] = new PhingFile($dir, $fname);
                 }
             } catch (BuildException $be) {
                 $this->log($be->getMessage(), Project::MSG_WARN);
             }
         }
     }
     $this->log("Applying reflexive processing to " . count($files) . " files.");
     // These "slots" allow filters to retrieve information about the currently-being-process files
     $slot = $this->getRegisterSlot("currentFile");
     $basenameSlot = $this->getRegisterSlot("currentFile.basename");
     foreach ($files as $file) {
         // set the register slots
         $slot->setValue($file->getPath());
         $basenameSlot->setValue($file->getName());
         // 1) read contents of file, pulling through any filters
         $in = null;
         try {
             $contents = "";
             $in = FileUtils::getChainedReader(new FileReader($file), $this->filterChains, $this->project);
             while (-1 !== ($buffer = $in->read())) {
                 $contents .= $buffer;
             }
             $in->close();
         } catch (Exception $e) {
             if ($in) {
                 $in->close();
             }
             $this->log("Erorr reading file: " . $e->getMessage(), Project::MSG_WARN);
         }
         try {
             // now create a FileWriter w/ the same file, and write to the file
             $out = new FileWriter($file);
             $out->write($contents);
             $out->close();
             $this->log("Applying reflexive processing to " . $file->getPath(), Project::MSG_VERBOSE);
         } catch (Exception $e) {
             if ($out) {
                 $out->close();
             }
             $this->log("Error writing file back: " . $e->getMessage(), Project::MSG_WARN);
         }
     }
 }
开发者ID:andrew-ejov,项目名称:start-template,代码行数:65,代码来源:ReflexiveTask.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP File_Archive类代码示例发布时间:2022-05-23
下一篇:
PHP FileUtils类代码示例发布时间: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