#include <MsgCatStream.h>
Public Member Functions | |
| MsgCatStream () | |
| MsgCatStream (const char *fileName) | |
| ~MsgCatStream () | |
| const char * | GetOutputFileName () const |
| void | SetOutputFile (const char *filename) |
| void | AddFileToList (const char *filename) |
| void | DoConcatenation () |
Private Attributes | |
| string | fOutFile |
| vector< string > | fFileList |
Friends | |
| ostream & | operator<< (ostream &os, const MsgCatStream &m) |
|
|
Definition at line 41 of file MsgCatStream.cxx. 00041 : fOutFile("") { }
|
|
|
Definition at line 45 of file MsgCatStream.cxx. 00045 : fOutFile(fileName) { }
|
|
|
Definition at line 49 of file MsgCatStream.cxx. 00049 { }
|
|
|
Definition at line 53 of file MsgCatStream.cxx. References fFileList. Referenced by MsgService::AddCatStream(). 00054 {
00055 //======================================================================
00056 // Purpose: Add a file to the list of files to be concatenated
00057 // Inputs: filename - the name of the file that will be concatenated
00058 //======================================================================
00059 string aName(filename);
00060 fFileList.push_back(aName);
00061 }
|
|
|
Definition at line 65 of file MsgCatStream.cxx. References fFileList, and fOutFile. 00066 {
00067 //======================================================================
00068 // Purpose: Concatenate the contents of the files in the fFileList list
00069 // to a single output file fOutFile. The files in the fFileList
00070 // *are deleted* once their contents have been copied to
00071 // fOutFile
00072 //======================================================================
00073 // Open the output file
00074 ofstream outFile(fOutFile.c_str());
00075 if (!outFile) {
00076 cerr << "=E= " << __FILE__ << ":" << __LINE__
00077 << " Can't open file " << fOutFile
00078 << " for write."
00079 << " Concatenation not performed\n";
00080 return;
00081 }
00082
00083 // Append the contents of each file in the list to outFile and
00084 // delete the file
00085 vector<string>::iterator vend(fFileList.end());
00086 for (vector<string>::iterator itrMsgName = fFileList.begin();
00087 itrMsgName != vend;
00088 ++itrMsgName) {
00089 ifstream *inFile;
00090 inFile = new ifstream(itrMsgName->c_str());
00091 if ((*inFile)) {
00092 char ch;
00093 while (inFile->get(ch)) outFile.put(ch);
00094 delete inFile;
00095 if ( unlink(itrMsgName->c_str()) != 0) {
00096 cerr << "=W= " << __FILE__ << ":" << __LINE__
00097 << "Failed to unlink file '"
00098 << (*itrMsgName) << "'.\n";
00099 }
00100 }
00101 else {
00102 // Input stream didn't open correctly
00103 cerr << "=E= " << __FILE__ << ":" << __LINE__
00104 << " Can't open file " << (*itrMsgName)
00105 << " for read."
00106 << " File skipped\n";
00107 continue;
00108 }
00109 }
00110 }
|
|
|
Definition at line 38 of file MsgCatStream.h. 00038 { return fOutFile.c_str(); }
|
|
|
Definition at line 40 of file MsgCatStream.h. 00040 {fOutFile = filename; }
|
|
||||||||||||
|
Definition at line 20 of file MsgCatStream.cxx. 00021 {
00022 //======================================================================
00023 // Purpose: Print information about a MsgCatStream
00024 // Inputs : os - stream to print to
00025 // m - MsgCatStream to print
00026 // Returns: The stream printed to
00027 //======================================================================
00028 vector<string>::const_iterator vend(m.fFileList.end());
00029 os << m.fOutFile << ":";
00030 for (vector<string>::const_iterator itrFileName = m.fFileList.begin();
00031 itrFileName != vend;
00032 ++itrFileName) {
00033 os << " " << *itrFileName;
00034 }
00035 os << "\n";
00036 return os;
00037 }
|
|
|
Definition at line 45 of file MsgCatStream.h. Referenced by AddFileToList(), DoConcatenation(), and operator<<(). |
|
|
Definition at line 44 of file MsgCatStream.h. Referenced by DoConcatenation(), and operator<<(). |
1.3.9.1