/ Check-in [90cb01d8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid the use of utimensat() on older unix platforms.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:90cb01d8d6ac12d0b88f2952a75aeefa81ba66f5e4a5377fdd8b9f86aec8e927
User & Date: drh 2018-01-07 23:28:10
Context
2018-01-08
16:54
First code for an auxiliary function that will normalize an SQL statement. check-in: 84814aac user: drh tags: normalize
14:24
Fix compilation of 'sqltclsh.exe' for MSVC. check-in: abb112d9 user: mistachkin tags: trunk
2018-01-07
23:28
Avoid the use of utimensat() on older unix platforms. check-in: 90cb01d8 user: drh tags: trunk
21:58
Remove the dependency on test_windirent.h from the generated shell.c file. check-in: 0a50c9e3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/fileio.c.

   257    257         }
   258    258         if( rc ) return 2;
   259    259         sqlite3_result_int64(pCtx, nWrite);
   260    260       }
   261    261     }
   262    262   
   263    263     if( mtime>=0 ){
   264         -#if !defined(_WIN32) && !defined(WIN32)
   265         -    struct timespec times[2];
   266         -    times[0].tv_nsec = times[1].tv_nsec = 0;
   267         -    times[0].tv_sec = time(0);
   268         -    times[1].tv_sec = mtime;
   269         -    if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){
   270         -      return 1;
   271         -    }
   272         -#else
          264  +#if defined(_WIN32)
          265  +    /* Windows */
   273    266       FILETIME lastAccess;
   274    267       FILETIME lastWrite;
   275    268       SYSTEMTIME currentTime;
   276    269       LONGLONG intervals;
   277    270       HANDLE hFile;
   278    271       GetSystemTime(&currentTime);
   279    272       SystemTimeToFileTime(&currentTime, &lastAccess);
................................................................................
   286    279       );
   287    280       if( hFile!=INVALID_HANDLE_VALUE ){
   288    281         BOOL bResult = SetFileTime(hFile, NULL, &lastAccess, &lastWrite);
   289    282         CloseHandle(hFile);
   290    283         return !bResult;
   291    284       }else{
   292    285         return 1;
          286  +    }
          287  +#elif defined(AT_FDCWD)
          288  +    /* Recent unix */
          289  +    struct timespec times[2];
          290  +    times[0].tv_nsec = times[1].tv_nsec = 0;
          291  +    times[0].tv_sec = time(0);
          292  +    times[1].tv_sec = mtime;
          293  +    if( utimensat(AT_FDCWD, zFile, times, AT_SYMLINK_NOFOLLOW) ){
          294  +      return 1;
          295  +    }
          296  +#else
          297  +    /* Legacy unix */
          298  +    struct timeval times[2];
          299  +    times[0].tv_usec = times[1].tv_usec = 0;
          300  +    times[0].tv_sec = time(0);
          301  +    times[1].tv_sec = mtime;
          302  +    if( utimes(zFile, times) ){
          303  +      return 1;
   293    304       }
   294    305   #endif
   295    306     }
   296    307   
   297    308     return 0;
   298    309   }
   299    310