summaryrefslogtreecommitdiff
path: root/lib/raidfile/RaidFileUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/raidfile/RaidFileUtil.cpp')
-rw-r--r--lib/raidfile/RaidFileUtil.cpp58
1 files changed, 40 insertions, 18 deletions
diff --git a/lib/raidfile/RaidFileUtil.cpp b/lib/raidfile/RaidFileUtil.cpp
index da23cef5..7c6299ec 100644
--- a/lib/raidfile/RaidFileUtil.cpp
+++ b/lib/raidfile/RaidFileUtil.cpp
@@ -22,17 +22,21 @@
// --------------------------------------------------------------------------
//
// Function
-// Name: RaidFileUtil::RaidFileExists(RaidFileDiscSet &, const std::string &)
-// Purpose: Check to see the state of a RaidFile on disc (doesn't look at contents,
-// just at existense of files)
+// Name: RaidFileUtil::RaidFileExists(RaidFileDiscSet &,
+// const std::string &, int *, int *, int64_t *)
+// Purpose: Check to see the state of a RaidFile on disc
+// (doesn't look at contents, just at existence of
+// files)
// Created: 2003/07/11
//
// --------------------------------------------------------------------------
-RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet, const std::string &rFilename, int *pStartDisc, int *pExisitingFiles, int64_t *pRevisionID)
+RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
+ const std::string &rFilename, int *pStartDisc, int *pExistingFiles,
+ int64_t *pRevisionID)
{
- if(pExisitingFiles)
+ if(pExistingFiles)
{
- *pExisitingFiles = 0;
+ *pExistingFiles = 0;
}
// For stat call, although the results are not examined
@@ -53,11 +57,20 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
// Get unique ID
if(pRevisionID != 0)
{
- (*pRevisionID) = FileModificationTime(st);
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
- // On linux, the time resolution is very low for modification times.
- // So add the size to it to give a bit more chance of it changing.
+ #ifdef WIN32
+ *pRevisionID = st.st_mtime;
+ #else
+ *pRevisionID = FileModificationTime(st);
+ #endif
+
+#ifdef BOX_RELEASE_BUILD
+ // The resolution of timestamps may be very
+ // low, e.g. 1 second. So add the size to it
+ // to give a bit more chance of it changing.
// TODO: Make this better.
+ // Disabled in debug mode, to simulate
+ // filesystem with 1-second timestamp
+ // resolution, e.g. MacOS X HFS, Linux.
(*pRevisionID) += st.st_size;
#endif
}
@@ -71,10 +84,10 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
int64_t revisionID = 0;
int setSize = rDiscSet.size();
int rfCount = 0;
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
+
// TODO: replace this with better linux revision ID detection
int64_t revisionIDplus = 0;
-#endif
+
for(int f = 0; f < setSize; ++f)
{
std::string componentFile(RaidFileUtil::MakeRaidComponentName(rDiscSet, rFilename, (f + startDisc) % setSize));
@@ -83,25 +96,34 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
// Component file exists, add to count
rfCount++;
// Set flags for existance?
- if(pExisitingFiles)
+ if(pExistingFiles)
{
- (*pExisitingFiles) |= (1 << f);
+ (*pExistingFiles) |= (1 << f);
}
// Revision ID
if(pRevisionID != 0)
{
- int64_t rid = FileModificationTime(st);
+ #ifdef WIN32
+ int64_t rid = st.st_mtime;
+ #else
+ int64_t rid = FileModificationTime(st);
+ #endif
+
if(rid > revisionID) revisionID = rid;
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
revisionIDplus += st.st_size;
-#endif
}
}
}
if(pRevisionID != 0)
{
(*pRevisionID) = revisionID;
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
+#ifdef BOX_RELEASE_BUILD
+ // The resolution of timestamps may be very low, e.g.
+ // 1 second. So add the size to it to give a bit more
+ // chance of it changing.
+ // TODO: Make this better.
+ // Disabled in debug mode, to simulate filesystem with
+ // 1-second timestamp resolution, e.g. MacOS X HFS, Linux.
(*pRevisionID) += revisionIDplus;
#endif
}