Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.

Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
This commit is contained in:
Clinton Stimpson 2014-01-03 22:47:13 -07:00 committed by Brad King
parent 7fb2b80662
commit 5730710c86
75 changed files with 292 additions and 228 deletions

View File

@ -11,8 +11,8 @@
============================================================================*/ ============================================================================*/
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/ios/fstream>
#include <cmsys/ios/iostream> #include <cmsys/ios/iostream>
#include <cmsys/FStream.hxx>
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
@ -27,7 +27,7 @@ int main(int argc, char* argv[])
{ {
//if ( cmsys::SystemTools::FileExists( //if ( cmsys::SystemTools::FileExists(
cmsys_stl::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory(); cmsys_stl::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
cmsys_ios::ofstream ofs("/tmp/output.txt"); cmsys::ofstream ofs("/tmp/output.txt");
CFStringRef fileName; CFStringRef fileName;
CFBundleRef appBundle; CFBundleRef appBundle;

View File

@ -24,6 +24,7 @@
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Encoding.hxx> #include <cmsys/Encoding.hxx>
#include <cmsys/FStream.hxx>
#include <rpc.h> // for GUID generation #include <rpc.h> // for GUID generation
@ -56,7 +57,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output, bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&returnValue, 0, cmSystemTools::OUTPUT_NONE); &returnValue, 0, cmSystemTools::OUTPUT_NONE);
std::ofstream logFile(logFileName.c_str(), std::ios::app); cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
logFile << command << std::endl; logFile << command << std::endl;
logFile << output; logFile << output;
logFile.close(); logFile.close();
@ -838,7 +839,7 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
{ {
cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename); cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename);
std::ifstream licenseSource(licenseSourceFilename.c_str()); cmsys::ifstream licenseSource(licenseSourceFilename.c_str());
std::string line; std::string line;
while(std::getline(licenseSource, line)) while(std::getline(licenseSource, line))

View File

@ -13,7 +13,7 @@
#ifndef cmWIXRichTextFormatWriter_h #ifndef cmWIXRichTextFormatWriter_h
#define cmWIXRichTextFormatWriter_h #define cmWIXRichTextFormatWriter_h
#include <fstream> #include <cmsys/FStream.hxx>
/** \class cmWIXRichtTextFormatWriter /** \class cmWIXRichtTextFormatWriter
* \brief Helper class to generate Rich Text Format (RTF) documents * \brief Helper class to generate Rich Text Format (RTF) documents
@ -46,7 +46,7 @@ private:
void EmitInvalidCodepoint(int c); void EmitInvalidCodepoint(int c);
std::ofstream File; cmsys::ofstream File;
}; };
#endif #endif

View File

@ -15,7 +15,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <fstream> #include <cmsys/FStream.hxx>
#include <CPack/cmCPackLog.h> #include <CPack/cmCPackLog.h>
@ -60,7 +60,7 @@ private:
cmCPackLog* Logger; cmCPackLog* Logger;
std::ofstream File; cmsys::ofstream File;
State State; State State;

View File

@ -803,7 +803,7 @@ static int put_arobj(CF *cfp, struct stat *sb)
static int ar_append(const char* archive,const std::vector<std::string>& files) static int ar_append(const char* archive,const std::vector<std::string>& files)
{ {
int eval = 0; int eval = 0;
FILE* aFile = fopen(archive, "wb+"); FILE* aFile = cmSystemTools::Fopen(archive, "wb+");
if (aFile!=NULL) { if (aFile!=NULL) {
fwrite(ARMAG, SARMAG, 1, aFile); fwrite(ARMAG, SARMAG, 1, aFile);
if (fseek(aFile, 0, SEEK_END) != -1) { if (fseek(aFile, 0, SEEK_END) != -1) {
@ -814,7 +814,7 @@ static int ar_append(const char* archive,const std::vector<std::string>& files)
for(std::vector<std::string>::const_iterator fileIt = files.begin(); for(std::vector<std::string>::const_iterator fileIt = files.begin();
fileIt!=files.end(); ++fileIt) { fileIt!=files.end(); ++fileIt) {
const char* filename = fileIt->c_str(); const char* filename = fileIt->c_str();
FILE* file = fopen(filename, "rb"); FILE* file = cmSystemTools::Fopen(filename, "rb");
if (file == NULL) { if (file == NULL) {
eval = -1; eval = -1;
continue; continue;

View File

@ -16,6 +16,7 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
static const char* SLAHeader = static const char* SLAHeader =
"data 'LPic' (5000) {\n" "data 'LPic' (5000) {\n"
@ -422,7 +423,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
sla_r += "/sla.r"; sla_r += "/sla.r";
std::ifstream ifs; cmsys::ifstream ifs;
ifs.open(cpack_license_file.c_str()); ifs.open(cpack_license_file.c_str());
if(ifs.is_open()) if(ifs.is_open())
{ {

View File

@ -23,6 +23,7 @@
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
#include <algorithm> #include <algorithm>
#if defined(__HAIKU__) #if defined(__HAIKU__)
@ -152,7 +153,7 @@ int cmCPackGenerator::PrepareNames()
<< descFileName << "]" << std::endl); << descFileName << "]" << std::endl);
return 0; return 0;
} }
std::ifstream ifs(descFileName); cmsys::ifstream ifs(descFileName);
if ( !ifs ) if ( !ifs )
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,

View File

@ -22,6 +22,7 @@
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator() cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator()
@ -467,7 +468,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
return 0; return 0;
} }
std::ifstream ifs(versionFile.c_str()); cmsys::ifstream ifs(versionFile.c_str());
if ( !ifs ) if ( !ifs )
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
@ -716,7 +717,7 @@ GenerateComponentPackage(const char *packageFile,
// X packages, which work on Mac OS X 10.3 and newer. // X packages, which work on Mac OS X 10.3 and newer.
std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
descriptionFile += '/' + component.Name + "-Description.plist"; descriptionFile += '/' + component.Name + "-Description.plist";
std::ofstream out(descriptionFile.c_str()); cmsys::ofstream out(descriptionFile.c_str());
out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
<< "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"" << "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
<< "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" << std::endl << "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" << std::endl

View File

@ -20,6 +20,7 @@
#include "cmCPackLog.h" #include "cmCPackLog.h"
#include <cmsys/ios/sstream> #include <cmsys/ios/sstream>
#include <cmsys/FStream.hxx>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -91,7 +92,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
std::string inLicFile = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); std::string inLicFile = this->GetOption("CPACK_RESOURCE_FILE_LICENSE");
std::string line; std::string line;
std::ifstream ilfs(inLicFile.c_str()); cmsys::ifstream ilfs(inLicFile.c_str());
std::string licenseText; std::string licenseText;
while ( cmSystemTools::GetLineFromStream(ilfs, line) ) while ( cmSystemTools::GetLineFromStream(ilfs, line) )
{ {
@ -104,7 +105,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
// Create the header // Create the header
std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE"); std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE");
std::ifstream ifs(inFile.c_str()); cmsys::ifstream ifs(inFile.c_str());
std::string packageHeaderText; std::string packageHeaderText;
while ( cmSystemTools::GetLineFromStream(ifs, line) ) while ( cmSystemTools::GetLineFromStream(ifs, line) )
{ {

View File

@ -24,6 +24,7 @@
//#include <cmsys/RegularExpression.hxx> //#include <cmsys/RegularExpression.hxx>
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
// used for sleep // used for sleep
#ifdef _WIN32 #ifdef _WIN32
@ -751,7 +752,7 @@ void cmCTestBuildHandler::GenerateXMLFooter(std::ostream& os,
void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os, void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os,
const char* fname) const char* fname)
{ {
std::ifstream fin(fname, std::ios::in | std::ios::binary); cmsys::ifstream fin(fname, std::ios::in | std::ios::binary);
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
{ {
@ -885,7 +886,7 @@ cmCTestBuildHandler::LaunchHelper
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTestBuildHandler::RunMakeCommand(const char* command, int cmCTestBuildHandler::RunMakeCommand(const char* command,
int* retVal, const char* dir, int timeout, std::ofstream& ofs) int* retVal, const char* dir, int timeout, std::ostream& ofs)
{ {
// First generate the command and arguments // First generate the command and arguments
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
@ -1049,7 +1050,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
size_t& tick, size_t tick_len, std::ofstream& ofs, size_t& tick, size_t tick_len, std::ostream& ofs,
t_BuildProcessingQueueType* queue) t_BuildProcessingQueueType* queue)
{ {
const std::string::size_type tick_line_len = 50; const std::string::size_type tick_line_len = 50;

View File

@ -54,7 +54,7 @@ private:
// and retVal is return value or exception. // and retVal is return value or exception.
int RunMakeCommand(const char* command, int RunMakeCommand(const char* command,
int* retVal, const char* dir, int timeout, int* retVal, const char* dir, int timeout,
std::ofstream& ofs); std::ostream& ofs);
enum { enum {
b_REGULAR_LINE, b_REGULAR_LINE,
@ -113,7 +113,7 @@ private:
typedef std::deque<char> t_BuildProcessingQueueType; typedef std::deque<char> t_BuildProcessingQueueType;
void ProcessBuffer(const char* data, int length, size_t& tick, void ProcessBuffer(const char* data, int length, size_t& tick,
size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue); size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue);
int ProcessSingleLine(const char* data); int ProcessSingleLine(const char* data);
t_BuildProcessingQueueType BuildProcessingQueue; t_BuildProcessingQueueType BuildProcessingQueue;

View File

@ -16,6 +16,7 @@
#include "cmXMLSafe.h" #include "cmXMLSafe.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log) cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
@ -231,7 +232,7 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
// Lookup the branch in the tag file, if any. // Lookup the branch in the tag file, if any.
std::string tagLine; std::string tagLine;
std::ifstream tagStream(tagFile.c_str()); cmsys::ifstream tagStream(tagFile.c_str());
if(tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) && if(tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
tagLine.size() > 1 && tagLine[0] == 'T') tagLine.size() > 1 && tagLine[0] == 'T')
{ {

View File

@ -26,6 +26,7 @@
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/stl/iterator> #include <cmsys/stl/iterator>
#include <cmsys/stl/algorithm> #include <cmsys/stl/algorithm>
#include <cmsys/FStream.hxx>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
@ -511,7 +512,7 @@ int cmCTestCoverageHandler::ProcessHandler()
<< "\" FullPath=\"" << cmXMLSafe(shortFileName) << "\">\n" << "\" FullPath=\"" << cmXMLSafe(shortFileName) << "\">\n"
<< "\t\t<Report>" << std::endl; << "\t\t<Report>" << std::endl;
std::ifstream ifs(fullFileName.c_str()); cmsys::ifstream ifs(fullFileName.c_str());
if ( !ifs) if ( !ifs)
{ {
cmOStringStream ostr; cmOStringStream ostr;
@ -600,7 +601,7 @@ int cmCTestCoverageHandler::ProcessHandler()
<< "\" FullPath=\"" << cmXMLSafe(*i) << "\">\n" << "\" FullPath=\"" << cmXMLSafe(*i) << "\">\n"
<< "\t\t<Report>" << std::endl; << "\t\t<Report>" << std::endl;
std::ifstream ifs(fullPath.c_str()); cmsys::ifstream ifs(fullPath.c_str());
if (!ifs) if (!ifs)
{ {
cmOStringStream ostr; cmOStringStream ostr;
@ -1158,7 +1159,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in gcovFile: " cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in gcovFile: "
<< gcovFile << std::endl); << gcovFile << std::endl);
std::ifstream ifile(gcovFile.c_str()); cmsys::ifstream ifile(gcovFile.c_str());
if ( ! ifile ) if ( ! ifile )
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
@ -1370,7 +1371,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
= &cont->TotalCoverage[actualSourceFile]; = &cont->TotalCoverage[actualSourceFile];
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" in file: " << fileIt->c_str() << std::endl); " in file: " << fileIt->c_str() << std::endl);
std::ifstream ifile(fileIt->c_str()); cmsys::ifstream ifile(fileIt->c_str());
if ( ! ifile ) if ( ! ifile )
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
@ -1530,7 +1531,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
"covbr output in " << outputFile "covbr output in " << outputFile
<< std::endl); << std::endl);
// open the output file // open the output file
std::ifstream fin(outputFile.c_str()); cmsys::ifstream fin(outputFile.c_str());
if(!fin) if(!fin)
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
@ -1743,7 +1744,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
std::vector<std::string> coveredFiles; std::vector<std::string> coveredFiles;
std::vector<std::string> coveredFilesFullPath; std::vector<std::string> coveredFilesFullPath;
// Read and parse the summary output file // Read and parse the summary output file
std::ifstream fin(outputFile.c_str()); cmsys::ifstream fin(outputFile.c_str());
if(!fin) if(!fin)
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
@ -2012,7 +2013,7 @@ void cmCTestCoverageHandler::LoadLabels()
fileList += "/TargetDirectories.txt"; fileList += "/TargetDirectories.txt";
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" target directory list [" << fileList << "]\n"); " target directory list [" << fileList << "]\n");
std::ifstream finList(fileList.c_str()); cmsys::ifstream finList(fileList.c_str());
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(finList, line)) while(cmSystemTools::GetLineFromStream(finList, line))
{ {
@ -2026,7 +2027,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
LabelSet& dirLabels = this->TargetDirs[dir]; LabelSet& dirLabels = this->TargetDirs[dir];
std::string fname = dir; std::string fname = dir;
fname += "/Labels.txt"; fname += "/Labels.txt";
std::ifstream fin(fname.c_str()); cmsys::ifstream fin(fname.c_str());
if(!fin) if(!fin)
{ {
return; return;
@ -2080,7 +2081,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestCoverageHandler::WriteXMLLabels(std::ofstream& os, void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os,
std::string const& source) std::string const& source)
{ {
LabelMapType::const_iterator li = this->SourceLabels.find(source); LabelMapType::const_iterator li = this->SourceLabels.find(source);

View File

@ -132,7 +132,7 @@ private:
// Label reading and writing methods. // Label reading and writing methods.
void LoadLabels(); void LoadLabels();
void LoadLabels(const char* dir); void LoadLabels(const char* dir);
void WriteXMLLabels(std::ofstream& os, std::string const& source); void WriteXMLLabels(std::ostream& os, std::string const& source);
// Label-based filtering. // Label-based filtering.
std::set<int> LabelFilter; std::set<int> LabelFilter;

View File

@ -18,6 +18,7 @@
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/ios/sstream> #include <cmsys/ios/sstream>
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/FStream.hxx>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
@ -200,7 +201,7 @@ bool cmCTestGIT::UpdateByFetchAndReset()
std::string sha1; std::string sha1;
{ {
std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD"; std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD";
std::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
if(!fin) if(!fin)
{ {
this->Log << "Unable to open " << fetch_head << "\n"; this->Log << "Unable to open " << fetch_head << "\n";

View File

@ -19,6 +19,7 @@
#include <cmsys/MD5.h> #include <cmsys/MD5.h>
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv) cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
@ -171,7 +172,7 @@ void cmCTestLaunch::HandleRealArg(const char* arg)
// Expand response file arguments. // Expand response file arguments.
if(arg[0] == '@' && cmSystemTools::FileExists(arg+1)) if(arg[0] == '@' && cmSystemTools::FileExists(arg+1))
{ {
std::ifstream fin(arg+1); cmsys::ifstream fin(arg+1);
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
{ {
@ -241,8 +242,8 @@ void cmCTestLaunch::RunChild()
cmsysProcess* cp = this->Process; cmsysProcess* cp = this->Process;
cmsysProcess_SetCommand(cp, this->RealArgV); cmsysProcess_SetCommand(cp, this->RealArgV);
std::ofstream fout; cmsys::ofstream fout;
std::ofstream ferr; cmsys::ofstream ferr;
if(this->Passthru) if(this->Passthru)
{ {
// In passthru mode we just share the output pipes. // In passthru mode we just share the output pipes.
@ -330,7 +331,7 @@ void cmCTestLaunch::LoadLabels()
cmSystemTools::ConvertToUnixSlashes(source); cmSystemTools::ConvertToUnixSlashes(source);
// Load the labels file. // Load the labels file.
std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
if(!fin) { return; } if(!fin) { return; }
bool inTarget = true; bool inTarget = true;
bool inSource = false; bool inSource = false;
@ -579,7 +580,7 @@ void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml)
void cmCTestLaunch::DumpFileToXML(std::ostream& fxml, void cmCTestLaunch::DumpFileToXML(std::ostream& fxml,
std::string const& fname) std::string const& fname)
{ {
std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line; std::string line;
const char* sep = ""; const char* sep = "";
@ -652,7 +653,7 @@ cmCTestLaunch
fname += "Custom"; fname += "Custom";
fname += purpose; fname += purpose;
fname += ".txt"; fname += ".txt";
std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line; std::string line;
cmsys::RegularExpression rex; cmsys::RegularExpression rex;
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
@ -671,7 +672,7 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname)
// Look for log file lines matching warning expressions but not // Look for log file lines matching warning expressions but not
// suppression expressions. // suppression expressions.
std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
{ {

View File

@ -18,6 +18,7 @@
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/Base64.h> #include <cmsys/Base64.h>
#include <cmsys/FStream.hxx>
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmXMLSafe.h" #include "cmXMLSafe.h"
@ -929,7 +930,7 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
} }
// put a scope around this to close ifs so the file can be removed // put a scope around this to close ifs so the file can be removed
{ {
std::ifstream ifs(ofile.c_str()); cmsys::ifstream ifs(ofile.c_str());
if ( !ifs ) if ( !ifs )
{ {
std::string log = "Cannot read memory tester output file: " + ofile; std::string log = "Cannot read memory tester output file: " + ofile;
@ -984,7 +985,7 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res,
{ {
return; return;
} }
std::ifstream ifs(ofile.c_str()); cmsys::ifstream ifs(ofile.c_str());
if ( !ifs ) if ( !ifs )
{ {
std::string log = "Cannot read memory tester output file: " + ofile; std::string log = "Cannot read memory tester output file: " + ofile;

View File

@ -17,6 +17,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stack> #include <stack>
#include <float.h> #include <float.h>
#include <cmsys/FStream.hxx>
class TestComparator class TestComparator
{ {
@ -325,7 +326,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
if(cmSystemTools::FileExists(fname.c_str())) if(cmSystemTools::FileExists(fname.c_str()))
{ {
std::ifstream fin; cmsys::ifstream fin;
fin.open(fname.c_str()); fin.open(fname.c_str());
std::string line; std::string line;
@ -384,7 +385,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
if(cmSystemTools::FileExists(fname.c_str(), true)) if(cmSystemTools::FileExists(fname.c_str(), true))
{ {
std::ifstream fin; cmsys::ifstream fin;
fin.open(fname.c_str()); fin.open(fname.c_str());
std::string line; std::string line;
while(std::getline(fin, line)) while(std::getline(fin, line))
@ -721,7 +722,7 @@ void cmCTestMultiProcessHandler::CheckResume()
<< "----------------------------------------------------------" << "----------------------------------------------------------"
<< std::endl; << std::endl;
std::ifstream fin; cmsys::ifstream fin;
fin.open(fname.c_str()); fin.open(fname.c_str());
std::string line; std::string line;
while(std::getline(fin, line)) while(std::getline(fin, line))

View File

@ -235,7 +235,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
return false; return false;
} }
ftpfile = ::fopen(local_file.c_str(), "rb"); ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
*this->LogFile << "\tUpload file: " << local_file.c_str() << " to " *this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
<< upload_as.c_str() << std::endl; << upload_as.c_str() << std::endl;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
@ -476,7 +476,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
return false; return false;
} }
ftpfile = ::fopen(local_file.c_str(), "rb"); ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
<< local_file.c_str() << " to " << local_file.c_str() << " to "
<< upload_as.c_str() << " Size: " << st.st_size << std::endl); << upload_as.c_str() << " Size: " << st.st_size << std::endl);
@ -566,7 +566,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
<< count << std::endl); << count << std::endl);
::fclose(ftpfile); ::fclose(ftpfile);
ftpfile = ::fopen(local_file.c_str(), "rb"); ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
chunk.clear(); chunk.clear();
@ -998,7 +998,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
return false; return false;
} }
size_t fileSize = static_cast<size_t>(st.st_size); size_t fileSize = static_cast<size_t>(st.st_size);
FILE* fp = fopen(local_file.c_str(), "rb"); FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
if ( !fp ) if ( !fp )
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: " cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: "

View File

@ -21,6 +21,7 @@
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/Base64.h> #include <cmsys/Base64.h>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
@ -931,7 +932,7 @@ void cmCTestTestHandler::UpdateMaxTestNameWidth()
bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag,
int& value, int& value,
std::ifstream& fin) std::istream& fin)
{ {
std::string line; std::string line;
bool ret = true; bool ret = true;
@ -953,7 +954,7 @@ bool cmCTestTestHandler::GetValue(const char* tag,
bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag,
double& value, double& value,
std::ifstream& fin) std::istream& fin)
{ {
std::string line; std::string line;
cmSystemTools::GetLineFromStream(fin, line); cmSystemTools::GetLineFromStream(fin, line);
@ -975,7 +976,7 @@ bool cmCTestTestHandler::GetValue(const char* tag,
bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag,
bool& value, bool& value,
std::ifstream& fin) std::istream& fin)
{ {
std::string line; std::string line;
cmSystemTools::GetLineFromStream(fin, line); cmSystemTools::GetLineFromStream(fin, line);
@ -1007,7 +1008,7 @@ bool cmCTestTestHandler::GetValue(const char* tag,
bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag,
size_t& value, size_t& value,
std::ifstream& fin) std::istream& fin)
{ {
std::string line; std::string line;
cmSystemTools::GetLineFromStream(fin, line); cmSystemTools::GetLineFromStream(fin, line);
@ -1029,7 +1030,7 @@ bool cmCTestTestHandler::GetValue(const char* tag,
bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag,
std::string& value, std::string& value,
std::ifstream& fin) std::istream& fin)
{ {
std::string line; std::string line;
cmSystemTools::GetLineFromStream(fin, line); cmSystemTools::GetLineFromStream(fin, line);
@ -1798,7 +1799,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
} }
// parse the list of tests to rerun from LastTestsFailed.log // parse the list of tests to rerun from LastTestsFailed.log
std::ifstream ifs(lastTestsFailedLog.c_str()); cmsys::ifstream ifs(lastTestsFailedLog.c_str());
if ( ifs ) if ( ifs )
{ {
std::string line; std::string line;
@ -1964,7 +1965,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
} }
else else
{ {
std::ifstream ifs(filename.c_str(), std::ios::in cmsys::ifstream ifs(filename.c_str(), std::ios::in
#ifdef _WIN32 #ifdef _WIN32
| std::ios::binary | std::ios::binary
#endif #endif
@ -2054,7 +2055,7 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
// string // string
if(cmSystemTools::FileExists(in)) if(cmSystemTools::FileExists(in))
{ {
std::ifstream fin(in); cmsys::ifstream fin(in);
unsigned long filelen = cmSystemTools::FileLength(in); unsigned long filelen = cmSystemTools::FileLength(in);
char* buff = new char[filelen+1]; char* buff = new char[filelen+1];
fin.getline(buff, filelen); fin.getline(buff, filelen);

View File

@ -227,19 +227,19 @@ private:
bool GetValue(const char* tag, bool GetValue(const char* tag,
std::string& value, std::string& value,
std::ifstream& fin); std::istream& fin);
bool GetValue(const char* tag, bool GetValue(const char* tag,
int& value, int& value,
std::ifstream& fin); std::istream& fin);
bool GetValue(const char* tag, bool GetValue(const char* tag,
size_t& value, size_t& value,
std::ifstream& fin); std::istream& fin);
bool GetValue(const char* tag, bool GetValue(const char* tag,
bool& value, bool& value,
std::ifstream& fin); std::istream& fin);
bool GetValue(const char* tag, bool GetValue(const char* tag,
double& value, double& value,
std::ifstream& fin); std::istream& fin);
/** /**
* Find the executable for a test * Find the executable for a test
*/ */

View File

@ -5,6 +5,7 @@
#include "cmParseCacheCoverage.h" #include "cmParseCacheCoverage.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
cmParseCacheCoverage::cmParseCacheCoverage( cmParseCacheCoverage::cmParseCacheCoverage(
@ -106,7 +107,7 @@ bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
bool cmParseCacheCoverage::ReadCMCovFile(const char* file) bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
{ {
std::ifstream in(file); cmsys::ifstream in(file);
if(!in) if(!in)
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,

View File

@ -5,6 +5,7 @@
#include "cmParseGTMCoverage.h" #include "cmParseGTMCoverage.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont, cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
@ -48,7 +49,7 @@ bool cmParseGTMCoverage::LoadCoverageData(const char* d)
bool cmParseGTMCoverage::ReadMCovFile(const char* file) bool cmParseGTMCoverage::ReadMCovFile(const char* file)
{ {
std::ifstream in(file); cmsys::ifstream in(file);
if(!in) if(!in)
{ {
return false; return false;
@ -127,7 +128,7 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath,
std::string const& function, std::string const& function,
int& lineoffset) int& lineoffset)
{ {
std::ifstream in(filepath.c_str()); cmsys::ifstream in(filepath.c_str());
if(!in) if(!in)
{ {
return false; return false;

View File

@ -5,6 +5,7 @@
#include "cmParseGTMCoverage.h" #include "cmParseGTMCoverage.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
cmParseMumpsCoverage::cmParseMumpsCoverage( cmParseMumpsCoverage::cmParseMumpsCoverage(
@ -23,7 +24,7 @@ bool cmParseMumpsCoverage::ReadCoverageFile(const char* file)
// Read the gtm_coverage.mcov file, that has two lines of data: // Read the gtm_coverage.mcov file, that has two lines of data:
// packages:/full/path/to/Vista/Packages // packages:/full/path/to/Vista/Packages
// coverage_dir:/full/path/to/dir/with/*.mcov // coverage_dir:/full/path/to/dir/with/*.mcov
std::ifstream in(file); cmsys::ifstream in(file);
if(!in) if(!in)
{ {
return false; return false;
@ -61,7 +62,7 @@ bool cmParseMumpsCoverage::ReadCoverageFile(const char* file)
void cmParseMumpsCoverage::InitializeMumpsFile(std::string& file) void cmParseMumpsCoverage::InitializeMumpsFile(std::string& file)
{ {
// initialize the coverage information for a given mumps file // initialize the coverage information for a given mumps file
std::ifstream in(file.c_str()); cmsys::ifstream in(file.c_str());
if(!in) if(!in)
{ {
return; return;

View File

@ -2,6 +2,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmParsePHPCoverage.h" #include "cmParsePHPCoverage.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
/* /*
To setup coverage for php. To setup coverage for php.
@ -20,7 +21,7 @@ cmParsePHPCoverage::cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont,
{ {
} }
bool cmParsePHPCoverage::ReadUntil(std::ifstream& in, char until) bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until)
{ {
char c = 0; char c = 0;
while(in.get(c) && c != until) while(in.get(c) && c != until)
@ -32,7 +33,7 @@ bool cmParsePHPCoverage::ReadUntil(std::ifstream& in, char until)
} }
return true; return true;
} }
bool cmParsePHPCoverage::ReadCoverageArray(std::ifstream& in, bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
cmStdString const& fileName) cmStdString const& fileName)
{ {
cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector
@ -109,7 +110,7 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::ifstream& in,
return true; return true;
} }
bool cmParsePHPCoverage::ReadInt(std::ifstream& in, int& v) bool cmParsePHPCoverage::ReadInt(std::istream& in, int& v)
{ {
std::string s; std::string s;
char c = 0; char c = 0;
@ -121,7 +122,7 @@ bool cmParsePHPCoverage::ReadInt(std::ifstream& in, int& v)
return true; return true;
} }
bool cmParsePHPCoverage::ReadArraySize(std::ifstream& in, int& size) bool cmParsePHPCoverage::ReadArraySize(std::istream& in, int& size)
{ {
char c = 0; char c = 0;
in.get(c); in.get(c);
@ -139,7 +140,7 @@ bool cmParsePHPCoverage::ReadArraySize(std::ifstream& in, int& size)
return false; return false;
} }
bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in) bool cmParsePHPCoverage::ReadFileInformation(std::istream& in)
{ {
char buf[4]; char buf[4];
in.read(buf, 2); in.read(buf, 2);
@ -190,7 +191,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in)
bool cmParsePHPCoverage::ReadPHPData(const char* file) bool cmParsePHPCoverage::ReadPHPData(const char* file)
{ {
std::ifstream in(file); cmsys::ifstream in(file);
if(!in) if(!in)
{ {
return false; return false;

View File

@ -32,11 +32,11 @@ public:
void PrintCoverage(); void PrintCoverage();
private: private:
bool ReadPHPData(const char* file); bool ReadPHPData(const char* file);
bool ReadArraySize(std::ifstream& in, int& size); bool ReadArraySize(std::istream& in, int& size);
bool ReadFileInformation(std::ifstream& in); bool ReadFileInformation(std::istream& in);
bool ReadInt(std::ifstream& in, int& v); bool ReadInt(std::istream& in, int& v);
bool ReadCoverageArray(std::ifstream& in, cmStdString const&); bool ReadCoverageArray(std::istream& in, cmStdString const&);
bool ReadUntil(std::ifstream& in, char until); bool ReadUntil(std::istream& in, char until);
cmCTestCoverageHandlerContainer& Coverage; cmCTestCoverageHandlerContainer& Coverage;
cmCTest* CTest; cmCTest* CTest;
}; };

View File

@ -3,7 +3,7 @@
#include "cmXMLParser.h" #include "cmXMLParser.h"
#include "cmParsePythonCoverage.h" #include "cmParsePythonCoverage.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class cmParsePythonCoverage::XMLParser: public cmXMLParser class cmParsePythonCoverage::XMLParser: public cmXMLParser
@ -35,7 +35,7 @@ protected:
atts[tagCount+1]; atts[tagCount+1];
FileLinesType& curFileLines = FileLinesType& curFileLines =
this->Coverage.TotalCoverage[this->CurFileName]; this->Coverage.TotalCoverage[this->CurFileName];
std::ifstream fin(this->CurFileName.c_str()); cmsys::ifstream fin(this->CurFileName.c_str());
if(!fin) if(!fin)
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,

View File

@ -11,7 +11,7 @@
============================================================================*/ ============================================================================*/
#include "cmCursesForm.h" #include "cmCursesForm.h"
std::ofstream cmCursesForm::DebugFile; cmsys::ofstream cmCursesForm::DebugFile;
bool cmCursesForm::Debug = false; bool cmCursesForm::Debug = false;
cmCursesForm::cmCursesForm() cmCursesForm::cmCursesForm()

View File

@ -14,6 +14,7 @@
#include "../cmStandardIncludes.h" #include "../cmStandardIncludes.h"
#include "cmCursesStandardIncludes.h" #include "cmCursesStandardIncludes.h"
#include <cmsys/FStream.hxx>
class cmCursesForm class cmCursesForm
{ {
@ -63,7 +64,7 @@ public:
protected: protected:
static std::ofstream DebugFile; static cmsys::ofstream DebugFile;
static bool Debug; static bool Debug;
cmCursesForm(const cmCursesForm& form); cmCursesForm(const cmCursesForm& form);

View File

@ -14,6 +14,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <cmsys/ios/iostream> #include <cmsys/ios/iostream>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
#include <cm_libarchive.h> #include <cm_libarchive.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -263,7 +264,7 @@ bool cmArchiveWrite::AddFile(const char* file,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmArchiveWrite::AddData(const char* file, size_t size) bool cmArchiveWrite::AddData(const char* file, size_t size)
{ {
std::ifstream fin(file, std::ios::in | cmsys_ios_binary); cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary);
if(!fin) if(!fin)
{ {
this->Error = "Error opening \""; this->Error = "Error opening \"";

View File

@ -19,6 +19,7 @@
#include <cmsys/Base64.h> #include <cmsys/Base64.h>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/SystemInformation.hxx> #include <cmsys/SystemInformation.hxx>
#include <cmsys/FStream.hxx>
#include "cmDynamicLoader.h" #include "cmDynamicLoader.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmXMLSafe.h" #include "cmXMLSafe.h"
@ -207,7 +208,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
return -1; return -1;
} }
::curl_easy_setopt(curl, CURLOPT_PUT, 1); ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
file = ::fopen(putFile.c_str(), "rb"); file = cmsys::SystemTools::Fopen(putFile.c_str(), "rb");
::curl_easy_setopt(curl, CURLOPT_INFILE, file); ::curl_easy_setopt(curl, CURLOPT_INFILE, file);
//fall through to append GET fields //fall through to append GET fields
case cmCTest::HTTP_GET: case cmCTest::HTTP_GET:
@ -549,7 +550,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
} }
std::string tagfile = testingDir + "/TAG"; std::string tagfile = testingDir + "/TAG";
std::ifstream tfin(tagfile.c_str()); cmsys::ifstream tfin(tagfile.c_str());
std::string tag; std::string tag;
if (createNewTag) if (createNewTag)
@ -604,7 +605,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
lctime->tm_hour, lctime->tm_hour,
lctime->tm_min); lctime->tm_min);
tag = datestring; tag = datestring;
std::ofstream ofs(tagfile.c_str()); cmsys::ofstream ofs(tagfile.c_str());
if ( ofs ) if ( ofs )
{ {
ofs << tag << std::endl; ofs << tag << std::endl;
@ -763,7 +764,7 @@ bool cmCTest::UpdateCTestConfiguration()
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
<< fileName.c_str() << "\n"); << fileName.c_str() << "\n");
// parse the dart test file // parse the dart test file
std::ifstream fin(fileName.c_str()); cmsys::ifstream fin(fileName.c_str());
if(!fin) if(!fin)
{ {
@ -1149,7 +1150,7 @@ int cmCTest::GetTestModelFromString(const char* str)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTest::RunMakeCommand(const char* command, std::string* output, int cmCTest::RunMakeCommand(const char* command, std::string* output,
int* retVal, const char* dir, int timeout, std::ofstream& ofs) int* retVal, const char* dir, int timeout, std::ostream& ofs)
{ {
// First generate the command and arguments // First generate the command and arguments
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
@ -1611,7 +1612,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os,
<< "<Time>" << cmSystemTools::GetTime() << "</Time>\n" << "<Time>" << cmSystemTools::GetTime() << "</Time>\n"
<< "<DateTime>" << note_time << "</DateTime>\n" << "<DateTime>" << note_time << "</DateTime>\n"
<< "<Text>" << std::endl; << "<Text>" << std::endl;
std::ifstream ifs(it->c_str()); cmsys::ifstream ifs(it->c_str());
if ( ifs ) if ( ifs )
{ {
std::string line; std::string line;
@ -1692,7 +1693,7 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
std::string cmCTest::Base64EncodeFile(std::string file) std::string cmCTest::Base64EncodeFile(std::string file)
{ {
long len = cmSystemTools::FileLength(file.c_str()); long len = cmSystemTools::FileLength(file.c_str());
std::ifstream ifs(file.c_str(), std::ios::in cmsys::ifstream ifs(file.c_str(), std::ios::in
#ifdef _WIN32 #ifdef _WIN32
| std::ios::binary | std::ios::binary
#endif #endif

View File

@ -273,7 +273,7 @@ public:
// and retVal is return value or exception. // and retVal is return value or exception.
int RunMakeCommand(const char* command, std::string* output, int RunMakeCommand(const char* command, std::string* output,
int* retVal, const char* dir, int timeout, int* retVal, const char* dir, int timeout,
std::ofstream& ofs); std::ostream& ofs);
/* /*
* return the current tag * return the current tag

View File

@ -20,7 +20,7 @@
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
const char* cmCacheManagerTypes[] = const char* cmCacheManagerTypes[] =
@ -211,7 +211,7 @@ bool cmCacheManager::LoadCache(const char* path,
return false; return false;
} }
std::ifstream fin(cacheFile.c_str()); cmsys::ifstream fin(cacheFile.c_str());
if(!fin) if(!fin)
{ {
return false; return false;
@ -566,7 +566,7 @@ bool cmCacheManager::SaveCache(const char* path)
checkCacheFile += cmake::GetCMakeFilesDirectory(); checkCacheFile += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(checkCacheFile.c_str()); cmSystemTools::MakeDirectory(checkCacheFile.c_str());
checkCacheFile += "/cmake.check_cache"; checkCacheFile += "/cmake.check_cache";
std::ofstream checkCache(checkCacheFile.c_str()); cmsys::ofstream checkCache(checkCacheFile.c_str());
if(!checkCache) if(!checkCache)
{ {
cmSystemTools::Error("Unable to open check cache file for write. ", cmSystemTools::Error("Unable to open check cache file for write. ",

View File

@ -278,7 +278,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
sourceDirectory = this->BinaryDirectory.c_str(); sourceDirectory = this->BinaryDirectory.c_str();
// now create a CMakeLists.txt file in that directory // now create a CMakeLists.txt file in that directory
FILE *fout = fopen(outFileName.c_str(),"w"); FILE *fout = cmsys::SystemTools::Fopen(outFileName.c_str(),"w");
if (!fout) if (!fout)
{ {
cmOStringStream e; cmOStringStream e;

View File

@ -12,6 +12,7 @@
#include "cmCryptoHash.h" #include "cmCryptoHash.h"
#include <cmsys/MD5.h> #include <cmsys/MD5.h>
#include <cmsys/FStream.hxx>
#include "cm_sha2.h" #include "cm_sha2.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -45,7 +46,7 @@ std::string cmCryptoHash::HashString(const char* input)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmCryptoHash::HashFile(const char* file) std::string cmCryptoHash::HashFile(const char* file)
{ {
std::ifstream fin(file, std::ios::in | cmsys_ios_binary); cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary);
if(!fin) if(!fin)
{ {
return ""; return "";

View File

@ -17,6 +17,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmFileTimeComparison.h" #include "cmFileTimeComparison.h"
#include <string.h> #include <string.h>
#include <cmsys/FStream.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir): cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir):
@ -103,7 +104,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile,
// Check whether dependencies must be regenerated. // Check whether dependencies must be regenerated.
bool okay = true; bool okay = true;
std::ifstream fin(internalFile); cmsys::ifstream fin(internalFile);
if(!(fin && this->CheckDependencies(fin, internalFile, validDeps))) if(!(fin && this->CheckDependencies(fin, internalFile, validDeps)))
{ {
// Clear all dependencies so they will be regenerated. // Clear all dependencies so they will be regenerated.

View File

@ -15,6 +15,7 @@
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <cmsys/FStream.hxx>
#include <ctype.h> // isspace #include <ctype.h> // isspace
@ -246,7 +247,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// Try to scan the file. Just leave it out if we cannot find // Try to scan the file. Just leave it out if we cannot find
// it. // it.
std::ifstream fin(fullName.c_str()); cmsys::ifstream fin(fullName.c_str());
if(fin) if(fin)
{ {
// Add this file as a dependency. // Add this file as a dependency.
@ -291,7 +292,7 @@ void cmDependsC::ReadCacheFile()
{ {
return; return;
} }
std::ifstream fin(this->CacheFileName.c_str()); cmsys::ifstream fin(this->CacheFileName.c_str());
if(!fin) if(!fin)
{ {
return; return;
@ -380,7 +381,7 @@ void cmDependsC::WriteCacheFile() const
{ {
return; return;
} }
std::ofstream cacheOut(this->CacheFileName.c_str()); cmsys::ofstream cacheOut(this->CacheFileName.c_str());
if(!cacheOut) if(!cacheOut)
{ {
return; return;

View File

@ -17,7 +17,7 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmDependsFortranParser.h" /* Interface to parser object. */ #include "cmDependsFortranParser.h" /* Interface to parser object. */
#include <cmsys/FStream.hxx>
#include <assert.h> #include <assert.h>
#include <stack> #include <stack>
@ -356,7 +356,7 @@ void cmDependsFortran::LocateModules()
{ {
std::string targetDir = cmSystemTools::GetFilenamePath(*i); std::string targetDir = cmSystemTools::GetFilenamePath(*i);
std::string fname = targetDir + "/fortran.internal"; std::string fname = targetDir + "/fortran.internal";
std::ifstream fin(fname.c_str()); cmsys::ifstream fin(fname.c_str());
if(fin) if(fin)
{ {
this->MatchRemoteModules(fin, targetDir.c_str()); this->MatchRemoteModules(fin, targetDir.c_str());
@ -700,7 +700,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
// is later used for longer sequences it should be re-written using an // is later used for longer sequences it should be re-written using an
// efficient string search algorithm such as Boyer-Moore. // efficient string search algorithm such as Boyer-Moore.
static static
bool cmDependsFortranStreamContainsSequence(std::ifstream& ifs, bool cmDependsFortranStreamContainsSequence(std::istream& ifs,
const char* seq, int len) const char* seq, int len)
{ {
assert(len > 0); assert(len > 0);
@ -733,8 +733,8 @@ bool cmDependsFortranStreamContainsSequence(std::ifstream& ifs,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Helper function to compare the remaining content in two streams. // Helper function to compare the remaining content in two streams.
static bool cmDependsFortranStreamsDiffer(std::ifstream& ifs1, static bool cmDependsFortranStreamsDiffer(std::istream& ifs1,
std::ifstream& ifs2) std::istream& ifs2)
{ {
// Compare the remaining content. // Compare the remaining content.
for(;;) for(;;)
@ -799,11 +799,11 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
} }
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ifstream finModFile(modFile, std::ios::in | std::ios::binary); cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
std::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary); cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary);
#else #else
std::ifstream finModFile(modFile, std::ios::in); cmsys::ifstream finModFile(modFile, std::ios::in);
std::ifstream finStampFile(stampFile, std::ios::in); cmsys::ifstream finStampFile(stampFile, std::ios::in);
#endif #endif
if(!finModFile || !finStampFile) if(!finModFile || !finStampFile)
{ {
@ -944,7 +944,7 @@ bool cmDependsFortranParser_FilePush(cmDependsFortranParser* parser,
{ {
// Open the new file and push it onto the stack. Save the old // Open the new file and push it onto the stack. Save the old
// buffer with it on the stack. // buffer with it on the stack.
if(FILE* file = fopen(fname, "rb")) if(FILE* file = cmsys::SystemTools::Fopen(fname, "rb"))
{ {
YY_BUFFER_STATE current = YY_BUFFER_STATE current =
cmDependsFortranLexer_GetCurrentBuffer(parser->Scanner); cmDependsFortranLexer_GetCurrentBuffer(parser->Scanner);

View File

@ -13,6 +13,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmDependsJavaLexer.h" #include "cmDependsJavaLexer.h"
#include <cmsys/FStream.hxx>
int cmDependsJava_yyparse( yyscan_t yyscanner ); int cmDependsJava_yyparse( yyscan_t yyscanner );
@ -412,7 +413,7 @@ int cmDependsJavaParserHelper::ParseFile(const char* file)
{ {
return 0; return 0;
} }
std::ifstream ifs(file); cmsys::ifstream ifs(file);
if ( !ifs ) if ( !ifs )
{ {
return 0; return 0;

View File

@ -17,6 +17,7 @@
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/FStream.hxx>
#include <ctype.h> #include <ctype.h>
@ -156,11 +157,11 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
this->CurrentArgument = i->Argument; this->CurrentArgument = i->Argument;
// If a file name was given, use it. Otherwise, default to the // If a file name was given, use it. Otherwise, default to the
// given stream. // given stream.
std::ofstream* fout = 0; cmsys::ofstream* fout = 0;
std::ostream* s = &os; std::ostream* s = &os;
if(i->Filename.length() > 0) if(i->Filename.length() > 0)
{ {
fout = new std::ofstream(i->Filename.c_str(), std::ios::out); fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out);
if(fout) if(fout)
{ {
s = fout; s = fout;
@ -631,7 +632,7 @@ void cmDocumentation::PrintNames(std::ostream& os,
i != files.end(); ++i) i != files.end(); ++i)
{ {
std::string line; std::string line;
std::ifstream fin(i->c_str()); cmsys::ifstream fin(i->c_str());
while(fin && cmSystemTools::GetLineFromStream(fin, line)) while(fin && cmSystemTools::GetLineFromStream(fin, line))
{ {
if(!line.empty() && (isalnum(line[0]) || line[0] == '<')) if(!line.empty() && (isalnum(line[0]) || line[0] == '<'))

View File

@ -13,6 +13,7 @@
#include "cmELF.h" #include "cmELF.h"
#include <cmsys/auto_ptr.hxx> #include <cmsys/auto_ptr.hxx>
#include <cmsys/FStream.hxx>
// Need the native byte order of the running CPU. // Need the native byte order of the running CPU.
#define cmsys_CPU_UNKNOWN_OKAY // We can decide at runtime if not known. #define cmsys_CPU_UNKNOWN_OKAY // We can decide at runtime if not known.
@ -71,7 +72,7 @@ public:
// Construct and take ownership of the file stream object. // Construct and take ownership of the file stream object.
cmELFInternal(cmELF* external, cmELFInternal(cmELF* external,
cmsys::auto_ptr<std::ifstream>& fin, cmsys::auto_ptr<cmsys::ifstream>& fin,
ByteOrderType order): ByteOrderType order):
External(external), External(external),
Stream(*fin.release()), Stream(*fin.release()),
@ -204,7 +205,7 @@ public:
// Construct with a stream and byte swap indicator. // Construct with a stream and byte swap indicator.
cmELFInternalImpl(cmELF* external, cmELFInternalImpl(cmELF* external,
cmsys::auto_ptr<std::ifstream>& fin, cmsys::auto_ptr<cmsys::ifstream>& fin,
ByteOrderType order); ByteOrderType order);
// Return the number of sections as specified by the ELF header. // Return the number of sections as specified by the ELF header.
@ -462,7 +463,7 @@ private:
template <class Types> template <class Types>
cmELFInternalImpl<Types> cmELFInternalImpl<Types>
::cmELFInternalImpl(cmELF* external, ::cmELFInternalImpl(cmELF* external,
cmsys::auto_ptr<std::ifstream>& fin, cmsys::auto_ptr<cmsys::ifstream>& fin,
ByteOrderType order): ByteOrderType order):
cmELFInternal(external, fin, order) cmELFInternal(external, fin, order)
{ {
@ -707,7 +708,7 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(int tag)
cmELF::cmELF(const char* fname): Internal(0) cmELF::cmELF(const char* fname): Internal(0)
{ {
// Try to open the file. // Try to open the file.
cmsys::auto_ptr<std::ifstream> fin(new std::ifstream(fname)); cmsys::auto_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
// Quit now if the file could not be opened. // Quit now if the file could not be opened.
if(!fin.get() || !*fin) if(!fin.get() || !*fin)

View File

@ -24,6 +24,7 @@
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
#include <cmsys/auto_ptr.hxx> #include <cmsys/auto_ptr.hxx>
#include <cmsys/FStream.hxx>
#include <assert.h> #include <assert.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -61,12 +62,12 @@ const char* cmExportFileGenerator::GetMainExportFileName() const
bool cmExportFileGenerator::GenerateImportFile() bool cmExportFileGenerator::GenerateImportFile()
{ {
// Open the output file to generate it. // Open the output file to generate it.
cmsys::auto_ptr<std::ofstream> foutPtr; cmsys::auto_ptr<cmsys::ofstream> foutPtr;
if(this->AppendMode) if(this->AppendMode)
{ {
// Open for append. // Open for append.
cmsys::auto_ptr<std::ofstream> cmsys::auto_ptr<cmsys::ofstream>
ap(new std::ofstream(this->MainImportFile.c_str(), std::ios::app)); ap(new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
foutPtr = ap; foutPtr = ap;
} }
else else

View File

@ -55,11 +55,11 @@ void cmExportLibraryDependenciesCommand::FinalPass()
void cmExportLibraryDependenciesCommand::ConstFinalPass() const void cmExportLibraryDependenciesCommand::ConstFinalPass() const
{ {
// Use copy-if-different if not appending. // Use copy-if-different if not appending.
cmsys::auto_ptr<std::ofstream> foutPtr; cmsys::auto_ptr<cmsys::ofstream> foutPtr;
if(this->Append) if(this->Append)
{ {
cmsys::auto_ptr<std::ofstream> ap( cmsys::auto_ptr<cmsys::ofstream> ap(
new std::ofstream(this->Filename.c_str(), std::ios::app)); new cmsys::ofstream(this->Filename.c_str(), std::ios::app));
foutPtr = ap; foutPtr = ap;
} }
else else

View File

@ -32,6 +32,7 @@
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
// Table of permissions flags. // Table of permissions flags.
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
@ -228,7 +229,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
} }
// If GetPermissions fails, pretend like it is ok. File open will fail if // If GetPermissions fails, pretend like it is ok. File open will fail if
// the file is not writable // the file is not writable
std::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out); cmsys::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out);
if ( !file ) if ( !file )
{ {
std::string error = "Internal CMake error when trying to open file: "; std::string error = "Internal CMake error when trying to open file: ";
@ -283,10 +284,10 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
// Open the specified file. // Open the specified file.
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ifstream file(fileName.c_str(), std::ios::in | cmsys::ifstream file(fileName.c_str(), std::ios::in |
(hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in)); (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in));
#else #else
std::ifstream file(fileName.c_str(), std::ios::in); cmsys::ifstream file(fileName.c_str(), std::ios::in);
#endif #endif
if ( !file ) if ( !file )
@ -577,9 +578,9 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// Open the specified file. // Open the specified file.
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary);
#else #else
std::ifstream fin(fileName.c_str(), std::ios::in); cmsys::ifstream fin(fileName.c_str(), std::ios::in);
#endif #endif
if(!fin) if(!fin)
{ {
@ -2490,7 +2491,7 @@ namespace {
void *data) void *data)
{ {
int realsize = (int)(size * nmemb); int realsize = (int)(size * nmemb);
std::ofstream* fout = static_cast<std::ofstream*>(data); cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data);
const char* chPtr = static_cast<char*>(ptr); const char* chPtr = static_cast<char*>(ptr);
fout->write(chPtr, realsize); fout->write(chPtr, realsize);
return realsize; return realsize;
@ -2838,7 +2839,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
return false; return false;
} }
std::ofstream fout(file.c_str(), std::ios::binary); cmsys::ofstream fout(file.c_str(), std::ios::binary);
if(!fout) if(!fout)
{ {
this->SetError("DOWNLOAD cannot open file for write."); this->SetError("DOWNLOAD cannot open file for write.");
@ -3094,7 +3095,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// Open file for reading: // Open file for reading:
// //
FILE *fin = fopen(filename.c_str(), "rb"); FILE *fin = cmsys::SystemTools::Fopen(filename.c_str(), "rb");
if(!fin) if(!fin)
{ {
std::string errStr = "UPLOAD cannot open file '"; std::string errStr = "UPLOAD cannot open file '";

View File

@ -1334,7 +1334,7 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir)
cmFindPackageCommandHoldFile holdFile(fname.c_str()); cmFindPackageCommandHoldFile holdFile(fname.c_str());
// Load the file. // Load the file.
std::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary); cmsys::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary);
if(fin && this->CheckPackageRegistryEntry(fin)) if(fin && this->CheckPackageRegistryEntry(fin))
{ {
// The file references an existing package, so release it. // The file references an existing package, so release it.

View File

@ -213,7 +213,7 @@ int cmGeneratedFileStreamBase::CompressFile(const char* oldname,
{ {
return 0; return 0;
} }
FILE* ifs = fopen(oldname, "r"); FILE* ifs = cmsys::SystemTools::Fopen(oldname, "r");
if ( !ifs ) if ( !ifs )
{ {
return 0; return 0;

View File

@ -13,6 +13,7 @@
#define cmGeneratedFileStream_h #define cmGeneratedFileStream_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include <cmsys/FStream.hxx>
#if defined(__sgi) && !defined(__GNUC__) #if defined(__sgi) && !defined(__GNUC__)
# pragma set woff 1375 /* base class destructor not virtual */ # pragma set woff 1375 /* base class destructor not virtual */
@ -77,10 +78,10 @@ protected:
* being updated. * being updated.
*/ */
class cmGeneratedFileStream: private cmGeneratedFileStreamBase, class cmGeneratedFileStream: private cmGeneratedFileStreamBase,
public std::ofstream public cmsys::ofstream
{ {
public: public:
typedef std::ofstream Stream; typedef cmsys::ofstream Stream;
/** /**
* This constructor prepares a default stream. The open method must * This constructor prepares a default stream. The open method must

View File

@ -13,6 +13,7 @@
#include "cmGeneratorExpressionEvaluationFile.h" #include "cmGeneratorExpressionEvaluationFile.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include <cmsys/FStream.hxx>
#include <assert.h> #include <assert.h>
@ -78,7 +79,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
this->Files.push_back(outputFileName); this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent; outputFiles[outputFileName] = outputContent;
std::ofstream fout(outputFileName.c_str()); cmsys::ofstream fout(outputFileName.c_str());
if(!fout) if(!fout)
{ {
@ -103,7 +104,7 @@ void cmGeneratorExpressionEvaluationFile::Generate()
} }
else else
{ {
std::ifstream fin(this->Input.c_str()); cmsys::ifstream fin(this->Input.c_str());
if(!fin) if(!fin)
{ {
cmOStringStream e; cmOStringStream e;

View File

@ -30,6 +30,7 @@
#include "cmExportBuildFileGenerator.h" #include "cmExportBuildFileGenerator.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
# include <cmsys/MD5.h> # include <cmsys/MD5.h>
@ -2747,9 +2748,9 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
std::string const& home) std::string const& home)
{ {
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary);
#else #else
std::ifstream fin(pfile.c_str(), std::ios::in); cmsys::ifstream fin(pfile.c_str(), std::ios::in);
#endif #endif
if(!fin) if(!fin)
{ {

View File

@ -21,6 +21,7 @@
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalKdevelopGenerator void cmGlobalKdevelopGenerator
@ -189,7 +190,7 @@ bool cmGlobalKdevelopGenerator
//check if the output file already exists and read it //check if the output file already exists and read it
//insert all files which exist into the set of files //insert all files which exist into the set of files
std::ifstream oldFilelist(filename.c_str()); cmsys::ifstream oldFilelist(filename.c_str());
if (oldFilelist) if (oldFilelist)
{ {
while (cmSystemTools::GetLineFromStream(oldFilelist, tmp)) while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
@ -310,7 +311,7 @@ void cmGlobalKdevelopGenerator
const std::string& fileToOpen, const std::string& fileToOpen,
const std::string& sessionFilename) const std::string& sessionFilename)
{ {
std::ifstream oldProjectFile(filename.c_str()); cmsys::ifstream oldProjectFile(filename.c_str());
if (!oldProjectFile) if (!oldProjectFile)
{ {
this->CreateNewProjectFile(outputDir, projectDir, filename, this->CreateNewProjectFile(outputDir, projectDir, filename,

View File

@ -13,6 +13,7 @@
#include "cmLocalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmake.h" #include "cmake.h"
#include <cmsys/FStream.hxx>
cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator() cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
{ {
@ -27,7 +28,7 @@ cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc)
{ {
std::string fstab = makeloc; std::string fstab = makeloc;
fstab += "/../etc/fstab"; fstab += "/../etc/fstab";
std::ifstream fin(fstab.c_str()); cmsys::ifstream fin(fstab.c_str());
std::string path; std::string path;
std::string mount; std::string mount;
std::string mingwBin; std::string mingwBin;

View File

@ -14,6 +14,7 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmake.h" #include "cmake.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include <cmsys/FStream.hxx>
// Utility function to make a valid VS6 *.dsp filename out // Utility function to make a valid VS6 *.dsp filename out
// of a CMake target name: // of a CMake target name:
@ -244,7 +245,7 @@ void cmGlobalVisualStudio6Generator
fname += "/"; fname += "/";
fname += root->GetMakefile()->GetProjectName(); fname += root->GetMakefile()->GetProjectName();
fname += ".dsw"; fname += ".dsw";
std::ofstream fout(fname.c_str()); cmsys::ofstream fout(fname.c_str());
if(!fout) if(!fout)
{ {
cmSystemTools::Error("Error can not open DSW file for write: ", cmSystemTools::Error("Error can not open DSW file for write: ",

View File

@ -166,7 +166,7 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType(
const char* inFileName) const char* inFileName)
{ {
char buf[1024]; char buf[1024];
FILE* inFile = fopen(inFileName, "rb"); FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb");
if (inFile == 0) if (inFile == 0)
{ {
return Binary; return Binary;
@ -223,8 +223,8 @@ bool cmHexFileConverter::TryConvert(const char* inFileName,
} }
// try to open the file // try to open the file
FILE* inFile = fopen(inFileName, "rb"); FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb");
FILE* outFile = fopen(outFileName, "wb"); FILE* outFile = cmsys::SystemTools::Fopen(outFileName, "wb");
if ((inFile == 0) || (outFile == 0)) if ((inFile == 0) || (outFile == 0))
{ {
if (inFile != 0) if (inFile != 0)

View File

@ -569,6 +569,9 @@ Modify cmListFileLexer.c:
*/ */
#include "cmStandardLexer.h" #include "cmStandardLexer.h"
#ifdef WIN32
#include <cmsys/Encoding.h>
#endif
/* Setup the proper cmListFileLexer_yylex declaration. */ /* Setup the proper cmListFileLexer_yylex declaration. */
#define YY_EXTRA_TYPE cmListFileLexer* #define YY_EXTRA_TYPE cmListFileLexer*
@ -612,7 +615,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
#line 618 "cmListFileLexer.c" #line 621 "cmListFileLexer.c"
#define INITIAL 0 #define INITIAL 0
#define STRING 1 #define STRING 1
@ -844,10 +847,10 @@ YY_DECL
int yy_act; int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#line 88 "cmListFileLexer.in.l" #line 91 "cmListFileLexer.in.l"
#line 855 "cmListFileLexer.c" #line 858 "cmListFileLexer.c"
if ( !yyg->yy_init ) if ( !yyg->yy_init )
{ {
@ -945,7 +948,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
/* rule 1 can match eol */ /* rule 1 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 90 "cmListFileLexer.in.l" #line 93 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_Newline; lexer->token.type = cmListFileLexer_Token_Newline;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -957,7 +960,7 @@ YY_RULE_SETUP
case 2: case 2:
/* rule 2 can match eol */ /* rule 2 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 99 "cmListFileLexer.in.l" #line 102 "cmListFileLexer.in.l"
{ {
const char* bracket = yytext; const char* bracket = yytext;
lexer->comment = yytext[0] == '#'; lexer->comment = yytext[0] == '#';
@ -986,7 +989,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 125 "cmListFileLexer.in.l" #line 128 "cmListFileLexer.in.l"
{ {
lexer->column += yyleng; lexer->column += yyleng;
BEGIN(COMMENT); BEGIN(COMMENT);
@ -994,14 +997,14 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 130 "cmListFileLexer.in.l" #line 133 "cmListFileLexer.in.l"
{ {
lexer->column += yyleng; lexer->column += yyleng;
} }
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 134 "cmListFileLexer.in.l" #line 137 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_ParenLeft; lexer->token.type = cmListFileLexer_Token_ParenLeft;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1010,7 +1013,7 @@ YY_RULE_SETUP
} }
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 141 "cmListFileLexer.in.l" #line 144 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_ParenRight; lexer->token.type = cmListFileLexer_Token_ParenRight;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1019,7 +1022,7 @@ YY_RULE_SETUP
} }
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 148 "cmListFileLexer.in.l" #line 151 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_Identifier; lexer->token.type = cmListFileLexer_Token_Identifier;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1028,7 +1031,7 @@ YY_RULE_SETUP
} }
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 155 "cmListFileLexer.in.l" #line 158 "cmListFileLexer.in.l"
{ {
/* Handle ]]====]=======]*/ /* Handle ]]====]=======]*/
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
@ -1041,7 +1044,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 165 "cmListFileLexer.in.l" #line 168 "cmListFileLexer.in.l"
{ {
lexer->column += yyleng; lexer->column += yyleng;
/* Erase the partial bracket from the token. */ /* Erase the partial bracket from the token. */
@ -1052,7 +1055,7 @@ YY_RULE_SETUP
} }
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 174 "cmListFileLexer.in.l" #line 177 "cmListFileLexer.in.l"
{ {
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng; lexer->column += yyleng;
@ -1061,7 +1064,7 @@ YY_RULE_SETUP
case 11: case 11:
/* rule 11 can match eol */ /* rule 11 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 179 "cmListFileLexer.in.l" #line 182 "cmListFileLexer.in.l"
{ {
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line; ++lexer->line;
@ -1071,7 +1074,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 186 "cmListFileLexer.in.l" #line 189 "cmListFileLexer.in.l"
{ {
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng; lexer->column += yyleng;
@ -1080,7 +1083,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case YY_STATE_EOF(BRACKET): case YY_STATE_EOF(BRACKET):
case YY_STATE_EOF(BRACKETEND): case YY_STATE_EOF(BRACKETEND):
#line 192 "cmListFileLexer.in.l" #line 195 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_BadBracket; lexer->token.type = cmListFileLexer_Token_BadBracket;
BEGIN(INITIAL); BEGIN(INITIAL);
@ -1088,7 +1091,7 @@ case YY_STATE_EOF(BRACKETEND):
} }
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 198 "cmListFileLexer.in.l" #line 201 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1097,7 +1100,7 @@ YY_RULE_SETUP
} }
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 205 "cmListFileLexer.in.l" #line 208 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1106,7 +1109,7 @@ YY_RULE_SETUP
} }
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 212 "cmListFileLexer.in.l" #line 215 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_ArgumentQuoted; lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
cmListFileLexerSetToken(lexer, "", 0); cmListFileLexerSetToken(lexer, "", 0);
@ -1116,7 +1119,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 219 "cmListFileLexer.in.l" #line 222 "cmListFileLexer.in.l"
{ {
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng; lexer->column += yyleng;
@ -1125,7 +1128,7 @@ YY_RULE_SETUP
case 17: case 17:
/* rule 17 can match eol */ /* rule 17 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 224 "cmListFileLexer.in.l" #line 227 "cmListFileLexer.in.l"
{ {
/* Continuation: text is not part of string */ /* Continuation: text is not part of string */
++lexer->line; ++lexer->line;
@ -1135,7 +1138,7 @@ YY_RULE_SETUP
case 18: case 18:
/* rule 18 can match eol */ /* rule 18 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 230 "cmListFileLexer.in.l" #line 233 "cmListFileLexer.in.l"
{ {
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line; ++lexer->line;
@ -1144,7 +1147,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 236 "cmListFileLexer.in.l" #line 239 "cmListFileLexer.in.l"
{ {
lexer->column += yyleng; lexer->column += yyleng;
BEGIN(INITIAL); BEGIN(INITIAL);
@ -1152,14 +1155,14 @@ YY_RULE_SETUP
} }
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 242 "cmListFileLexer.in.l" #line 245 "cmListFileLexer.in.l"
{ {
cmListFileLexerAppend(lexer, yytext, yyleng); cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng; lexer->column += yyleng;
} }
YY_BREAK YY_BREAK
case YY_STATE_EOF(STRING): case YY_STATE_EOF(STRING):
#line 247 "cmListFileLexer.in.l" #line 250 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_BadString; lexer->token.type = cmListFileLexer_Token_BadString;
BEGIN(INITIAL); BEGIN(INITIAL);
@ -1167,7 +1170,7 @@ case YY_STATE_EOF(STRING):
} }
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 253 "cmListFileLexer.in.l" #line 256 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_Space; lexer->token.type = cmListFileLexer_Token_Space;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1176,7 +1179,7 @@ YY_RULE_SETUP
} }
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 260 "cmListFileLexer.in.l" #line 263 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_BadCharacter; lexer->token.type = cmListFileLexer_Token_BadCharacter;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
@ -1185,7 +1188,7 @@ YY_RULE_SETUP
} }
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(COMMENT):
#line 267 "cmListFileLexer.in.l" #line 270 "cmListFileLexer.in.l"
{ {
lexer->token.type = cmListFileLexer_Token_None; lexer->token.type = cmListFileLexer_Token_None;
cmListFileLexerSetToken(lexer, 0, 0); cmListFileLexerSetToken(lexer, 0, 0);
@ -1193,10 +1196,10 @@ case YY_STATE_EOF(COMMENT):
} }
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 273 "cmListFileLexer.in.l" #line 276 "cmListFileLexer.in.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1217 "cmListFileLexer.c" #line 1220 "cmListFileLexer.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@ -2317,7 +2320,7 @@ void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 273 "cmListFileLexer.in.l" #line 276 "cmListFileLexer.in.l"
@ -2542,7 +2545,13 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
cmListFileLexerDestroy(lexer); cmListFileLexerDestroy(lexer);
if(name) if(name)
{ {
#ifdef _WIN32
wchar_t* wname = cmsysEncoding_DupToWide(name);
lexer->file = _wfopen(wname, L"rb");
free(wname);
#else
lexer->file = fopen(name, "rb"); lexer->file = fopen(name, "rb");
#endif
if(lexer->file) if(lexer->file)
{ {
if(bom) if(bom)

View File

@ -31,6 +31,9 @@ Modify cmListFileLexer.c:
*/ */
#include "cmStandardLexer.h" #include "cmStandardLexer.h"
#ifdef WIN32
#include <cmsys/Encoding.h>
#endif
/* Setup the proper cmListFileLexer_yylex declaration. */ /* Setup the proper cmListFileLexer_yylex declaration. */
#define YY_EXTRA_TYPE cmListFileLexer* #define YY_EXTRA_TYPE cmListFileLexer*
@ -493,7 +496,13 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
cmListFileLexerDestroy(lexer); cmListFileLexerDestroy(lexer);
if(name) if(name)
{ {
#ifdef _WIN32
wchar_t* wname = cmsysEncoding_DupToWide(name);
lexer->file = _wfopen(wname, L"rb");
free(wname);
#else
lexer->file = fopen(name, "rb"); lexer->file = fopen(name, "rb");
#endif
if(lexer->file) if(lexer->file)
{ {
if(bom) if(bom)

View File

@ -12,6 +12,7 @@
#include "cmLoadCacheCommand.h" #include "cmLoadCacheCommand.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
// cmLoadCacheCommand // cmLoadCacheCommand
bool cmLoadCacheCommand bool cmLoadCacheCommand
@ -115,7 +116,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
} }
// Read the cache file. // Read the cache file.
std::ifstream fin(cacheFile.c_str()); cmsys::ifstream fin(cacheFile.c_str());
// This is a big hack read loop to overcome a buggy ifstream // This is a big hack read loop to overcome a buggy ifstream
// implementation on HP-UX. This should work on all platforms even // implementation on HP-UX. This should work on all platforms even

View File

@ -1172,7 +1172,7 @@ cmLocalUnixMakefileGenerator3
} }
cleanfile += ".cmake"; cleanfile += ".cmake";
std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL);
std::ofstream fout(cleanfilePath.c_str()); cmsys::ofstream fout(cleanfilePath.c_str());
if(!fout) if(!fout)
{ {
cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); cmSystemTools::Error("Could not create ", cleanfilePath.c_str());

View File

@ -21,6 +21,7 @@
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator(): cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator():
cmLocalVisualStudioGenerator(VS6) cmLocalVisualStudioGenerator(VS6)
@ -200,7 +201,7 @@ void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
// save the name of the real dsp file // save the name of the real dsp file
std::string realDSP = fname; std::string realDSP = fname;
fname += ".cmake"; fname += ".cmake";
std::ofstream fout(fname.c_str()); cmsys::ofstream fout(fname.c_str());
if(!fout) if(!fout)
{ {
cmSystemTools::Error("Error Writing ", fname.c_str()); cmSystemTools::Error("Error Writing ", fname.c_str());
@ -336,11 +337,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
std::string path = cmSystemTools::GetFilenamePath(source); std::string path = cmSystemTools::GetFilenamePath(source);
cmSystemTools::MakeDirectory(path.c_str()); cmSystemTools::MakeDirectory(path.c_str());
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ofstream sourceFout(source.c_str(), cmsys::ofstream sourceFout(source.c_str(),
std::ios::binary | std::ios::out std::ios::binary | std::ios::out
| std::ios::trunc); | std::ios::trunc);
#else #else
std::ofstream sourceFout(source.c_str(), cmsys::ofstream sourceFout(source.c_str(),
std::ios::out | std::ios::trunc); std::ios::out | std::ios::trunc);
#endif #endif
if(sourceFout) if(sourceFout)
@ -758,7 +759,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
// once the build type is set, determine what configurations are // once the build type is set, determine what configurations are
// possible // possible
std::ifstream fin(this->DSPHeaderTemplate.c_str()); cmsys::ifstream fin(this->DSPHeaderTemplate.c_str());
cmsys::RegularExpression reg("# Name "); cmsys::RegularExpression reg("# Name ");
if(!fin) if(!fin)
@ -1452,7 +1453,7 @@ void cmLocalVisualStudio6Generator
std::string customRuleCodeRelWithDebInfo std::string customRuleCodeRelWithDebInfo
= this->CreateTargetRules(target, "RELWITHDEBINFO", libName); = this->CreateTargetRules(target, "RELWITHDEBINFO", libName);
std::ifstream fin(this->DSPHeaderTemplate.c_str()); cmsys::ifstream fin(this->DSPHeaderTemplate.c_str());
if(!fin) if(!fin)
{ {
cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
@ -1785,7 +1786,7 @@ void cmLocalVisualStudio6Generator
void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
{ {
std::ifstream fin(this->DSPFooterTemplate.c_str()); cmsys::ifstream fin(this->DSPFooterTemplate.c_str());
if(!fin) if(!fin)
{ {
cmSystemTools::Error("Error Reading ", cmSystemTools::Error("Error Reading ",

View File

@ -205,7 +205,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
cmSystemTools::MakeDirectory(stampName.c_str()); cmSystemTools::MakeDirectory(stampName.c_str());
stampName += "/"; stampName += "/";
stampName += "generate.stamp"; stampName += "generate.stamp";
std::ofstream stamp(stampName.c_str()); cmsys::ofstream stamp(stampName.c_str());
stamp << "# CMake generation timestamp file for this directory.\n"; stamp << "# CMake generation timestamp file for this directory.\n";
// Create a helper file so CMake can determine when it is run // Create a helper file so CMake can determine when it is run
@ -216,7 +216,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
// the stamp file can just be touched. // the stamp file can just be touched.
std::string depName = stampName; std::string depName = stampName;
depName += ".depend"; depName += ".depend";
std::ofstream depFile(depName.c_str()); cmsys::ofstream depFile(depName.c_str());
depFile << "# CMake generation dependency list for this directory.\n"; depFile << "# CMake generation dependency list for this directory.\n";
std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
for(std::vector<std::string>::const_iterator lf = listFiles.begin(); for(std::vector<std::string>::const_iterator lf = listFiles.begin();
@ -1826,7 +1826,7 @@ WriteCustomRule(std::ostream& fout,
// make sure the rule runs reliably. // make sure the rule runs reliably.
if(!cmSystemTools::FileExists(source)) if(!cmSystemTools::FileExists(source))
{ {
std::ofstream depout(source); cmsys::ofstream depout(source);
depout << "Artificial dependency for a custom command.\n"; depout << "Artificial dependency for a custom command.\n";
} }
fout << this->ConvertToXMLOutputPath(source); fout << this->ConvertToXMLOutputPath(source);

View File

@ -14,6 +14,7 @@
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
void cmDependInformation::AddDependencies(cmDependInformation* info) void cmDependInformation::AddDependencies(cmDependInformation* info)
{ {
@ -217,7 +218,7 @@ void cmMakeDepend::DependWalk(cmDependInformation* info)
{ {
cmsys::RegularExpression includeLine cmsys::RegularExpression includeLine
("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); ("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]");
std::ifstream fin(info->FullPath.c_str()); cmsys::ifstream fin(info->FullPath.c_str());
if(!fin) if(!fin)
{ {
cmSystemTools::Error("Cannot open ", info->FullPath.c_str()); cmSystemTools::Error("Cannot open ", info->FullPath.c_str());

View File

@ -34,7 +34,7 @@
#include <stdlib.h> // required for atoi #include <stdlib.h> // required for atoi
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
#include <cmsys/auto_ptr.hxx> #include <cmsys/auto_ptr.hxx>
#include <stack> #include <stack>
@ -3499,7 +3499,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
} }
std::string tempOutputFile = soutfile; std::string tempOutputFile = soutfile;
tempOutputFile += ".tmp"; tempOutputFile += ".tmp";
std::ofstream fout(tempOutputFile.c_str(), omode); cmsys::ofstream fout(tempOutputFile.c_str(), omode);
if(!fout) if(!fout)
{ {
cmSystemTools::Error( cmSystemTools::Error(
@ -3508,7 +3508,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
cmSystemTools::ReportLastSystemError(""); cmSystemTools::ReportLastSystemError("");
return 0; return 0;
} }
std::ifstream fin(sinfile.c_str()); cmsys::ifstream fin(sinfile.c_str());
if(!fin) if(!fin)
{ {
cmSystemTools::Error("Could not open file for read in copy operation ", cmSystemTools::Error("Could not open file for read in copy operation ",

View File

@ -957,7 +957,6 @@ private:
bool EnforceUniqueDir(const char* srcPath, const char* binPath); bool EnforceUniqueDir(const char* srcPath, const char* binPath);
void ReadSources(std::ifstream& fin, bool t);
friend class cmMakeDepend; // make depend needs direct access friend class cmMakeDepend; // make depend needs direct access
// to the Sources array // to the Sources array
void PrintStringVector(const char* s, const void PrintStringVector(const char* s, const

View File

@ -11,6 +11,7 @@
============================================================================*/ ============================================================================*/
#include "cmOutputRequiredFilesCommand.h" #include "cmOutputRequiredFilesCommand.h"
#include "cmMakeDepend.h" #include "cmMakeDepend.h"
#include <cmsys/FStream.hxx>
class cmLBDepend : public cmMakeDepend class cmLBDepend : public cmMakeDepend
{ {
@ -22,7 +23,7 @@ class cmLBDepend : public cmMakeDepend
void cmLBDepend::DependWalk(cmDependInformation* info) void cmLBDepend::DependWalk(cmDependInformation* info)
{ {
std::ifstream fin(info->FullPath.c_str()); cmsys::ifstream fin(info->FullPath.c_str());
if(!fin) if(!fin)
{ {
cmSystemTools::Error("error can not open ", info->FullPath.c_str()); cmSystemTools::Error("error can not open ", info->FullPath.c_str());
@ -196,7 +197,7 @@ bool cmOutputRequiredFilesCommand
if (info) if (info)
{ {
// write them out // write them out
FILE *fout = fopen(this->OutputFile.c_str(),"w"); FILE *fout = cmsys::SystemTools::Fopen(this->OutputFile.c_str(),"w");
if(!fout) if(!fout)
{ {
std::string err = "Can not open output file: "; std::string err = "Can not open output file: ";

View File

@ -23,6 +23,7 @@
#include <cmsys/Terminal.h> #include <cmsys/Terminal.h>
#include <cmsys/ios/sstream> #include <cmsys/ios/sstream>
#include <cmsys/FStream.hxx>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -396,7 +397,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
|| !configIncludes.empty() || !configIncludes.empty()
|| !configUicOptions.empty()) || !configUicOptions.empty())
{ {
std::ofstream infoFile(outputFile.c_str(), std::ios::app); cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app);
if ( !infoFile ) if ( !infoFile )
{ {
std::string error = "Internal CMake error when trying to open file: "; std::string error = "Internal CMake error when trying to open file: ";
@ -2111,7 +2112,7 @@ bool cmQtAutoGenerators::EndsWith(const std::string& str,
std::string cmQtAutoGenerators::ReadAll(const std::string& filename) std::string cmQtAutoGenerators::ReadAll(const std::string& filename)
{ {
std::ifstream file(filename.c_str()); cmsys::ifstream file(filename.c_str());
cmsys_ios::stringstream stream; cmsys_ios::stringstream stream;
stream << file.rdbuf(); stream << file.rdbuf();
file.close(); file.close();

View File

@ -13,7 +13,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmVersion.h" #include "cmVersion.h"
#include <cmsys/FStream.hxx>
#include <ctype.h> #include <ctype.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -52,7 +52,7 @@ cmRST::cmRST(std::ostream& os, std::string const& docroot):
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmRST::ProcessFile(std::string const& fname, bool isModule) bool cmRST::ProcessFile(std::string const& fname, bool isModule)
{ {
std::ifstream fin(fname.c_str()); cmsys::ifstream fin(fname.c_str());
if(fin) if(fin)
{ {
this->DocDir = cmSystemTools::GetFilenamePath(fname); this->DocDir = cmSystemTools::GetFilenamePath(fname);

View File

@ -32,6 +32,7 @@
# include <cmsys/Terminal.h> # include <cmsys/Terminal.h>
#endif #endif
#include <cmsys/stl/algorithm> #include <cmsys/stl/algorithm>
#include <cmsys/FStream.hxx>
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> # include <windows.h>
@ -1432,7 +1433,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
{ {
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
std::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); cmsys::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary);
if(!fout) if(!fout)
{ {
std::string e = "Cannot open output file \""; std::string e = "Cannot open output file \"";
@ -2037,7 +2038,7 @@ unsigned int cmSystemTools::RandomSeed()
} seed; } seed;
// Try using a real random source. // Try using a real random source.
std::ifstream fin("/dev/urandom"); cmsys::ifstream fin("/dev/urandom");
if(fin && fin.read(seed.bytes, sizeof(seed)) && if(fin && fin.read(seed.bytes, sizeof(seed)) &&
fin.gcount() == sizeof(seed)) fin.gcount() == sizeof(seed))
{ {
@ -2160,7 +2161,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
// Build tree has "<build>/bin[/<config>]/cmake" and // Build tree has "<build>/bin[/<config>]/cmake" and
// "<build>/CMakeFiles/CMakeSourceDir.txt". // "<build>/CMakeFiles/CMakeSourceDir.txt".
std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
std::ifstream fin(src_dir_txt.c_str()); cmsys::ifstream fin(src_dir_txt.c_str());
std::string src_dir; std::string src_dir;
if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) && if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) &&
cmSystemTools::FileIsDirectory(src_dir.c_str())) cmSystemTools::FileIsDirectory(src_dir.c_str()))
@ -2171,7 +2172,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
{ {
dir = cmSystemTools::GetFilenamePath(dir); dir = cmSystemTools::GetFilenamePath(dir);
src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
std::ifstream fin2(src_dir_txt.c_str()); cmsys::ifstream fin2(src_dir_txt.c_str());
if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) && if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) &&
cmSystemTools::FileIsDirectory(src_dir.c_str())) cmSystemTools::FileIsDirectory(src_dir.c_str()))
{ {
@ -2506,7 +2507,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
{ {
// Open the file for update. // Open the file for update.
std::ofstream f(file.c_str(), cmsys::ofstream f(file.c_str(),
std::ios::in | std::ios::out | std::ios::binary); std::ios::in | std::ios::out | std::ios::binary);
if(!f) if(!f)
{ {
@ -2704,7 +2705,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
} }
// Open the file for update. // Open the file for update.
std::ofstream f(file.c_str(), cmsys::ofstream f(file.c_str(),
std::ios::in | std::ios::out | std::ios::binary); std::ios::in | std::ios::out | std::ios::binary);
if(!f) if(!f)
{ {

View File

@ -12,6 +12,7 @@
#include "cmTryRunCommand.h" #include "cmTryRunCommand.h"
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "cmTryCompileCommand.h" #include "cmTryCompileCommand.h"
#include <cmsys/FStream.hxx>
// cmTryRunCommand // cmTryRunCommand
bool cmTryRunCommand bool cmTryRunCommand
@ -302,7 +303,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
if (error) if (error)
{ {
static bool firstTryRun = true; static bool firstTryRun = true;
std::ofstream file(resultFileName.c_str(), cmsys::ofstream file(resultFileName.c_str(),
firstTryRun ? std::ios::out : std::ios::app); firstTryRun ? std::ios::out : std::ios::app);
if ( file ) if ( file )
{ {

View File

@ -13,6 +13,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
bool cmUseMangledMesaCommand bool cmUseMangledMesaCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
@ -73,7 +74,7 @@ CopyAndFullPathMesaHeader(const char* source,
outFile += file; outFile += file;
std::string tempOutputFile = outFile; std::string tempOutputFile = outFile;
tempOutputFile += ".tmp"; tempOutputFile += ".tmp";
std::ofstream fout(tempOutputFile.c_str()); cmsys::ofstream fout(tempOutputFile.c_str());
if(!fout) if(!fout)
{ {
cmSystemTools::Error("Could not open file for write in copy operation: ", cmSystemTools::Error("Could not open file for write in copy operation: ",
@ -81,7 +82,7 @@ CopyAndFullPathMesaHeader(const char* source,
cmSystemTools::ReportLastSystemError(""); cmSystemTools::ReportLastSystemError("");
return; return;
} }
std::ifstream fin(source); cmsys::ifstream fin(source);
if(!fin) if(!fin)
{ {
cmSystemTools::Error("Could not open file for read in copy operation", cmSystemTools::Error("Could not open file for read in copy operation",

View File

@ -596,7 +596,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
// Make sure the path exists for the file // Make sure the path exists for the file
std::string path = cmSystemTools::GetFilenamePath(sourcePath); std::string path = cmSystemTools::GetFilenamePath(sourcePath);
cmSystemTools::MakeDirectory(path.c_str()); cmSystemTools::MakeDirectory(path.c_str());
std::ofstream fout(sourcePath.c_str()); cmsys::ofstream fout(sourcePath.c_str());
if(fout) if(fout)
{ {
fout << "# generated from CMake\n"; fout << "# generated from CMake\n";

View File

@ -13,6 +13,7 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmVisualStudioSlnData.h" #include "cmVisualStudioSlnData.h"
#include <cmsys/FStream.hxx>
#include <cassert> #include <cassert>
#include <stack> #include <stack>
@ -472,7 +473,7 @@ bool cmVisualStudioSlnParser::ParseFile(const std::string& file,
this->LastResult.SetError(ResultErrorUnsupportedDataGroup, 0); this->LastResult.SetError(ResultErrorUnsupportedDataGroup, 0);
return false; return false;
} }
std::ifstream f(file.c_str()); cmsys::ifstream f(file.c_str());
if (!f) if (!f)
{ {
this->LastResult.SetError(ResultErrorOpeningInput, 0); this->LastResult.SetError(ResultErrorOpeningInput, 0);

View File

@ -10,6 +10,7 @@
See the License for more information. See the License for more information.
============================================================================*/ ============================================================================*/
#include "cmWriteFileCommand.h" #include "cmWriteFileCommand.h"
#include <cmsys/FStream.hxx>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -71,7 +72,7 @@ bool cmWriteFileCommand
} }
// If GetPermissions fails, pretend like it is ok. File open will fail if // If GetPermissions fails, pretend like it is ok. File open will fail if
// the file is not writable // the file is not writable
std::ofstream file(fileName.c_str(), cmsys::ofstream file(fileName.c_str(),
overwrite?std::ios::out : std::ios::app); overwrite?std::ios::out : std::ios::app);
if ( !file ) if ( !file )
{ {

View File

@ -10,6 +10,7 @@
See the License for more information. See the License for more information.
============================================================================*/ ============================================================================*/
#include "cmXMLParser.h" #include "cmXMLParser.h"
#include <cmsys/FStream.hxx>
#include <cm_expat.h> #include <cm_expat.h>
#include <ctype.h> #include <ctype.h>
@ -45,7 +46,7 @@ int cmXMLParser::ParseFile(const char* file)
return 0; return 0;
} }
std::ifstream ifs(file); cmsys::ifstream ifs(file);
if ( !ifs ) if ( !ifs )
{ {
return 0; return 0;

View File

@ -28,6 +28,7 @@
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
// only build kdevelop generator on non-windows platforms // only build kdevelop generator on non-windows platforms
// when not bootstrapping cmake // when not bootstrapping cmake
@ -1861,7 +1862,7 @@ void cmake::UpdateConversionPathTable()
if(tablepath) if(tablepath)
{ {
std::ifstream table( tablepath ); cmsys::ifstream table( tablepath );
if(!table) if(!table)
{ {
cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath,
@ -2387,7 +2388,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
// echo results to stdout if needed // echo results to stdout if needed
if (writeToStdout) if (writeToStdout)
{ {
FILE* fin = fopen(resultFile.c_str(), "r"); FILE* fin = cmsys::SystemTools::Fopen(resultFile.c_str(), "r");
if(fin) if(fin)
{ {
const int bufferSize = 4096; const int bufferSize = 4096;
@ -2421,9 +2422,9 @@ static bool cmakeCheckStampFile(const char* stampName)
std::string stampDepends = stampName; std::string stampDepends = stampName;
stampDepends += ".depend"; stampDepends += ".depend";
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary);
#else #else
std::ifstream fin(stampDepends.c_str(), std::ios::in); cmsys::ifstream fin(stampDepends.c_str(), std::ios::in);
#endif #endif
if(!fin) if(!fin)
{ {
@ -2464,7 +2465,7 @@ static bool cmakeCheckStampFile(const char* stampName)
{ {
// TODO: Teach cmGeneratedFileStream to use a random temp file (with // TODO: Teach cmGeneratedFileStream to use a random temp file (with
// multiple tries in unlikely case of conflict) and use that here. // multiple tries in unlikely case of conflict) and use that here.
std::ofstream stamp(stampTemp); cmsys::ofstream stamp(stampTemp);
stamp << "# CMake generation timestamp file for this directory.\n"; stamp << "# CMake generation timestamp file for this directory.\n";
} }
if(cmSystemTools::RenameFile(stampTemp, stampName)) if(cmSystemTools::RenameFile(stampTemp, stampName))
@ -2494,7 +2495,7 @@ static bool cmakeCheckStampList(const char* stampList)
<< "is missing.\n"; << "is missing.\n";
return false; return false;
} }
std::ifstream fin(stampList); cmsys::ifstream fin(stampList);
if(!fin) if(!fin)
{ {
std::cout << "CMake is re-running because generate.stamp.list " std::cout << "CMake is re-running because generate.stamp.list "

View File

@ -139,7 +139,7 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile,
std::sort(incs.begin(), incs.end()); std::sort(incs.begin(), incs.end());
incs.erase(std::unique(incs.begin(), incs.end()), incs.end()); incs.erase(std::unique(incs.begin(), incs.end()), incs.end());
FILE* out = fopen(dfile.c_str(), "wb"); FILE* out = cmsys::SystemTools::Fopen(dfile.c_str(), "wb");
// FIXME should this be fatal or not? delete obj? delete d? // FIXME should this be fatal or not? delete obj? delete d?
if (!out) if (!out)

View File

@ -23,6 +23,7 @@
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/FStream.hxx>
#if defined(CMAKE_HAVE_VS_GENERATORS) #if defined(CMAKE_HAVE_VS_GENERATORS)
#include "cmCallVisualStudioMacro.h" #include "cmCallVisualStudioMacro.h"
@ -376,7 +377,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmSystemTools::RemoveADirectory(dirName.c_str()); cmSystemTools::RemoveADirectory(dirName.c_str());
// is the last argument a filename that exists? // is the last argument a filename that exists?
FILE *countFile = fopen(args[3].c_str(),"r"); FILE *countFile = cmsys::SystemTools::Fopen(args[3].c_str(),"r");
int count; int count;
if (countFile) if (countFile)
{ {
@ -396,7 +397,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// write the count into the directory // write the count into the directory
std::string fName = dirName; std::string fName = dirName;
fName += "/count.txt"; fName += "/count.txt";
FILE *progFile = fopen(fName.c_str(),"w"); FILE *progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w");
if (progFile) if (progFile)
{ {
fprintf(progFile,"%i\n",count); fprintf(progFile,"%i\n",count);
@ -417,7 +418,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// read the count // read the count
fName = dirName; fName = dirName;
fName += "/count.txt"; fName += "/count.txt";
progFile = fopen(fName.c_str(),"r"); progFile = cmsys::SystemTools::Fopen(fName.c_str(),"r");
int count = 0; int count = 0;
if (!progFile) if (!progFile)
{ {
@ -437,7 +438,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
fName = dirName; fName = dirName;
fName += "/"; fName += "/";
fName += args[i]; fName += args[i];
progFile = fopen(fName.c_str(),"w"); progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w");
if (progFile) if (progFile)
{ {
fprintf(progFile,"empty"); fprintf(progFile,"empty");
@ -946,7 +947,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1); cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1);
// Read command lines from the script. // Read command lines from the script.
std::ifstream fin(args[2].c_str()); cmsys::ifstream fin(args[2].c_str());
if(!fin) if(!fin)
{ {
std::cerr << "Error opening link script \"" std::cerr << "Error opening link script \""
@ -1057,7 +1058,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
// check for nmake temporary files // check for nmake temporary files
if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 )
{ {
std::ifstream fin(i->substr(1).c_str()); cmsys::ifstream fin(i->substr(1).c_str());
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(fin, while(cmSystemTools::GetLineFromStream(fin,
line)) line))
@ -1229,7 +1230,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
std::cout << "Create " << resourceInputFile.c_str() << "\n"; std::cout << "Create " << resourceInputFile.c_str() << "\n";
} }
// Create input file for rc command // Create input file for rc command
std::ofstream fout(resourceInputFile.c_str()); cmsys::ofstream fout(resourceInputFile.c_str());
if(!fout) if(!fout)
{ {
return -1; return -1;
@ -1252,7 +1253,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
{ {
std::cout << "Create empty: " << manifestFile.c_str() << "\n"; std::cout << "Create empty: " << manifestFile.c_str() << "\n";
} }
std::ofstream foutTmp(manifestFile.c_str()); cmsys::ofstream foutTmp(manifestFile.c_str());
} }
std::string resourceFile = manifestFile; std::string resourceFile = manifestFile;
resourceFile += ".res"; resourceFile += ".res";