[fpc-pascal] Re: fstat usage
Francisco Reyes writes: Trying the fstat function and don't seem to be getting the right values for ctime, mtime and atime. -- filedate.pp uses BaseUnix,DateUtils,SysUtils; var info : stat ; begin if fpstat ('myfile.txt' , info) 0 then begin writeln ('Fstat failed . Errno : ' , fpgeterrno) ; halt ( 1 ) ; end ; writeln ; writeln ('atime : ' , DateTimeToStr(info.st_atime )); writeln ('mtime : ' , DateTimeToStr(info.st_mtime )); writeln ('ctime : ' , DateTimeToStr(info.st_ctime )); writeln ('Now STR: ', DateTimeToStr(Now)); writeln ('Mod diff:' , DaySpan(Now,info.st_mtime)); writeln ('mtime raw: ', info.st_mtime ); writeln (' Now raw: ', Now); end . touch mfyle.txt fpc filedate.pp ./filedate.pp atime : 6-9-88-- mtime : 6-9-88-- ctime : 6-9-88-- Now STR: 5-12-08 22:15:08 Mod diff: 1.22849351907281E+009 mtime raw: 1228533307 Now raw: 3.97879271865278E+004 I was expecting atime, mtime and ctime to be very close to 'Now'. The file date is December 5, 2008 as shown on the OS ll myfile.txt -rw-r--r-- 1 fran users 16 2008-12-05 22:15 myfile.txt What other function can I use instead of fpstat? Perhaps a different function in another RTL library? Need to be able to have the program work on both FreeBSD and Linux. Any pointers greatly appreciated. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: fstat usage
On Monday 08 December 2008 10:22:25 Francisco Reyes wrote: Francisco Reyes writes: Trying the fstat function and don't seem to be getting the right values for ctime, mtime and atime. Those values are Unix timestamp values. You need to convert them into TDateTime values. Look for UnixToDateTime and DateTimeToUnix in DateUtils. Best regards, Pete C. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: fstat usage
Pete Cervasio writes: TDateTime values. Look for UnixToDateTime and DateTimeToUnix in DateUtils. The documentation I have must be old (even though I got it a few days ago from the website). It says those functions are not implemented, yet I was able to use it. Is the time displayed in UTC? Seems to be. Any way to make the time displayed be my timezone? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: fstat usage
Francisco Reyes writes: Is the time displayed in UTC? Seems to be. Any way to make the time displayed be my timezone? Nevermind that... Was confused because the date was in a different format.. You pointed me in the right direction and finished the program. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal