[Box Backup-commit] COMMIT r1102 - box/trunk/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Fri, 27 Oct 2006 19:54:22 +0100
Author: chris
Date: 2006-10-27 19:54:22 +0100 (Fri, 27 Oct 2006)
New Revision: 1102
Modified:
box/trunk/lib/common/Test.h
Log:
Convert UNIX paths to native on Win32 (avoids #ifdefs in tests)
Modified: box/trunk/lib/common/Test.h
===================================================================
--- box/trunk/lib/common/Test.h 2006-10-27 18:53:20 UTC (rev 1101)
+++ box/trunk/lib/common/Test.h 2006-10-27 18:54:22 UTC (rev 1102)
@@ -79,11 +79,31 @@
return -1;
}
-inline int LaunchServer(const char *CommandLine, const char *pidFile)
+inline int LaunchServer(const char *pCommandLine, const char *pidFile)
{
- if(::system(CommandLine) != 0)
+#ifdef WIN32
+ // convert UNIX paths to native
+
+ std::string command;
+ for (int i = 0; pCommandLine[i] != 0; i++)
{
- printf("Server: %s\n", CommandLine);
+ if (pCommandLine[i] == '/')
+ {
+ command += '\\';
+ }
+ else
+ {
+ command += pCommandLine[i];
+ }
+ }
+
+#else // !WIN32
+ std::string command = pCommandLine;
+#endif
+
+ if(::system(command.c_str()) != 0)
+ {
+ printf("Server: %s\n", command.c_str());
TEST_FAIL_WITH_MESSAGE("Couldn't start server");
return -1;
}
@@ -93,7 +113,7 @@
// read pid file
if(!TestFileExists(pidFile))
{
- printf("Server: %s\n", CommandLine);
+ printf("Server: %s\n", command.c_str());
TEST_FAIL_WITH_MESSAGE("Server didn't save PID file");
return -1;
}
@@ -102,7 +122,7 @@
int pid = -1;
if(f == NULL || fscanf(f, "%d", &pid) != 1)
{
- printf("Server: %s (pidfile %s)\n", CommandLine, pidFile);
+ printf("Server: %s (pidfile %s)\n", command.c_str(), pidFile);
TEST_FAIL_WITH_MESSAGE("Couldn't read PID file");
return -1;
}