get/setfiletime() removed, as they are only used by functions identical to existing fuptodate() and fexists(), which we use instead

This commit is contained in:
Frank Seide 2014-10-30 16:40:23 -07:00
Родитель 9fe2259f15
Коммит 88125bec4c
4 изменённых файлов: 10 добавлений и 35 удалений

Просмотреть файл

@ -668,15 +668,6 @@ namespace msra { namespace files {
vector<char*> fgetfilelines (const wstring & pathname, vector<char> & readbuffer);
};};
// ----------------------------------------------------------------------------
// getfiletime(), setfiletime(): access modification time
// ----------------------------------------------------------------------------
// Note: we use struct _FILETIME instead of FILETIME to avoid having to include Windows.h, for increased portability.
// As a next step, we shall make these two functions local to fileutil.cpp, and move all code that uses it in there as well.
bool getfiletime (const std::wstring & path, struct _FILETIME & time);
void setfiletime (const std::wstring & path, const struct _FILETIME & time);
// ----------------------------------------------------------------------------
// expand_wildcards() -- expand a path with wildcards (also intermediate ones)
// ----------------------------------------------------------------------------

Просмотреть файл

@ -51,9 +51,7 @@ template <> const wchar_t* GetScanFormatString(unsigned int) {return L" %u";
template <> const wchar_t* GetScanFormatString(unsigned long) {return L" %lu";}
template <> const wchar_t* GetScanFormatString(float) {return L" %g";}
template <> const wchar_t* GetScanFormatString(double) {return L" %lg";}
#if (SIZE_MAX != UINT_MAX) // on 32 bit platforms, the following will be flagged as a redefinition
template <> const wchar_t* GetScanFormatString(size_t) {return L" %llu";}
#endif
template <> const wchar_t* GetScanFormatString(long long) {return L" %lli";}
template <> const wchar_t* GetFormatString(char) {return L" %hc";}
@ -66,9 +64,7 @@ template <> const wchar_t* GetFormatString(unsigned int) {return L" %u";}
template <> const wchar_t* GetFormatString(unsigned long) {return L" %lu";}
template <> const wchar_t* GetFormatString(float) {return L" %.9g";}
template <> const wchar_t* GetFormatString(double) {return L" %.17g";}
#if (SIZE_MAX != UINT_MAX)
template <> const wchar_t* GetFormatString(size_t) { return L" %llu"; }
#endif
template <> const wchar_t* GetFormatString(long long) {return L" %lli";}
// ----------------------------------------------------------------------------
@ -1559,10 +1555,16 @@ bool msra::files::fuptodate (const wstring & target, const wstring & input, bool
if (!getfiletime (target, targettime)) return false; // target missing: need to update
FILETIME inputtime;
if (!getfiletime (input, inputtime)) return !inputrequired; // input missing: if required, pretend to be out of date as to force caller to fail
#if 1 // formerly called IsResultFileUpdateToDate()
// up to date if target has higher time stamp
return (targettime.dwHighDateTime > inputtime.dwHighDateTime) ||
(targettime.dwHighDateTime == inputtime.dwHighDateTime && targettime.dwLowDateTime >= inputtime.dwLowDateTime);
#else
ULARGE_INTEGER targett, inputt;
memcpy (&targett, &targettime, sizeof (targett));
memcpy (&inputt, &inputtime, sizeof (inputt));
return !(targett.QuadPart < inputt.QuadPart); // up to date if target not older than input
#endif
}
/// separate string by separator

Просмотреть файл

@ -1252,7 +1252,7 @@ protected:
{
const wstring prevEpochFile = GetModelNameForEpoch (e-1);
if (IsResultFileUpdateToDate (curEpochFile, prevEpochFile, false))
if (msra::files::fuptodate (curEpochFile, prevEpochFile, false))
{
firstEpoch = size_t(e)+1;
break;
@ -1264,23 +1264,6 @@ protected:
return firstEpoch;
}
//up to date if resultFile is older than srcFile or missing
// TODO: move this to fileutil.h to allow for portable implementation
bool IsResultFileUpdateToDate (const wstring & resultFile, const wstring & srcFile, const bool IsSrcFileNeeded)
{
FILETIME resultFileTime;
if (!getfiletime (resultFile, resultFileTime))
return false; // not up to date is resultFile is missing
FILETIME srcFileTime;
if (!getfiletime (srcFile, srcFileTime))
return !IsSrcFileNeeded; // srcFile missing: if required, the result file is not up to date
//up to date if resultFile has higher time stamp
return (resultFileTime.dwHighDateTime > srcFileTime.dwHighDateTime) ||
(resultFileTime.dwHighDateTime == srcFileTime.dwHighDateTime && resultFileTime.dwLowDateTime >= srcFileTime.dwLowDateTime);
}
AdaptationRegType ParseAdaptationRegType(wstring s)
{
transform(s.begin(), s.end(), s.begin(),tolower);

Просмотреть файл

@ -177,12 +177,11 @@ void DoCrossValidate(const ConfigParameters& config)
{
wstring cvModelPath = msra::strfun::wstrprintf (L"%ws.%lld", modelPath.c_str(), i);
FILETIME resultFileTime;
if (!getfiletime (cvModelPath, resultFileTime))
if (!fexists (cvModelPath))
{
fprintf(stderr, "model %ws does not exist.\n", cvModelPath.c_str());
if (finalModelEvaluated || !getfiletime (modelPath, resultFileTime))
continue; //file missing
if (finalModelEvaluated || !fexists (modelPath))
continue; // file missing
else
{
cvModelPath = modelPath;