[Box Backup-commit] COMMIT r2174 - box/trunk/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Wed, 28 May 2008 13:36:53 +0100 (BST)
Author: chris
Date: 2008-05-28 13:36:53 +0100 (Wed, 28 May 2008)
New Revision: 2174
Modified:
box/trunk/lib/common/Test.cpp
Log:
Separate checks for file existing and file not empty.
Modified: box/trunk/lib/common/Test.cpp
===================================================================
--- box/trunk/lib/common/Test.cpp 2008-05-28 12:36:05 UTC (rev 2173)
+++ box/trunk/lib/common/Test.cpp 2008-05-28 12:36:53 UTC (rev 2174)
@@ -25,6 +25,12 @@
bool TestFileExists(const char *Filename)
{
struct stat st;
+ return ::stat(Filename, &st) == 0 && (st.st_mode & S_IFDIR) == 0;
+}
+
+bool TestFileNotEmpty(const char *Filename)
+{
+ struct stat st;
return ::stat(Filename, &st) == 0 && (st.st_mode & S_IFDIR) == 0 &&
st.st_size > 0;
}
@@ -102,7 +108,7 @@
int ReadPidFile(const char *pidFile)
{
- if(!TestFileExists(pidFile))
+ if(!TestFileNotEmpty(pidFile))
{
TEST_FAIL_WITH_MESSAGE("Server didn't save PID file "
"(perhaps one was already running?)");
@@ -194,7 +200,7 @@
for (int i = 0; i < 15; i++)
{
- if (TestFileExists(pidFile))
+ if (TestFileNotEmpty(pidFile))
{
break;
}
@@ -223,7 +229,7 @@
}
#endif
- if (!TestFileExists(pidFile))
+ if (!TestFileNotEmpty(pidFile))
{
::fprintf(stdout, " timed out!\n");
TEST_FAIL_WITH_MESSAGE("Server didn't save PID file");