summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Client.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2005-01-11 03:59:42 +0000
committerMichi Henning <michi@zeroc.com>2005-01-11 03:59:42 +0000
commitbfdd46fc78552716f25900de5b75a6aff79c6d7c (patch)
treeb0078934828f0c08be6d5f2bf12757e1010f5ed1 /cpp/src/IcePatch2/Client.cpp
parentCommented out the delete[] args calls again -- I couldn't reproduce a (diff)
downloadice-bfdd46fc78552716f25900de5b75a6aff79c6d7c.tar.bz2
ice-bfdd46fc78552716f25900de5b75a6aff79c6d7c.tar.xz
ice-bfdd46fc78552716f25900de5b75a6aff79c6d7c.zip
Minor refactoring of IcePatch2.
Diffstat (limited to 'cpp/src/IcePatch2/Client.cpp')
-rw-r--r--cpp/src/IcePatch2/Client.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index 8c9581061f2..ce6752b215b 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -14,6 +14,7 @@
#ifdef _WIN32
# include <conio.h>
+# include <direct.h>
#else
# include <fcntl.h>
# include <termios.h>
@@ -253,11 +254,25 @@ Client::run(int argc, char* argv[])
usage(argv[0]);
return EXIT_FAILURE;
}
- if(args.size() == 1)
+ if(args.empty())
{
- properties->setProperty("IcePatch2.Directory", args[0]);
+ cerr << argv[0] << ": no data directory specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ //
+ // Make working directory the data directory *before* calling normalize() for
+ // for the first time (because normalize caches the current working directory).
+ //
+ if(chdir(args[0].c_str()) != 0)
+ {
+ string msg = "cannot change working directory to `" + args[0] + "': " + lastError();
+ throw msg;
}
+ properties->setProperty("IcePatch2.Directory", normalize("."));
+
bool aborted = false;
try
@@ -269,7 +284,7 @@ Client::run(int argc, char* argv[])
if(!aborted)
{
- aborted = !patcher->patch("");
+ aborted = !patcher->patch(".");
}
if(!aborted)
@@ -303,7 +318,7 @@ Client::usage(const string& appName)
"-v, --version Display the Ice version.\n"
"-t, --thorough Recalculate all checksums.";
- cerr << "Usage: " << appName << " [options] [DIR]" << endl;
+ cerr << "Usage: " << appName << " [options] DIR" << endl;
cerr << options << endl;
}