diff options
Diffstat (limited to 'libs/androidfw/misc.cpp')
-rw-r--r-- | libs/androidfw/misc.cpp | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/libs/androidfw/misc.cpp b/libs/androidfw/misc.cpp index 9bdaf18a116a..93dcaf549a90 100644 --- a/libs/androidfw/misc.cpp +++ b/libs/androidfw/misc.cpp @@ -28,13 +28,11 @@ #include <sys/vfs.h> #endif // __linux__ +#include <cstring> +#include <cstdio> #include <errno.h> #include <sys/stat.h> -#include <cstdio> -#include <cstring> -#include <tuple> - namespace android { /* @@ -75,32 +73,27 @@ FileType getFileType(const char* fileName) } } -static ModDate getModDate(const struct stat& st) { -#ifdef _WIN32 - return st.st_mtime; -#else - return st.st_mtim; -#endif -} - -ModDate getFileModDate(const char* fileName) { - struct stat sb; - if (stat(fileName, &sb) < 0) { - return kInvalidModDate; - } - return getModDate(sb); +/* + * Get a file's modification date. + */ +time_t getFileModDate(const char* fileName) { + struct stat sb; + if (stat(fileName, &sb) < 0) { + return (time_t)-1; + } + return sb.st_mtime; } -ModDate getFileModDate(int fd) { - struct stat sb; - if (fstat(fd, &sb) < 0) { - return kInvalidModDate; - } - if (sb.st_nlink <= 0) { - errno = ENOENT; - return kInvalidModDate; - } - return getModDate(sb); +time_t getFileModDate(int fd) { + struct stat sb; + if (fstat(fd, &sb) < 0) { + return (time_t)-1; + } + if (sb.st_nlink <= 0) { + errno = ENOENT; + return (time_t)-1; + } + return sb.st_mtime; } #ifndef __linux__ @@ -131,8 +124,4 @@ bool isReadonlyFilesystem(int fd) { } #endif // __linux__ -} // namespace android - -bool operator==(const timespec& l, const timespec& r) { - return std::tie(l.tv_sec, l.tv_nsec) == std::tie(r.tv_sec, l.tv_nsec); -} +}; // namespace android |