Return to stripcrs.cpp CVS log | Up to [Pegasus] / pegasus / src / utils / stripcrs |
File: [Pegasus] / pegasus / src / utils / stripcrs / stripcrs.cpp
(download)
Revision: 1.4, Tue Apr 2 08:32:53 2002 UTC (22 years, 3 months ago) by kumpf Branch: MAIN CVS Tags: test, pep_88, mday-merge-start, mday-merge-pegasus/src/Pegasus/Server, mday-merge-pegasus/src/Pegasus/Common, mday-2-0-patches, VERSION_2_1_RELEASE_HEAD, VERSION_2_1_RELEASE_BRANCH, VERSION_2_1_RELEASE, VERSION_2_1_1_RELEASE, VERSION_2_01_01, VERSION_2_00_RC_4, VERSION_2_00_RC_3, VERSION_2_00_RC_2, VERSION_2_00_RC_1, VERSION_2_00_BRANCH, VERSION_1_10, VERSION_1_09, TEST, RELEASE_2_3_0-msg-freeze, RELEASE_2_2_1-snapshot, RELEASE_2_2_0_0-release, RELEASE_2_2_0-root, RELEASE_2_2_0-branch, RELEASE_2_2-root, PRE_LICENSE_UPDATE_2003, PEGASUS_FC_VERSION_2_2, LOCAL_ASSOCPROV-ROOT, LOCAL_ASSOCPROV-BRANCH Changes since 1.3: +1 -1 lines DME: Add stripcrs to build to support comparison of test scripts on multiple platforms. |
#include <Pegasus/Common/Config.h> #include <fstream> #include <string> #include <iostream> #include <cstdlib> #ifdef PEGASUS_OS_TYPE_WINDOWS # include <direct.h> #else # include <unistd.h> #endif PEGASUS_USING_STD; bool RemoveFile(const string& path) { #ifdef OS_TYPE_WINDOWS return _unlink(path.c_str()) == 0; #else return unlink(path.c_str()) == 0; #endif } bool CopyFile(const string& fromFile, const string& toFile) { // Open input file: ifstream is(fromFile.c_str() PEGASUS_IOS_BINARY); if (!is) return false; // Open output file: ofstream os(toFile.c_str() PEGASUS_IOS_BINARY); if (!os) return false; char c; while (is.get(c)) os.put(c); return true; } const char* arg0 = ""; void ProcessFile(const char* fileName) { ifstream is(fileName PEGASUS_IOS_BINARY); if (!is) { cerr << arg0 << "warning: failed to open \"" << fileName << "\""; cerr << endl; return; } const char TEMP_FILE_NAME[] = "stripcrs.tmp"; ofstream os(TEMP_FILE_NAME PEGASUS_IOS_BINARY); if (!os) { cerr << arg0 << ": failed to open \""; cerr << TEMP_FILE_NAME << "\"" << endl; exit(1); } char c; while (is.get(c)) { if (c != '\r') os.put(c); } is.close(); os.close(); if (!CopyFile(TEMP_FILE_NAME, fileName)) { cerr << arg0 << ": failed to copy back file" << endl; exit(1); } RemoveFile(TEMP_FILE_NAME); } int main(int argc, char** argv) { if (argc < 2) { cerr << "Usage: " << argv[0] << " filenames..." << endl; exit(1); } for (int i = 1; i < argc; i++) { cout << argv[i] << endl; ProcessFile(argv[i]); } return 0; }
No CVS admin address has been configured |
Powered by ViewCVS 0.9.2 |