Commit 06216f0b authored by Brad King's avatar Brad King
Browse files

SystemTools: Return Status from FileTimeCompare

parent fadfd7a0
...@@ -1454,8 +1454,8 @@ Status SystemTools::Touch(std::string const& filename, bool create) ...@@ -1454,8 +1454,8 @@ Status SystemTools::Touch(std::string const& filename, bool create)
return Status::Success(); return Status::Success();
} }
bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, Status SystemTools::FileTimeCompare(std::string const& f1,
int* result) std::string const& f2, int* result)
{ {
// Default to same time. // Default to same time.
*result = 0; *result = 0;
...@@ -1463,11 +1463,11 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, ...@@ -1463,11 +1463,11 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2,
// POSIX version. Use stat function to get file modification time. // POSIX version. Use stat function to get file modification time.
struct stat s1; struct stat s1;
if (stat(f1.c_str(), &s1) != 0) { if (stat(f1.c_str(), &s1) != 0) {
return false; return Status::POSIX_errno();
} }
struct stat s2; struct stat s2;
if (stat(f2.c_str(), &s2) != 0) { if (stat(f2.c_str(), &s2) != 0) {
return false; return Status::POSIX_errno();
} }
# if KWSYS_CXX_STAT_HAS_ST_MTIM # if KWSYS_CXX_STAT_HAS_ST_MTIM
// Compare using nanosecond resolution. // Compare using nanosecond resolution.
...@@ -1505,17 +1505,17 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, ...@@ -1505,17 +1505,17 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2,
WIN32_FILE_ATTRIBUTE_DATA f2d; WIN32_FILE_ATTRIBUTE_DATA f2d;
if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f1).c_str(), if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f1).c_str(),
GetFileExInfoStandard, &f1d)) { GetFileExInfoStandard, &f1d)) {
return false; return Status::Windows_GetLastError();
} }
if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f2).c_str(), if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f2).c_str(),
GetFileExInfoStandard, &f2d)) { GetFileExInfoStandard, &f2d)) {
return false; return Status::Windows_GetLastError();
} }
// Compare the file times using resolution provided by system call. // Compare the file times using resolution provided by system call.
*result = (int)CompareFileTime(&f1d.ftLastWriteTime, &f2d.ftLastWriteTime); *result = (int)CompareFileTime(&f1d.ftLastWriteTime, &f2d.ftLastWriteTime);
#endif #endif
return true; return Status::Success();
} }
// Return a capitalized string (i.e the first letter is uppercased, all other // Return a capitalized string (i.e the first letter is uppercased, all other
......
...@@ -348,8 +348,8 @@ public: ...@@ -348,8 +348,8 @@ public:
* When true is returned, result has -1, 0, +1 for * When true is returned, result has -1, 0, +1 for
* f1 older, same, or newer than f2. * f1 older, same, or newer than f2.
*/ */
static bool FileTimeCompare(const std::string& f1, const std::string& f2, static Status FileTimeCompare(std::string const& f1, std::string const& f2,
int* result); int* result);
/** /**
* Get the file extension (including ".") needed for an executable * Get the file extension (including ".") needed for an executable
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment