diff options
author | Marc Laukien <marc@zeroc.com> | 2004-12-01 19:42:56 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2004-12-01 19:42:56 +0000 |
commit | c1d356378e732070e3b60ab181a0b93a2d031078 (patch) | |
tree | 24d9084ce56f2ca98e210dbbc051f4aff91775e1 /cpp/src | |
parent | fixes (diff) | |
download | ice-c1d356378e732070e3b60ab181a0b93a2d031078.tar.bz2 ice-c1d356378e732070e3b60ab181a0b93a2d031078.tar.xz ice-c1d356378e732070e3b60ab181a0b93a2d031078.zip |
fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IcePatch2/Client.cpp | 46 | ||||
-rwxr-xr-x | cpp/src/IcePatch2/ClientUtil.cpp | 21 | ||||
-rw-r--r-- | cpp/src/IcePatch2/Util.cpp | 29 |
3 files changed, 60 insertions, 36 deletions
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp index 55519ee0f5b..7d066a94672 100644 --- a/cpp/src/IcePatch2/Client.cpp +++ b/cpp/src/IcePatch2/Client.cpp @@ -47,17 +47,7 @@ public: { #ifndef _WIN32 tcgetattr(0, &_savedTerm); - termios term; - memcpy(&term, &_savedTerm, sizeof(termios)); - term.c_lflag &= ~(ECHO | ICANON); - term.c_cc[VTIME] = 0; - term.c_cc[VMIN] = 1; - tcsetattr(0, TCSANOW, &term); - _savedFlags = fcntl(0, F_GETFL); - int flags = _savedFlags; - flags |= O_NONBLOCK; - fcntl(0, F_SETFL, flags); #endif } @@ -92,7 +82,20 @@ public: virtual bool fileListStart() { - cout << "[Press any key to interrupt]" << endl; +#ifndef _WIN32 + termios term; + memcpy(&term, &_savedTerm, sizeof(termios)); + term.c_lflag &= ~(ECHO | ICANON); + term.c_cc[VTIME] = 0; + term.c_cc[VMIN] = 1; + tcsetattr(0, TCSANOW, &term); + + int flags = _savedFlags; + flags |= O_NONBLOCK; + fcntl(0, F_SETFL, flags); +#endif + + cout << "[Press any key to abort]" << endl; _lastProgress = "0%"; cout << "Getting list of files to patch: " << _lastProgress << flush; return !keyPressed(); @@ -231,13 +234,22 @@ IcePatch2::Client::run(int argc, char* argv[]) cout << "Calculating checksums -- please wait, this might take awhile..." << endl; } - bool patchComplete = false; + bool aborted = false; try { PatcherFeedbackPtr feedback = new TextPatcherFeedback; PatcherPtr patcher = new Patcher(communicator(), feedback); - patchComplete = patcher->patch(); + + if(!aborted) + { + aborted = !patcher->prepare(); + } + + if(!aborted) + { + aborted = !patcher->patch(); + } } catch(const string& ex) { @@ -245,14 +257,14 @@ IcePatch2::Client::run(int argc, char* argv[]) return EXIT_FAILURE; } - if(patchComplete) + if(aborted) { - return EXIT_SUCCESS; + cout << "\n[Aborted]" << endl; + return EXIT_FAILURE; } else { - cout << "\n[Interrupted]" << endl; - return EXIT_FAILURE; + return EXIT_SUCCESS; } } diff --git a/cpp/src/IcePatch2/ClientUtil.cpp b/cpp/src/IcePatch2/ClientUtil.cpp index 90382121646..45962862b7d 100755 --- a/cpp/src/IcePatch2/ClientUtil.cpp +++ b/cpp/src/IcePatch2/ClientUtil.cpp @@ -172,20 +172,20 @@ IcePatch2::Patcher::patch() { return false; } - + if(!_dryRun) { saveFileInfoSeq(_dataDir, _localFiles); } } - + if(!_updateFiles.empty()) { if(!updateFiles(_updateFiles)) { return false; } - + if(!_dryRun) { saveFileInfoSeq(_dataDir, _localFiles); @@ -200,20 +200,9 @@ IcePatch2::Patcher::removeFiles(const FileInfoSeq& files) { if(!_dryRun) { - FileInfoSeq::const_iterator p = files.begin(); - - while(p != files.end()) + for(FileInfoSeq::const_reverse_iterator p = files.rbegin(); p != files.rend(); ++p) { - removeRecursive(_dataDir + '/' + p->path); - - string dir = p->path + '/'; - - do - { - ++p; - } - while(p != files.end() && p->path.size() > dir.size() && - p->path.compare(0, dir.size(), dir) == 0); + remove(_dataDir + '/' + p->path); } FileInfoSeq newLocalFiles; diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp index b4f610723bf..ce6c081754b 100644 --- a/cpp/src/IcePatch2/Util.cpp +++ b/cpp/src/IcePatch2/Util.cpp @@ -335,9 +335,29 @@ IcePatch2::remove(const string& pa) { const string path = normalize(pa); - if(::remove(path.c_str()) == -1) + struct stat buf; + if(stat(path.c_str(), &buf) == -1) + { + throw "cannot stat `" + path + "': " + lastError(); + } + + if(S_ISDIR(buf.st_mode)) + { +#ifdef _WIN32 + if(_rmdir(path.c_str()) == -1) +#else + if(rmdir(path.c_str()) == -1) +#endif + { + throw "cannot remove directory `" + path + "': " + lastError(); + } + } + else { - throw "cannot remove file `" + path + "': " + lastError(); + if(::remove(path.c_str()) == -1) + { + throw "cannot remove file `" + path + "': " + lastError(); + } } } @@ -371,7 +391,10 @@ IcePatch2::removeRecursive(const string& pa) } else { - remove(path); + if(::remove(path.c_str()) == -1) + { + throw "cannot remove file `" + path + "': " + lastError(); + } } } |