diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-04-22 20:52:15 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-04-22 20:52:15 +0000 |
commit | e89ceeb26d5ccb022ad55615266c57298a90e6f4 (patch) | |
tree | fc1baeff35c7752fd8d96ba1b4f1b824e8d611ab /test | |
parent | e94c3e5e551271ebdb98f444850de873dc4837f0 (diff) |
Use Cygwin chmod command-line tool to make the read-only file writable
on Win32, instead of our own chmod() (which does nothing). (refs #3)
Diffstat (limited to 'test')
-rw-r--r-- | test/bbackupd/testbbackupd.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 7d703492..d869d5d5 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -1809,11 +1809,31 @@ int test_bbackupd() // Then modify an existing file { - chmod("testfiles/TestDir1/sub23/rand.h", 0777); // in the archive, it's read only - FILE *f = fopen("testfiles/TestDir1/sub23/rand.h", "w+"); + // in the archive, it's read only + #ifdef WIN32 + TEST_THAT(::system("chmod 0777 testfiles" + "/TestDir1/sub23/rand.h") == 0); + #else + TEST_THAT(chmod("testfiles/TestDir1/sub23" + "/rand.h", 0777) == 0); + #endif + + FILE *f = fopen("testfiles/TestDir1/sub23/rand.h", + "w+"); + + if (f == 0) + { + perror("Failed to open"); + } + TEST_THAT(f != 0); - fprintf(f, "MODIFIED!\n"); - fclose(f); + + if (f != 0) + { + fprintf(f, "MODIFIED!\n"); + fclose(f); + } + // and then move the time backwards! struct timeval times[2]; BoxTimeToTimeval(SecondsToBoxTime((time_t)(365*24*60*60)), times[1]); |