David - thanks - this seems to work fine. I guess I was only looking at half of the returned timestamp.
Based on the test I show below, I can use this to read the file times and they behave in a sensible way: moving a file preserves the creation time but copying it creates it at the time of copy. Updating it changes the "last write" and "last access" times but not the creation time. Simply opening it in PaintShop Pro without modifying it changes only the access time. Regards, Devon NB. Picture I just took and copied from camera chip to C: >getfiletimes 'C:\amisc\DSCF5507.JPG' +-----------------------+-----------------------+-----------------------+ |2009-01-19 13:43:14.000|2009-01-19 13:43:15.000|2009-01-19 14:40:26.000| +-----------------------+-----------------------+-----------------------+ |_913116406 29981285 |_909835156 29981285 |_961761024 29981293 | +-----------------------+-----------------------+-----------------------+ NB. Times: Creation, Last Access, Last Write NB. Version of picture still on the chip >getfiletimes 'H:\DCIM\155_FUJI\DSCF5507.JPG' NB. H:\ is the camera chip +-----------------------+-----------------------+-----------------------+ |2009-01-19 14:40:27.000|2009-01-19 00:00:00.000|2009-01-19 14:40:26.000| +-----------------------+-----------------------+-----------------------+ |_951761024 29981293 |_940783616 29981170 |_961761024 29981293 | +-----------------------+-----------------------+-----------------------+ NB. Looks like I forgot to take camera off daylight savings time... qts'' 2009 1 19 13 44 38.64 NB. Flip and save the one on C:\ >getfiletimes 'C:\amisc\DSCF5507.JPG' +-----------------------+-----------------------+-----------------------+ |2009-01-19 13:43:14.000|2009-01-19 13:47:07.000|2009-01-19 13:47:05.000| +-----------------------+-----------------------+-----------------------+ |_913116406 29981285 |1414227344 29981286 |1394071094 29981286 | +-----------------------+-----------------------+-----------------------+ qts'' 2009 1 19 13 48 1.734 NB. Creation time remains the same, last access and last write are updated. NB. Now just open the one on C:\ but don't change anything... >getfiletimes 'C:\amisc\DSCF5507.JPG' +-----------------------+-----------------------+-----------------------+ |2009-01-19 13:43:14.000|2009-01-19 13:48:52.000|2009-01-19 13:47:05.000| +-----------------------+-----------------------+-----------------------+ |_913116406 29981285 |_1830271202 29981286 |1394071094 29981286 | +-----------------------+-----------------------+-----------------------+ qts'' 2009 1 19 13 49 19.218 NB. Creation the same, last access changed but not last write. NB. Now move the file from H: to C: instead of copying: >getfiletimes 'C:\amisc\DSCF5507.JPG' +-----------------------+-----------------------+-----------------------+ |2009-01-19 14:40:27.000|2009-01-19 13:57:47.000|2009-01-19 14:40:26.000| +-----------------------+-----------------------+-----------------------+ |_951761024 29981293 |_775707248 29981287 |_961761024 29981293 | +-----------------------+-----------------------+-----------------------+ qts'' 2009 1 19 13 58 15.437 NB. Updates access time but not the other two. On Mon, Jan 19, 2009 at 12:30 PM, David Mitchell <[email protected]>wrote: > Devon McCormick wrote: > > Members of the Forum - > > > > Here's what I have so far attempting to read some of the file times. I > used > > the function "CreateFileR" from "directio.ijs", which I found at > > http://www.jsoftware.com/jwiki/Scripts/WindowsDirectIO, to get the file > > handle which I need as an input to the "GetFileTime" API. > > > > load 'c:\amisc\j\directio.ijs' > > NB. See what modification time looks like: > > dir flnm=. 'C:\amisc\pix\Photos\2009Q1\20090116\DSCF5118.JPG' > > +------------+-----------------+-------+---+------+ > > |DSCF5118.JPG|2009 1 16 16 5 32|3091773|rw-|-----a| > > +------------+-----------------+-------+---+------+ > > ]fh=. CreateFileR > > > (flnm,{.a.);(FILE_ANY_ACCESS);(FILE_SHARE_READ+FILE_SHARE_WRITE);NULLPTR;OPEN_EXISTING;0;0 > > 892 > > > > NB. Here's the definition of the kernel32 API to get file times: > > getFileTimeDefn=. 0 : 0 > > BOOL WINAPI GetFileTime( > > __in HANDLE hFile, > > __out_opt LPFILETIME lpCreationTime, > > __out_opt LPFILETIME lpLastAccessTime, > > __out_opt LPFILETIME lpLastWriteTime > > ); > > ) > > > > getFlTms=: 'GetFileTime' win32api NB. GetFileTime i i *i *i *i > > ]'rc hndl crt lat lwt'=. getFlTms fh;,&.>0;0;0 > > +-+---+---------+----------+---------+ > > |1|892|108052680|_800311242|718878208| > > +-+---+---------+----------+---------+ > > q'' NB. Don't otherwise know how to release the file handle. > > > > This seems to lose my file as well (it disappears) but I've saved a copy > > elsewhere. > > > > Now I open the file and save it to change the modification time, then > re-do > > the preceding: > > > > dir flnm=. 'C:\amisc\pix\Photos\2009Q1\20090116\DSCF5118.JPG' > > +------------+------------------+-------+---+------+ > > |DSCF5118.JPG|2009 1 18 21 46 50|2800305|rw-|-----a| > > +------------+------------------+-------+---+------+ > > fh=. CreateFileR > > > (flnm,{.a.);(FILE_ANY_ACCESS);(FILE_SHARE_READ+FILE_SHARE_WRITE);NULLPTR;OPEN_EXISTING;0;0 > > ]'rc hndl crt lat lwt'=. getFlTms fh;,&.>0;0;0 > > +-+---+---------+---------+---------+ > > |1|896|757188758|783595008|764845008| > > +-+---+---------+---------+---------+ > > > > All these times (the latter three numbers) look completely different. > What > > gives? Shouldn't some of them remain the same? > > > > Regards, > > > > Devon > > Devon, > > I have uploaded an updated version of directio.ijs. > > > http://www.jsoftware.com/jwiki/Scripts/WindowsDirectIO?action=AttachFile&do=view&target=directio.ijs > > Please try out verb > > getfiletimes 'C:\amisc\pix\Photos\2009Q1\20090116\DSCF5118.JPG' > > and see if it answers any of your questions. > > -- > Thanks, > David Mitchell > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
