summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Client.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-12-06 21:00:28 +0000
committerMarc Laukien <marc@zeroc.com>2004-12-06 21:00:28 +0000
commitd0be319d1296891a164b7f62d3917024f43f5399 (patch)
tree832fc4f21223778a745cfdf124c9969f73377164 /cpp/src/IcePatch2/Client.cpp
parentfixes (diff)
downloadice-d0be319d1296891a164b7f62d3917024f43f5399.tar.bz2
ice-d0be319d1296891a164b7f62d3917024f43f5399.tar.xz
ice-d0be319d1296891a164b7f62d3917024f43f5399.zip
patcher enhancements
Diffstat (limited to 'cpp/src/IcePatch2/Client.cpp')
-rw-r--r--cpp/src/IcePatch2/Client.cpp77
1 files changed, 52 insertions, 25 deletions
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index db24c1cc0ea..d36cdb6d8f0 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -31,6 +31,7 @@ public:
#ifndef _WIN32
tcgetattr(0, &_savedTerm);
_savedFlags = fcntl(0, F_GETFL);
+ _block = true;
#endif
}
@@ -58,27 +59,31 @@ public:
}
}
while(answer != "yes");
- cout << "Calculating checksums -- please wait, this might take awhile..." << endl;
return true;
}
virtual bool
- fileListStart()
+ checksumStart()
{
-#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
+ return !keyPressed();
+ }
- cout << "[Press any key to abort]" << endl;
+ virtual bool
+ checksumProgress(const string& path)
+ {
+ cout << "Calculating checksum for " << getBasename(path) << endl;
+ return !keyPressed();
+ }
+
+ virtual bool
+ checksumEnd()
+ {
+ return !keyPressed();
+ }
+
+ virtual bool
+ fileListStart()
+ {
_lastProgress = "0%";
cout << "Getting list of files to patch: " << _lastProgress << flush;
return !keyPressed();
@@ -138,32 +143,59 @@ public:
private:
+#ifdef _WIN32
+
bool
keyPressed()
{
bool pressed = false;
-#ifdef _WIN32
while(_kbhit())
{
pressed = true;
_getch();
}
+ return pressed;
+ }
+
#else
+
+ bool
+ keyPressed()
+ {
+ if(_block)
+ {
+ 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);
+
+ _block = false;
+
+ cout << "[Press any key to abort]" << endl;
+ }
+
+ bool pressed = false;
char c;
while(read(0, &c, 1) > 0)
{
pressed = true;
}
-#endif
return pressed;
}
- string _lastProgress;
-
-#ifndef _WIN32
termios _savedTerm;
int _savedFlags;
+ bool _block;
+
#endif
+
+ string _lastProgress;
};
class Client : public Application
@@ -219,11 +251,6 @@ Client::run(int argc, char* argv[])
}
}
- if(properties->getPropertyAsInt("IcePatch2.Thorough") > 0)
- {
- cout << "Calculating checksums -- please wait, this might take awhile..." << endl;
- }
-
bool aborted = false;
try