diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-05-16 09:17:11 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-05-16 09:17:11 +0000 |
commit | 2a7c529781e732c847cde3c421de549f4436c42c (patch) | |
tree | 333f229ca3ba86ff5f26b214539c89d8bca7ee9d | |
parent | 32630dc6beebc5ef01497711e2d0ee3ec26fd174 (diff) |
Use FileModificationTime instead of raw stat() on Windows.
Fixes test failures caused by using seconds since epoch on Windows, instead
of a box_time_t, and rounding it to the nearest 10^6, which is fine for a
box_time_t (all other platforms), but 10^6 seconds is a rather long time to
ignore changes for on Windows.
This also makes it possible to support subsecond precision on Windows
via FileModificationTime() in future, and have RaidFile detect such subsecond
changes.
-rw-r--r-- | lib/raidfile/RaidFileUtil.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/raidfile/RaidFileUtil.cpp b/lib/raidfile/RaidFileUtil.cpp index 33438371..48625997 100644 --- a/lib/raidfile/RaidFileUtil.cpp +++ b/lib/raidfile/RaidFileUtil.cpp @@ -59,8 +59,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet, *pExistingFiles = 0; } - // For stat call, although the results are not examined - struct stat st; + EMU_STRUCT_STAT st; // check various files int startDisc = 0; @@ -70,19 +69,14 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet, { *pStartDisc = startDisc; } - if(::stat(writeFile.c_str(), &st) == 0) + if(EMU_STAT(writeFile.c_str(), &st) == 0) { // write file exists, use that // Get unique ID if(pRevisionID != 0) { - #ifdef WIN32 - *pRevisionID = st.st_mtime; - #else - *pRevisionID = FileModificationTime(st); - #endif - + *pRevisionID = FileModificationTime(st); *pRevisionID = adjust_timestamp(*pRevisionID, st.st_size); } @@ -102,7 +96,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet, for(int f = 0; f < setSize; ++f) { std::string componentFile(RaidFileUtil::MakeRaidComponentName(rDiscSet, rFilename, (f + startDisc) % setSize)); - if(::stat(componentFile.c_str(), &st) == 0) + if(EMU_STAT(componentFile.c_str(), &st) == 0) { // Component file exists, add to count rfCount++; @@ -114,12 +108,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet, // Revision ID if(pRevisionID != 0) { - #ifdef WIN32 - int64_t rid = st.st_mtime; - #else - int64_t rid = FileModificationTime(st); - #endif - + int64_t rid = FileModificationTime(st); if(rid > revisionID) revisionID = rid; revisionIDplus += st.st_size; } |