| | @@ -2237,19 +2237,12 @@ |
| 2237 | 2237 | sqlite3_result_int64(pCtx, nWrite); |
| 2238 | 2238 | } |
| 2239 | 2239 | } |
| 2240 | 2240 | |
| 2241 | 2241 | if( mtime>=0 ){ |
| 2242 | | -#if !defined(_WIN32) && !defined(WIN32) |
| 2243 | | - struct timespec times[2]; |
| 2244 | | - times[0].tv_nsec = times[1].tv_nsec = 0; |
| 2245 | | - times[0].tv_sec = time(0); |
| 2246 | | - times[1].tv_sec = mtime; |
| 2247 | | - if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){ |
| 2248 | | - return 1; |
| 2249 | | - } |
| 2250 | | -#else |
| 2242 | +#if defined(_WIN32) |
| 2243 | + /* Windows */ |
| 2251 | 2244 | FILETIME lastAccess; |
| 2252 | 2245 | FILETIME lastWrite; |
| 2253 | 2246 | SYSTEMTIME currentTime; |
| 2254 | 2247 | LONGLONG intervals; |
| 2255 | 2248 | HANDLE hFile; |
| | @@ -2266,10 +2259,28 @@ |
| 2266 | 2259 | BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite); |
| 2267 | 2260 | CloseHandle(hFile); |
| 2268 | 2261 | return !bResult; |
| 2269 | 2262 | }else{ |
| 2270 | 2263 | return 1; |
| 2264 | + } |
| 2265 | +#elif defined(AT_FDCWD) |
| 2266 | + /* Recent unix */ |
| 2267 | + struct timespec times[2]; |
| 2268 | + times[0].tv_nsec = times[1].tv_nsec = 0; |
| 2269 | + times[0].tv_sec = time(0); |
| 2270 | + times[1].tv_sec = mtime; |
| 2271 | + if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){ |
| 2272 | + return 1; |
| 2273 | + } |
| 2274 | +#else |
| 2275 | + /* Legacy unix */ |
| 2276 | + struct timeval times[2]; |
| 2277 | + times[0].tv_usec = times[1].tv_usec = 0; |
| 2278 | + times[0].tv_sec = time(0); |
| 2279 | + times[1].tv_sec = mtime; |
| 2280 | + if( utimes(zFile, times) ){ |
| 2281 | + return 1; |
| 2271 | 2282 | } |
| 2272 | 2283 | #endif |
| 2273 | 2284 | } |
| 2274 | 2285 | |
| 2275 | 2286 | return 0; |
| 2276 | 2287 | |