diff options
author | 2024-05-24 08:27:25 -0700 | |
---|---|---|
committer | 2024-05-24 11:35:17 -0700 | |
commit | fe285426c4f9149537bdd7cb351b02ec102e6082 (patch) | |
tree | a50559e0969480b7f613fc086e380a290ee3d6b1 /libs/androidfw/misc.cpp | |
parent | e2447a31771717fe6259043760ba02484f09d4da (diff) | |
parent | ed6f98ac9f4049f370e1db86e1b4e141bb83f5cc (diff) |
Merge Android 24Q2 Release (ab/11526283) to aosp-main-future
Bug: 337098550
Merged-In: Ie71e752f0224aa239ba1350d50996ce4b510949a
Change-Id: Ib25c1abf055b0114e0494088df5585f65df27595
Diffstat (limited to 'libs/androidfw/misc.cpp')
-rw-r--r-- | libs/androidfw/misc.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/androidfw/misc.cpp b/libs/androidfw/misc.cpp index d3949e9cf69f..93dcaf549a90 100644 --- a/libs/androidfw/misc.cpp +++ b/libs/androidfw/misc.cpp @@ -76,13 +76,23 @@ FileType getFileType(const char* fileName) /* * Get a file's modification date. */ -time_t getFileModDate(const char* fileName) -{ +time_t getFileModDate(const char* fileName) { struct stat sb; + if (stat(fileName, &sb) < 0) { + return (time_t)-1; + } + return sb.st_mtime; +} - if (stat(fileName, &sb) < 0) - return (time_t) -1; - +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; } |