|
109 | 109 | #else |
110 | 110 | #include <dirent.h> |
111 | 111 | #include <fcntl.h> |
112 | | -#include <langinfo.h> |
113 | 112 | #include <sys/param.h> |
114 | 113 | #include <sys/stat.h> |
115 | | -#include <sys/statvfs.h> |
116 | 114 | #include <sys/time.h> |
117 | 115 | #include <sys/types.h> |
118 | 116 | #include <unistd.h> |
119 | 117 | #include <limits.h> |
120 | 118 | #ifdef GHC_OS_ANDROID |
121 | 119 | #include <android/api-level.h> |
| 120 | +#if __ANDROID_API__ < 12 |
| 121 | +#include <sys/syscall.h> |
| 122 | +#endif |
| 123 | +#include <sys/vfs.h> |
| 124 | +#define statvfs statfs |
| 125 | +#else |
| 126 | +#include <sys/statvfs.h> |
| 127 | +#endif |
| 128 | +#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 |
| 129 | +#include <langinfo.h> |
122 | 130 | #endif |
123 | 131 | #endif |
124 | 132 | #ifdef GHC_OS_MACOS |
@@ -4165,12 +4173,19 @@ GHC_INLINE void last_write_time(const path& p, file_time_type new_time, std::err |
4165 | 4173 | #endif |
4166 | 4174 | #endif |
4167 | 4175 | #else |
| 4176 | +#ifndef UTIME_OMIT |
| 4177 | +#define UTIME_OMIT ((1l << 30) - 2l) |
| 4178 | +#endif |
4168 | 4179 | struct ::timespec times[2]; |
4169 | 4180 | times[0].tv_sec = 0; |
4170 | 4181 | times[0].tv_nsec = UTIME_OMIT; |
4171 | 4182 | times[1].tv_sec = static_cast<decltype(times[1].tv_sec)>(std::chrono::duration_cast<std::chrono::seconds>(d).count()); |
4172 | 4183 | times[1].tv_nsec = static_cast<decltype(times[1].tv_nsec)>(std::chrono::duration_cast<std::chrono::nanoseconds>(d).count() % 1000000000); |
| 4184 | +#if defined(__ANDROID_API__) && __ANDROID_API__ < 12 |
| 4185 | + if (syscall(__NR_utimensat, AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { |
| 4186 | +#else |
4173 | 4187 | if (::utimensat(AT_FDCWD, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { |
| 4188 | +#endif |
4174 | 4189 | ec = detail::make_system_error(); |
4175 | 4190 | } |
4176 | 4191 | return; |
@@ -4496,17 +4511,13 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept |
4496 | 4511 | return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)}; |
4497 | 4512 | } |
4498 | 4513 | return {static_cast<uintmax_t>(totalNumberOfBytes.QuadPart), static_cast<uintmax_t>(totalNumberOfFreeBytes.QuadPart), static_cast<uintmax_t>(freeBytesAvailableToCaller.QuadPart)}; |
4499 | | -#elif !defined(__ANDROID__) || __ANDROID_API__ >= 19 |
| 4514 | +#else |
4500 | 4515 | struct ::statvfs sfs; |
4501 | 4516 | if (::statvfs(p.c_str(), &sfs) != 0) { |
4502 | 4517 | ec = detail::make_system_error(); |
4503 | 4518 | return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)}; |
4504 | 4519 | } |
4505 | 4520 | return {static_cast<uintmax_t>(sfs.f_blocks * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bfree * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bavail * sfs.f_frsize)}; |
4506 | | -#else |
4507 | | - (void)p; |
4508 | | - ec = detail::make_error_code(detail::portable_error::not_supported); |
4509 | | - return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)}; |
4510 | 4521 | #endif |
4511 | 4522 | } |
4512 | 4523 |
|
|
0 commit comments