Task

Get and set the modification time of a file.




      DIM ft{dwLowDateTime%, dwHighDateTime%}
      DIM st{wYear{l&,h&}, wMonth{l&,h&}, wDayOfWeek{l&,h&}, \
      \      wDay{l&,h&}, wHour{l&,h&}, wMinute{l&,h&}, \
      \      wSecond{l&,h&}, wMilliseconds{l&,h&} }
 
      REM File is assumed to exist:
      file$ = @tmp$ + "rosetta.tmp"
 
      REM Get and display the modification time:
      file% = OPENIN(file$)
      SYS "GetFileTime", @hfile%(file%), 0, 0, ft{}
      CLOSE #file%
      SYS "FileTimeToSystemTime", ft{}, st{}
      date$ = STRING$(16, CHR$0)
      time$ = STRING$(16, CHR$0)
      SYS "GetDateFormat", 0, 0, st{}, 0, date$, LEN(date$) TO N%
      date$ = LEFT$(date$, N%-1)
      SYS "GetTimeFormat", 0, 0, st{}, 0, time$, LEN(time$) TO N%
      time$ = LEFT$(time$, N%-1)
      PRINT date$ " " time$
 
      REM Set the modification time to the current time:
      SYS "GetSystemTime", st{}
      SYS "SystemTimeToFileTime", st{}, ft{}
      file% = OPENUP(file$)
      SYS "SetFileTime", @hfile%(file%), 0, 0, ft{}
      CLOSE #file%
 