diff options
| author | 2024-05-24 21:15:37 +0000 | |
|---|---|---|
| committer | 2024-05-24 21:15:37 +0000 | |
| commit | f4cdb4307e47cf5799a27390b8ed894488237f09 (patch) | |
| tree | 02c789ce324427670da4b0d542f63d8eb50b0783 /libs/androidfw/misc.cpp | |
| parent | 2e07b93f0f950177eb4afd05670e042b7bd43f65 (diff) | |
| parent | fe285426c4f9149537bdd7cb351b02ec102e6082 (diff) | |
Merge "Merge Android 24Q2 Release (ab/11526283) to aosp-main-future" into aosp-main-future
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; } |