1. Other information and dates of an archive
- Posted by Sergio Gelli <sergelli at uol.com.br> Jan 29, 2007
- 708 views
Hi With the routine "dir", we can get the date of the last modification, the attribute, the size, etc of an archive. But in which way I can get the date of creation, last access and the name of the author of an archive? Also such is important to know how to modify some information as the name of the author. Some suggestion? Best regards and thanks for advance. Sérgio Gelli - Brasil.
2. Re: Other information and dates of an archive
- Posted by Alan Oxley <fizzpop at axemail.co.za> Jan 30, 2007
- 663 views
Hi, I assume you are talking about a Windows filesystem, eg FAT32/NTFS. The author of the file is not stored for these filesystems, but creation date and last access date is. This is a Windows limitation, so unless you are saving the author info yourself, ie if files are created from within your own application, it cannot be done. Search the archives for examples of walk_dir. On Linux/Unix the most common filesystem is EXT2/EXT3; these make use of permissions where the owner of the file and who else has access is defined. FWIW, on mainframe files, who created it, accessed it, by what program, etc is very much known and the info is stored. But Windows is not mainframe. Regards Alan
3. Re: Other information and dates of an archive
- Posted by Sergio Gelli <sergelli at uol.com.br> Jan 30, 2007
- 626 views
Hi Alan Very thanks, Ok, I understood that is not possible to modify the name of the author of an archive, but how I can extract the date of creation and the date of the last access of this archive, using a Eu code? Is this possible? Best regards, Sérgio - Brasil
4. Re: Other information and dates of an archive
- Posted by ZNorQ <znorq at holhaug.com> Jan 31, 2007
- 644 views
Sergio Gelli wrote: > > > Hi Alan > > Very thanks, > > Ok, I understood that is not possible to modify the name of > the author of an archive, but how I can extract the date of > creation and the date of the last access of this archive, using > a Eu code? Is this possible? > > Best regards, > > Sérgio - Brasil Hei Sérgio, Actually, I'm looking for the same, and I've tried looking in the arhives, but none that works for me. At work, I'm trying to analyze the content of a network disc, and I want 3 relevant dates in my analyzis; Created, Modified and Accessed. The network drive contains errors (too deep directory structure), so I want it to be able to handle that too, that is - not to CTD when it occours, but continue to next file/directory. I'd like to make it work in conjunction with the walk_dir(). Hope some brainer out there can help! :) Kenneth aka ZNorQ
5. Re: Other information and dates of an archive
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Jan 31, 2007
- 652 views
Sergio Gelli wrote: > > > Hi Alan > > Very thanks, > > Ok, I understood that is not possible to modify the name of > the author of an archive, but how I can extract the date of > creation and the date of the last access of this archive, using > a Eu code? Is this possible? > > Best regards, > > Sérgio - Brasil
constant kernel32=open_dll("kernel32.dll"), gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_BOOL), ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_BOOL), mem_area=allocate(72), create_time=mem_area, last_access=mem_area+8, last_write=mem_area+16 system_time=mem_area+24, system_last_access=mem_area+40, system_last_write=mem_area+56 atom hfile integer rc -- set hfile to a handle on your file rc=c_func(gft,{hfile,create_time,last_access,last_write) rc=c_func(create_time,system_create_time) rc=c_func(last_access,system_last_access) rc=c_func(last_write,system_last_write)
Note that some of the pointers passed to GetFileTime() may be 0. The system_* structures hold 8 16-bit words each, representing a date and a time as: * wYear * wMonth * wDayOfWeek * wDay * wHour * wMinute * wSecond * wMilliseconds To properly set hfile, you must call the CreateFile() Win32API. Please refer to the docs for it, as it is somewhat lengthy. Too bad that Eu doesn't give access to the physical handle of an open file, given its Eu handle... HTH CChris
6. Re: Other information and dates of an archive
- Posted by Sergio Gelli <sergelli at uol.com.br> Jan 31, 2007
- 658 views
CChris wrote: > > }}} <eucode> > constant kernel32=open_dll("kernel32.dll"), > gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_BOOL), > > ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_BOOL), > mem_area=allocate(72), > create_time=mem_area, > last_access=mem_area+8, > last_write=mem_area+16 > system_time=mem_area+24, > system_last_access=mem_area+40, > system_last_write=mem_area+56 > > atom hfile > integer rc > -- set hfile to a handle on your file > rc=c_func(gft,{hfile,create_time,last_access,last_write) > rc=c_func(create_time,system_create_time) > rc=c_func(last_access,system_last_access) > rc=c_func(last_write,system_last_write) > </eucode> {{{ > > CChris Hello CCris, Your code is very beyond what I can understand. I tried to make it to run, but it is impossible. You can explain better? Many Thanks, Sérgio - Brasil
7. Re: Other information and dates of an archive
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Jan 31, 2007
- 662 views
- Last edited Feb 01, 2007
Sergio Gelli wrote: > > CChris wrote: > > > Hello CCris, > > Your code is very beyond what I can understand. > > I tried to make it to run, but it is impossible. > > You can explain better? > > Many Thanks, > > Sérgio - Brasil Completed with some missing statements and a few comments. I am using Windows API directly since I don't know which wrapper library you use. Additionally, this code won't work on any other plaform than Windows.
-- wrap a few functions from kernel32.dll constant kernel32=open_dll("kernel32.dll"), gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_BOOL), ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_BOOL), cf=define_c_func(kernel32,"CreateFileA",repeat(C_POINTER,7),C_POINTER), ch=define_c_func(kernel32,"CloseHandle",{C_POINTER},C_BOOL), -- reserving some memory mem_area=allocate(72), -- area for raw data create_time=mem_area, last_access=mem_area+8, last_write=mem_area+16, -- area for usable data system_create_time=mem_area+24, system_last_access=mem_area+40, system_last_write=mem_area+56, -- this flag is used later: it tells the OS to fail upon opening a file -- which doesn't exist OPEN_EXISTING = 3 sequence fname fname="C:\my_file.txt") -- set this to the actual file name atom hfile integer rc -- set hfile to a handle on your file hfile=c_func(cf,{allocate_string(fname), 0, 0, 0, OPEN_EXISTING, 0, 0}) if not hfile then -- something went wrong, do something useful here end if -- now we have a file handle, let's get the timestamps -- you may wish to check if rc=0, which notifies of an error rc=c_func(gft,{hfile,create_time,last_access,last_write) -- convert the data to something of use. Again, rc=0 means soething went wrong rc=c_func(ft2st,{create_time,system_create_time}) rc=c_func(ft2st,{last_access,system_last_access}) rc=c_func(ft2st,{last_write,system_last_write}) -- now close the file rc=c_func(ch,{hfile})
Now the data is available to be peek()ed at system_create_time, system_last_access and system_last_write respectively. Each of the three 16 bytes area is made of 8 fields 2 byte long each. They come in the following order: * Year * Month * DayOfWeek * Day * Hour * Minute * Second * Milliseconds This should get you going... CChris
8. Re: Other information and dates of an archive
- Posted by Sergio Gelli <sergelli at uol.com.br> Feb 02, 2007
- 636 views
Hi CCris, I made some modifications in your code. I changed C_COOL for C_INT (C_BOOL is not declared) and another things and it ran, but I am not getting the dates. Please, try executes the code below. Also I do not know how to follow your orientation when you be says "you peek()ed". Many thanks again. Sérgio Gelli - Brasil -- Eucode include win32lib.ew ----------------------------------------------------------------------------- procedure wwait(object messag ) atom result,rr rr=getSelf() if sequence (messag) then result = message_box(messag ,"Mensagem !", MB_ICONEXCLAMATION + MB_TASKMODAL) else result = message_box(sprintf( "%d\n",messag), "Mensagem !", MB_ICONEXCLAMATION + MB_TASKMODAL) end if -- setFocus(rr) end procedure ------------------------------------------------------------------------------- -- wrap a few functions from kernel32.dll constant kernel32=open_dll("kernel32.dll"), gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_INT), ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_INT), cf=define_c_func(kernel32,"CreateFileA",repeat(C_POINTER,7),C_POINTER), ch=define_c_func(kernel32,"CloseHandle",{C_POINTER},C_INT), -- reserving some memory mem_area=allocate(72), -- area for raw data create_time=mem_area, last_access=mem_area+8, last_write=mem_area+16, -- area for usable data system_create_time=mem_area+24, system_last_access=mem_area+40, system_last_write=mem_area+56, -- this flag is used later: it tells the OS to fail upon opening a file -- which doesn't exist OPEN_EXISTING = 3 sequence fname fname="C:\\ex.err" -- set this to the actual file name atom hfile integer rc -- set hfile to a handle on your file hfile=c_func(cf,{allocate_string(fname), 0, 0, 0, OPEN_EXISTING, 0, 0}) if not hfile then -- something went wrong, do something useful here end if -- now we have a file handle, let's get the timestamps -- you may wish to check if rc=0, which notifies of an error rc=c_func(gft,{hfile,create_time,last_access,last_write}) wwait(sprintf("rc=%d hfile =%d create_time=%s last_access=%s last_write=%s\n"& "create_time=%d last_access=%d last_write=%d ",{rc,hfile,create_time,last_access,last_write,create_time,last_access,last_write})) -- convert the data to something of use. Again, rc=0 means soething went wrong rc=c_func(ft2st,{create_time,system_create_time}) wwait(sprintf("rc=%d create_time=%s system_create_time=%s \n"& "create_time=%d system_create_time=%d ", {rc,create_time,system_create_time,create_time,system_create_time})) rc=c_func(ft2st,{last_access,system_last_access}) wwait(sprintf("rc=%d last_access=%s system_last_access=%s \n"& "last_access=%d system_last_access=%d ", {rc,last_access,system_last_access,last_access,system_last_access})) rc=c_func(ft2st,{last_write,system_last_write}) wwait(sprintf("rc=%d last_write=%s system_last_write=%s \n"& "last_write=%d system_last_write=%d ", {rc,last_write,system_last_write,last_write,system_last_write})) -- now close the file rc=c_func(ch,{hfile}) --Now the data is available to be peek()ed at system_create_time, --system_last_access and system_last_write respectively. --Each of the three 16 bytes area is made of 8 fields 2 byte long each. --They come in the following order: --* Year --* Month --* DayOfWeek --* Day --* Hour --* Minute --* Second --* Milliseconds
9. Re: Other information and dates of an archive
- Posted by ZNorQ <znorq at holhaug.com> Feb 02, 2007
- 625 views
CChris wrote: > > Sergio Gelli wrote: > > > > CChris wrote: > > > > > > Hello CCris, > > > > Your code is very beyond what I can understand. > > > > I tried to make it to run, but it is impossible. > > > > You can explain better? > > > > Many Thanks, > > > > Sérgio - Brasil > > Completed with some missing statements and a few comments. I am using > Windows API directly since I don't know which wrapper library you use. > Additionally, this code won't work on any other plaform than Windows. > > }}} <eucode> > -- wrap a few functions from kernel32.dll > constant kernel32=open_dll("kernel32.dll"), > gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_BOOL), > > ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_BOOL), > cf=define_c_func(kernel32,"CreateFileA",repeat(C_POINTER,7),C_POINTER), > ch=define_c_func(kernel32,"CloseHandle",{C_POINTER},C_BOOL), C_BOOL isn't a legal type, I used C_LONG - would that be ok? > -- reserving some memory > mem_area=allocate(72), > -- area for raw data > create_time=mem_area, > last_access=mem_area+8, > last_write=mem_area+16, > -- area for usable data > system_create_time=mem_area+24, > system_last_access=mem_area+40, > system_last_write=mem_area+56, > -- this flag is used later: it tells the OS to fail upon opening a file > -- which doesn't exist > OPEN_EXISTING = 3 > > sequence fname > fname="C:\my_file.txt") -- set this to the actual file name > atom hfile > integer rc > -- set hfile to a handle on your file > hfile=c_func(cf,{allocate_string(fname), > 0, > 0, > 0, > OPEN_EXISTING, > 0, > 0}) > if not hfile then > -- something went wrong, do something useful here > end if > -- now we have a file handle, let's get the timestamps > -- you may wish to check if rc=0, which notifies of an error > rc=c_func(gft,{hfile,create_time,last_access,last_write) > -- convert the data to something of use. Again, rc=0 means soething went wrong > rc=c_func(ft2st,{create_time,system_create_time}) > rc=c_func(ft2st,{last_access,system_last_access}) > rc=c_func(ft2st,{last_write,system_last_write}) > -- now close the file > rc=c_func(ch,{hfile}) > </eucode> {{{ > > Now the data is available to be peek()ed at system_create_time, > system_last_access and system_last_write respectively. > Each of the three 16 bytes area is made of 8 fields 2 byte long each. > They come in the following order: > * Year > * Month > * DayOfWeek > * Day > * Hour > * Minute > * Second > * Milliseconds > > This should get you going... > > CChris I've used your example to create a test of my own. When I extract the data, I get some mismatch in the time (dates seem to be correct). year = peek(system_create_time + 0) + (peek(system_create_time + 1) * 256) month = peek(system_create_time + 2) + (peek(system_create_time + 3) * 256) dow = peek(system_create_time + 4) + (peek(system_create_time + 5) * 256) day = peek(system_create_time + 6) + (peek(system_create_time + 7) * 256) hour = peek(system_create_time + 8) + (peek(system_create_time + 9) * 256) min = peek(system_create_time + 10) + (peek(system_create_time + 11) * 256) sec = peek(system_create_time + 12) + (peek(system_create_time + 13) * 256) msec = peek(system_create_time + 14) + (peek(system_create_time + 15) * 256) (Same goes for system_last_access and system_last_write.) * CREATED dates - all that is wrong is the hour - all other data is correct. Hour is one short, ie. instead of 16 (4 o'clock) it shows 15. * ACCESSED dates - Date is correct, hours is one short, *and* minutes and seconds are both incorrect. * MODIFIED dates - Date is correct, hours is one short. Can you figure out what I'm doing wrong? PS! I know I might be doing it abit backwards, but I haven't been peeking and poking since back in those days of the Commodore 64. (I Couldn't find a peek that handled word size variables.) Also be aware that I shifted Kenneth aka ZNorQ
10. Re: Other information and dates of an archive
- Posted by ZNorQ <znorq at holhaug.com> Feb 02, 2007
- 631 views
I forgot to finish the last sentence "Also be aware that I shifted..", and I can't remember what I was supposed to say - so forget about it! :) And, yes, I too changed the C_BOOL, but I used C_LONG... Kenneth akak ZNorQ
11. Re: Other information and dates of an archive
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 02, 2007
- 620 views
ZNorQ wrote: > > CChris wrote: > > > > Sergio Gelli wrote: > > > > > > CChris wrote: > > > > > > > > > Hello CCris, > > > > > > Your code is very beyond what I can understand. > > > > > > I tried to make it to run, but it is impossible. > > > > > > You can explain better? > > > > > > Many Thanks, > > > > > > Sérgio - Brasil > > > > Completed with some missing statements and a few comments. I am using > > Windows API directly since I don't know which wrapper library you use. > > Additionally, this code won't work on any other plaform than Windows. > > > > }}} <eucode> > > -- wrap a few functions from kernel32.dll > > constant kernel32=open_dll("kernel32.dll"), > > gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_BOOL), > > > > ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_BOOL), > > cf=define_c_func(kernel32,"CreateFileA",repeat(C_POINTER,7),C_POINTER), > > ch=define_c_func(kernel32,"CloseHandle",{C_POINTER},C_BOOL), > > C_BOOL isn't a legal type, I used C_LONG - would that be ok? > > > -- reserving some memory > > mem_area=allocate(72), > > -- area for raw data > > create_time=mem_area, > > last_access=mem_area+8, > > last_write=mem_area+16, > > -- area for usable data > > system_create_time=mem_area+24, > > system_last_access=mem_area+40, > > system_last_write=mem_area+56, > > -- this flag is used later: it tells the OS to fail upon opening a file > > -- which doesn't exist > > OPEN_EXISTING = 3 > > > > sequence fname > > fname="C:\my_file.txt") -- set this to the actual file name > > atom hfile > > integer rc > > -- set hfile to a handle on your file > > hfile=c_func(cf,{allocate_string(fname), > > 0, > > 0, > > 0, > > OPEN_EXISTING, > > 0, > > 0}) > > if not hfile then > > -- something went wrong, do something useful here > > end if > > -- now we have a file handle, let's get the timestamps > > -- you may wish to check if rc=0, which notifies of an error > > rc=c_func(gft,{hfile,create_time,last_access,last_write) > > -- convert the data to something of use. Again, rc=0 means soething went > > wrong > > rc=c_func(ft2st,{create_time,system_create_time}) > > rc=c_func(ft2st,{last_access,system_last_access}) > > rc=c_func(ft2st,{last_write,system_last_write}) > > -- now close the file > > rc=c_func(ch,{hfile}) > > </eucode> {{{ > > > > Now the data is available to be peek()ed at system_create_time, > > system_last_access and system_last_write respectively. > > Each of the three 16 bytes area is made of 8 fields 2 byte long each. > > They come in the following order: > > * Year > > * Month > > * DayOfWeek > > * Day > > * Hour > > * Minute > > * Second > > * Milliseconds > > > > This should get you going... > > > > CChris > > I've used your example to create a test of my own. When I extract the > data, I get some mismatch in the time (dates seem to be correct). > > year = peek(system_create_time + 0) + (peek(system_create_time + 1) * > 256) > month = peek(system_create_time + 2) + (peek(system_create_time + 3) * > 256) > dow = peek(system_create_time + 4) + (peek(system_create_time + 5) * > 256) > day = peek(system_create_time + 6) + (peek(system_create_time + 7) * > 256) > hour = peek(system_create_time + 8) + (peek(system_create_time + 9) * > 256) > min = peek(system_create_time + 10) + (peek(system_create_time + 11) * > 256) > sec = peek(system_create_time + 12) + (peek(system_create_time + 13) * > 256) > msec = peek(system_create_time + 14) + (peek(system_create_time + 15) * > 256) > > (Same goes for system_last_access and system_last_write.) > > * CREATED dates - all that is wrong is the hour - all other data is correct. > Hour is > one short, ie. instead of 16 (4 o'clock) it shows 15. > Docs say hours are 0 thru 23, so that's expected. > * ACCESSED dates - Date is correct, hours is one short, *and* minutes and > seconds > are both incorrect. > Likewise for minutes and seconds, 0 thru 59. Also, the day_of_week field starts with 0=sunday, 1=monday and so on. However, if I remember well, your reional ptions may alter this behaviour. > * MODIFIED dates - Date is correct, hours is one short. > > Can you figure out what I'm doing wrong? > > PS! I know I might be doing it abit backwards, but I haven't been peeking and > poking > since back in those days of the Commodore 64. (I Couldn't find a peek that > handled > word size variables.) Also be aware that I shifted > > Kenneth aka ZNorQ And no, Eu doesn't have a peek2() routine. What you did is correct. You could make it faster by combining two 2-byte reads into one 4-byte read using peek4u though:
year = peek(system_create_time + 0) + (peek(system_create_time + 1) * 256) month = peek(system_create_time + 2) + (peek(system_create_time + 3) * 256)
could be replaced by:
atom temp temp=peek4u(system_create_time) year = remainder(temp,65536) month= floor(temp/65536)
Btw, Sergio, that is exactly what my "orientation" was.... CChris
12. Re: Other information and dates of an archive
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Feb 02, 2007
- 684 views
CChris wrote: > > And no, Eu doesn't have a peek2() routine. What you did is correct. > You could make it faster by combining two 2-byte reads into one 4-byte read > > using peek4u though: > }}} <eucode> > atom temp > temp=peek4u(system_create_time) > year = remainder(temp,65536) > month= floor(temp/65536) > </eucode> {{{ If you get rid of remainder() it would be even faster:
atom temp, year, month, t temp = 2007 + #10000 * 2 constant reps = 10000000 ? reps t = time() for i = 1 to reps do year = remainder(temp,#10000) month= floor(temp/#10000) end for ? time() - t ? year ? month t = time() for i = 1 to reps do year = and_bits( temp, #FFFF ) month = floor( temp / #10000 ) end for ? time() - t ? year ? month ? getc(0)
It's almost twice as fast to use and_bits() instead of remainder() on my machine. Also, bitwise stuff if usually easier to see what's going on if you use hexadecimal IMHO. Matt
13. Re: Other information and dates of an archive
- Posted by Sergio Gelli <sergelli at uol.com.br> Feb 04, 2007
- 658 views
CChris wrote: > Btw, Sergio, that is exactly what my "orientation" was.... > > CChris OK, CCris, I made plus some changes and finally I am getting the dates modified, created and last access. But, look at below the behavior of the EuCode with GTMs different, Greenwich and Bras�a: windows explorer dates with GTM = greenwich modified= 2007/02/03 08:55 creation= 2007/02/03 18:18 accessed= 2007/02/03 00:00 Eucode dates with GTM = Greenwich modified= 2007/02/03 08:55 creation= 2007/02/03 18:18 accessed= 2007/02/03 00:00 windows explorer dates with GTM = -03:00= Brasília modified= 2007/02/03 08:55 creation= 2007/02/03 18:18 accessed= 2007/02/04 00:00 Eucode dates with GTM = -03:00= Brasília modified= 2007/02/03 10:55 creation= 2007/02/03 20:18 accessed= 2007/02/03 02:00 However, the GTM is not being considered and this results in differences in the value of the hours. It is probable that we will have that to find which GTM is being used and to make additions or reductions in the value of the hour to show it correctly. But how meeting the value of the GTM in the machine that the Eucode is running? Many thanks again, Sérgio Gelli - Brasil <EuCode> include win32lib.ew sequence fname,creation,lastAccess,updated fname="C:\\ex.err" --"C:\\boot.ini" -- set this to the actual file name atom hfile,year,month,dow,day,hour,min,sec,msec integer rc ----------------------------------------------------------------------------- procedure wwait(object messag ) atom result,rr rr=getSelf() if sequence (messag) then result = message_box(messag ,"Mensagem !", MB_ICONEXCLAMATION + MB_TASKMODAL) else result = message_box(sprintf( "%d\n",messag), "Mensagem !", MB_ICONEXCLAMATION + MB_TASKMODAL) end if -- setFocus(rr) end procedure ----------------------------------------------------------------------------- procedure makeDate(sequence field,object data) year = peek(data + 0) + (peek(data + 1) * 256) month = peek(data + 2) + (peek(data + 3) * 256) dow = peek(data + 4) + (peek(data + 5) * 256) day = peek(data + 6) + (peek(data + 7) * 256) hour = peek(data + 8) + (peek(data + 9) * 256) min = peek(data + 10) + (peek(data + 11) * 256) sec = peek(data + 12) + (peek(data + 13) * 256) msec = peek(data + 14) + (peek(data + 15) * 256) if match(field,"system_create_time") then creation=sprintf("%04d/%02d/%02d %02d:%02d:%02d",{year,month,day,hour,min,sec}) elsif match(field,"system_last_access") then lastAccess=sprintf("%04d/%02d/%02d %02d:%02d:%02d",{year,month,day,hour,min,sec}) elsif match(field,"system_last_write") then updated=sprintf("%04d/%02d/%02d %02d:%02d:%02d",{year,month,day,hour,min,sec}) end if end procedure ------------------------------------------------------------------------------- -- wrap a few functions from kernel32.dll constant kernel32=open_dll("kernel32.dll"), gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_LONG), ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_LONG), cf=define_c_func(kernel32,"CreateFileA",repeat(C_POINTER,7),C_POINTER), ch=define_c_func(kernel32,"CloseHandle",{C_POINTER},C_LONG), -- reserving some memory mem_area=allocate(72), -- area for raw data create_time=mem_area, last_access=mem_area+8, last_write=mem_area+16, -- area for usable data system_create_time=mem_area+24, system_last_access=mem_area+40, system_last_write=mem_area+56, -- this flag is used later: it tells the OS to fail upon opening a file -- which doesn't exist OPEN_EXISTING = 3 -- set hfile to a handle on your file hfile=c_func(cf,{allocate_string(fname), 0, 0, 0, OPEN_EXISTING, 0, 0}) if not hfile then -- something went wrong, do something useful here end if -- now we have a file handle, let's get the timestamps -- you may wish to check if rc=0, which notifies of an error rc=c_func(gft,{hfile,create_time,last_access,last_write}) -- convert the data to something of use. Again, rc=0 means soething went wrong rc=c_func(ft2st,{create_time,system_create_time}) makeDate("system_create_time",system_create_time) rc=c_func(ft2st,{last_access,system_last_access}) makeDate("system_last_access",system_last_access) rc=c_func(ft2st,{last_write,system_last_write}) makeDate("system_last_write",system_last_write) wwait(sprintf("modified = %s \ncreation = %s \nlastAccess = %s",{updated, creation, lastAccess})) rc=c_func(ch,{hfile}) </EuCode>
14. Re: Other information and dates of an archive
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 05, 2007
- 627 views
Sergio Gelli wrote: > > CChris wrote: > > > Btw, Sergio, that is exactly what my "orientation" was.... > > > > CChris > > > OK, CCris, I made plus some changes and finally I am getting the dates > modified, created and last access. > > But, look at below the behavior of the EuCode with GTMs different, > Greenwich and Bras�a: > > > windows explorer dates with GTM = greenwich > modified= 2007/02/03 08:55 > creation= 2007/02/03 18:18 > accessed= 2007/02/03 00:00 > > Eucode dates with GTM = Greenwich > modified= 2007/02/03 08:55 > creation= 2007/02/03 18:18 > accessed= 2007/02/03 00:00 > > windows explorer dates with GTM = -03:00= Brasília > modified= 2007/02/03 08:55 > creation= 2007/02/03 18:18 > accessed= 2007/02/04 00:00 > > Eucode dates with GTM = -03:00= Brasília > modified= 2007/02/03 10:55 > creation= 2007/02/03 20:18 > accessed= 2007/02/03 02:00 > > However, the GTM is not being considered and this results in differences > in the value of the hours. > > It is probable that we will have that to find which GTM is being used > and to make additions or reductions in the value of the hour to show > it correctly. > > But how meeting the value of the GTM in the machine that the Eucode is > running? > > Many thanks again, > [snipped code] This information is in the time zone system info. You'll have to do some more define_c_ and peeks (see, not that difficult eh?):
-- wrap the relavant function from kernel32 constant kernel32=open_dll("kernel32.dll"), gtzi=define_c_func(kernel32,"GetTimeZoneInformation",{C_POINTER},C_ULONG), -- and get some storage for a TIME_ZONE_INFO structure tzi=allocate(172) integer rc,bias,std_bias,svt_bias -- fill the structure rc=c_func(gtzi,{a}) -- rc may be an error code, or say if we are in std time, xaving time or don't know bias=peek4s(a) std_bias=bias+peek4s(a+84) -- usually = bias svt_bias=bias+peek4s(a+168) -- free memory free(a)
After this, std_bias is the number of minutes that you have to add to your local standard time to get GMT time. svt_bias holds the number of minutes that separate your daylight savings time from GMT. On your machine, I'd expect values of 180 and 120 respectively. Divide the values by 60 to get the values in hours. These are the corrections Windows Explorer applies in reverse to display dates/times in user time. The remainder of the structure is made of the name of the times (standard and savings), and the switch dates between the two modes. I didn't google for the various return codes; you'll need to look up the Win32API doc and google to find out, if you need them. CChris
15. Re: Other information and dates of an archive
- Posted by Sergio Gelli <sergelli at uol.com.br> Feb 05, 2007
- 647 views
- Last edited Feb 06, 2007
> [snipped code] > This information is in the time zone system info. You'll have to do some > more define_c_ and peeks (see, not that difficult eh?): > > CChris Difficulties exist yes! For example, nor in my dreams I imagine where you he got used the number 172 in “tzi=allocate (172)” and in many others numbers. I am using it, but I do not know what really it is, what it does. Certainly, to make a code like this, a previous knowledge is necessary and I do not have now, but I am not finding tutorial on these subjects (API, DLL, define_c_func and etc.). You know where I you find these texts? Thanks for your patience for all that time. Sérgio Gelli
16. Re: Other information and dates of an archive
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 05, 2007
- 640 views
- Last edited Feb 06, 2007
Sergio Gelli wrote: > > > [snipped code] > > This information is in the time zone system info. You'll have to do some > > more define_c_ and peeks (see, not that difficult eh?): > > > > > CChris > > Difficulties exist yes! > > For example, nor in my dreams I imagine where you he got used the > number 172 in “tzi=allocate (172)” and in many others numbers. > > I am using it, but I do not know what really it is, what it does. > Certainly, to make a code like this, a previous knowledge is necessary > and I do not have now, but I am not finding tutorial on these > subjects (API, DLL, define_c_func and etc.). > > You know where I you find these texts? > > Thanks for your patience for all that time. > > Sérgio Gelli If you use win32lib, you can start here: http://www.king.igs.net/~wolfritz/tutor.htm Then the following is a must, even if it is aging: ftp://ftp.borland.com/pub/delphi/techpubs/delphi2/win32.zip Then, for the most up to date stuff, go to the OS makers: http://www.microsoft.com/msdownload/platformsdk/sdkupdate (huge downloads - I didn't attmpt it) All three links are in the Archive. As a bonus, you should also visit: http://msdn2.microsoft.com/en-us/library/aa139672.aspx Of course, the navigation is a little more difficult, but this is the ultimate reference. To compute the various sizes and offsets, you just need the structure layout and perform sums to find the offset of any desired field. All examples on M$/Borland docs are in C, but you'll see, this is not as difficult to read as some people on this list pretend. Sometimes, I have to complete this by technical tips googled for on the Web, but this is not too common. HTH CChris
17. Re: Other information and dates of an archive
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Feb 05, 2007
- 649 views
- Last edited Feb 06, 2007
Sergio Gelli wrote: > > > [snipped code] > > This information is in the time zone system info. You'll have to do some > > more define_c_ and peeks (see, not that difficult eh?): > > > > > CChris > > Difficulties exist yes! > > For example, nor in my dreams I imagine where you he got used the > number 172 in “tzi=allocate (172)” and in many others numbers. > > I am using it, but I do not know what really it is, what it does. > Certainly, to make a code like this, a previous knowledge is necessary > and I do not have now, but I am not finding tutorial on these > subjects (API, DLL, define_c_func and etc.). > > You know where I you find these texts? > > Thanks for your patience for all that time. > > Sérgio Gelli I forgot to mention that, for the Euphoria codding part, everything is explained in library.htm (in your euphoria HTML folder), under the "2.15 Calling C Functions (WIN32 and Linux)" section. CChris
18. Re: Other information and dates of an archive
- Posted by OtterDad <otter at full-moon.com> Feb 07, 2007
- 630 views
[snipped code] i couldn't help but keep trying at this code, if nothing else but for my own education. i wrapped the FileTimeToLocalFileTime function, which handles all the time zone, daylight savings time, time bias, etc. for you. i also added the windows api documentation more for my benefit. i tried to leave the original coding style in place to not confuse the original author.
-- gather other time stamp info from files. based on code posted to the forum: -- Date: 2007 Feb 5 15:35 -- From: CChris <christian.cuvier at agriculture.gouv.fr> -- Subject: Re: Other information and dates of an archive -- API documentation and FileTimeToLocalFileTime added by OtterDad without warning include win32lib.ew sequence fname, creation, lastAccess, updated, local_creation, local_lastAccess, local_updated atom hfile, year, month, dow, day, hour, min, sec, msec integer return_code fname = "C:\\ex.err" fname = "C:\\boot.ini" -- set this to the actual file name ----------------------------------------------------------------------------- procedure wwait(object messag ) atom result, rr rr = getSelf() if sequence (messag) then result = message_box(messag , "Message !", MB_ICONEXCLAMATION + MB_TASKMODAL) else result = message_box(sprintf( "%d\n", messag), "Message !", MB_ICONEXCLAMATION + MB_TASKMODAL) end if -- setFocus(rr) end procedure ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- procedure makeDate(sequence field, object data) -- reads and translates a SYSTEMTIME structure year = peek(data + 0) + (peek(data + 1) * 256) month = peek(data + 2) + (peek(data + 3) * 256) dow = peek(data + 4) + (peek(data + 5) * 256) day = peek(data + 6) + (peek(data + 7) * 256) hour = peek(data + 8) + (peek(data + 9) * 256) min = peek(data + 10) + (peek(data + 11) * 256) sec = peek(data + 12) + (peek(data + 13) * 256) msec = peek(data + 14) + (peek(data + 15) * 256) if match(field, "system_create_time") then creation = sprintf("%04d/%02d/%02d %02d:%02d:%02d", {year, month, day, hour, min, sec}) elsif match(field, "system_last_access") then lastAccess = sprintf("%04d/%02d/%02d %02d:%02d:%02d", {year, month, day, hour, min, sec}) elsif match(field, "system_last_write") then updated = sprintf("%04d/%02d/%02d %02d:%02d:%02d", {year, month, day, hour, min, sec}) elsif match(field, "local_system_create_time") then local_creation = sprintf("%04d/%02d/%02d %02d:%02d:%02d", {year, month, day, hour, min, sec}) elsif match(field, "local_system_last_access") then local_lastAccess = sprintf("%04d/%02d/%02d %02d:%02d:%02d", {year, month, day, hour, min, sec}) elsif match(field, "local_system_last_write") then local_updated = sprintf("%04d/%02d/%02d %02d:%02d:%02d", {year, month, day, hour, min, sec}) end if end procedure ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- wrap a few functions from kernel32.dll constant kernel32 = open_dll("kernel32.dll"), GetFileTime = define_c_func(kernel32, "GetFileTime", repeat(C_POINTER, 4), C_LONG), -- GetFileTime 11/30/2006 -- This function retrieves the date and time that a file was created, last accessed, and last modified. -- Syntax -- BOOL GetFileTime(HANDLE hFile, LPFILETIME lpCreationTime, LPFILETIME lpLastAccessTime, -- LPFILETIME lpLastWriteTime ); -- Parameters -- hFile - [in] Handle to the files for which to get dates and times. The file handle must have been -- created with GENERIC_READ access to the file. -- lpCreationTime - [out] Pointer to a FILETIME structure to receive the date and time the file was created. -- This parameter can be NULL if the application does not require this information. -- lpLastAccessTime - [out] Pointer to a FILETIME structure to receive the date and time the file was last -- accessed. The last access time includes the last time the file was written to, read from, or, in the -- case of executable files, run. This parameter can be NULL if the application does not require this -- information. -- lpLastWriteTime - [out] Pointer to a FILETIME structure to receive the date and time the file was last -- written to. This parameter can be NULL if the application does not require this information. -- Return Value -- Nonzero indicates success. -- Zero indicates failure. -- Remarks -- The FAT and NTFS file systems support the file creation, last access, and last write time values. -- The Windows Embedded CE object store returns the same creation time value for all three parameters. -- In general, file system drivers will vary how they support this function. The precision of the time -- for a file in a FAT file system is one second. The time precision for files in other file systems, -- such as those connected through a network or installed on a peripheral device, depends on the file -- system but may also be limited by the target device. -- Requirements -- Header: Winbase.h. -- Link Library: Coredll.lib. -- FILETIME -- Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). -- typedef struct _FILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; -- } FILETIME, *PFILETIME; -- Members -- dwLowDateTime - The low-order part of the file time. -- dwHighDateTime - The high-order part of the file time. -- Remarks -- To convert a FILETIME structure into a time that is easy to display to a user, use the -- FileTimeToSystemTime function. -- It is not recommended that you add and subtract values from the FILETIME structure to obtain -- relative times. Instead, you should: -- Copy the resulting FILETIME structure to a ULARGE_INTEGER structure using memcpy (using memcpy -- instead of direct assignment can prevent alignment faults on 64-bit Windows). -- Use normal 64-bit arithmetic on the ULARGE_INTEGER value. -- Not all file systems can record creation and last access time and not all file systems record them in -- the same manner. For example, on NT FAT, create time has a resolution of 10 milliseconds, write time -- has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). -- On NTFS, access time has a resolution of 1 hour. Therefore, the GetFileTime function may not return -- the same file time information set using the SetFileTime function. Furthermore, FAT records times on -- disk in local time. However, NTFS records times on disk in UTC. For more information, see File Times. FileTimeToSystemTime = define_c_func(kernel32, "FileTimeToSystemTime", repeat(C_POINTER, 2), C_LONG), -- Converts a file time to system time format. -- BOOL FileTimeToSystemTime( -- const FILETIME* lpFileTime, -- LPSYSTEMTIME lpSystemTime -- ); -- Parameters -- lpFileTime - [in] A pointer to a FILETIME structure containing the file time to convert to system date -- and time format. This value must be less than 0x8000000000000000. Otherwise, the function fails. -- lpSystemTime - [out] A pointer to a SYSTEMTIME structure to receive the converted file time. -- Return Value -- If the function succeeds, the return value is nonzero. -- If the function fails, the return value is zero. To get extended error information, call GetLastError. -- SYSTEMTIME - 11/30/2006 -- This structure represents a date and time using individual members for the month, day, year, weekday, -- hour, minute, second, and millisecond. -- Syntax -- typedef struct _SYSTEMTIME { -- WORD wYear; -- WORD wMonth; -- WORD wDayOfWeek; -- WORD wDay; -- WORD wHour; -- WORD wMinute; -- WORD wSecond; -- WORD wMilliseconds; -- } SYSTEMTIME; -- Members -- wYear - Specifies the current year. -- wMonth - Specifies the current month; January = 1, February = 2, and so on. -- wDayOfWeek - Specifies the current day of the week; Sunday = 0, Monday = 1, and so on. -- wDay - Specifies the current day of the month. -- wHour - Specifies the current hour. -- wMinute - Specifies the current minute. -- wSecond - Specifies the current second. -- wMilliseconds - Specifies the current millisecond. -- Remarks -- Millisecond granularity may not be supported by a hardware platform. The caller of this function should -- not rely on more than second granularity. -- It is not recommended that you add and subtract values from this structure to obtain relative times. -- The following list shows tasks to perform instead: -- Convert the SYSTEMTIME structure to a FILETIME structure. -- Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. -- Use usual 64-bit arithmetic on the ULARGE_INTEGER value. -- Requirements -- Header: Winbase.h. FileTimeToLocalFileTime = define_c_func(kernel32, "FileTimeToLocalFileTime", repeat(C_POINTER, 2), C_LONG), -- Converts a file time to a local file time. -- BOOL FileTimeToLocalFileTime( -- const FILETIME* lpFileTime, -- LPFILETIME lpLocalFileTime -- ); -- Parameters -- lpFileTime - [in] A pointer to a FILETIME structure containing the UTC-based file time to be -- converted into a local file time. -- lpLocalFileTime - [out] A pointer to a FILETIME structure to receive the converted local file time. -- This parameter cannot be the same as the lpFileTime parameter. -- Return Value -- If the function succeeds, the return value is nonzero. -- If the function fails, the return value is zero. To get extended error information, call GetLastError. -- Remarks -- FileTimeToLocalFileTime uses the current settings for the time zone and daylight saving time. -- Therefore, if it is daylight saving time, this function will take daylight saving time into account, -- even if the time you are converting is in standard time. You can use the following sequence of functions -- as an alternative. -- FileTimeToSystemTime -- SystemTimeToTzSpecificLocalTime -- SystemTimeToFileTime CreateFileA = define_c_func(kernel32, "CreateFileA", repeat(C_POINTER, 7), C_POINTER), CloseHandle = define_c_func(kernel32, "CloseHandle", {C_POINTER}, C_LONG), GetTimeZoneInformation = define_c_func(kernel32, "GetTimeZoneInformation", {C_POINTER}, C_ULONG), -- GetTimeZoneInformation -- This function retrieves the current time-zone parameters. These parameters control the translations -- between UTC and local time. -- DWORD GetTimeZoneInformation( LPTIME_ZONE_INFORMATION lpTimeZoneInformation ); -- Parameters -- lpTimeZoneInformation - [out] Pointer to a TIME_ZONE_INFORMATION structure to receive the current -- time-zone parameters. -- Return Values -- If the function succeeds, the return value is one of the following values: -- Value Description -- TIME_ZONE_ID_UNKNOWN = 0 The system cannot determine the current time zone. If daylight saving -- time is not used in the current time zone, this value is returned because there are no -- transition dates. -- TIME_ZONE_ID_STANDARD = 1 The system is operating in the range covered by the StandardDate member -- of the TIME_ZONE_INFORMATION structure. -- TIME_ZONE_ID_DAYLIGHT = 2 The system is operating in the range covered by the DaylightDate member -- of the TIME_ZONE_INFORMATION structure. -- If the function fails, the return value is TIME_ZONE_ID_UNKNOWN. -- Remarks -- All translations between UTC and local time are based on the following formula. -- UTC = local time + bias -- The bias is the difference, in minutes, between UTC and local time. -- If a call to SetTimeZoneInformation supplies a bias value but no transition date, -- GetTimeZoneInformation will return either TIME_ZONE_ID_STANDARD or TIME_ZONE_ID_DAYLIGHT. -- Requirements -- Header: Winbase.h. -- Link Library: Coredll.lib. TIME_ZONE_ID_UNKNOWN = 0, TIME_ZONE_ID_STANDARD = 1, TIME_ZONE_ID_DAYLIGHT = 2, -- reserving some memory mem_area = allocate(72 + 24 + 48), -- area for FILETIME raw data file_create_time = mem_area, file_last_access = mem_area+8, file_last_write = mem_area+16, -- area for local FILETIME raw data local_file_create_time = mem_area+24, local_file_last_access = mem_area+32, local_file_last_write = mem_area+40, -- area for SYSTEMTIME usable data system_create_time = mem_area+48, system_last_access = mem_area+64, system_last_write = mem_area+80, -- area for local SYSTEMTIME usable data local_system_create_time = mem_area+96, local_system_last_access = mem_area+112, local_system_last_write = mem_area+128, -- this flag is used later: it tells the OS to fail upon opening a file -- whiCloseHandle doesn't exist OPEN_EXISTING = 3, -- and get some storage for a TIME_ZONE_INFO structure TimeZoneInformation = allocate(172) integer bias, std_bias, svt_bias, TIME_ZONE_ID -- fill the structure TIME_ZONE_ID = c_func(GetTimeZoneInformation, {TimeZoneInformation}) -- rc may be an error code, or say if we are in std time, xaving time or don't know bias = peek4s(TimeZoneInformation) --warnErr(sprint(TIME_ZONE_ID) & " " & sprint(bias)) std_bias = bias+peek4s(TimeZoneInformation+84) -- usually = bias svt_bias = bias+peek4s(TimeZoneInformation+168) -- free memory free(TimeZoneInformation) -- set hfile to a handle on your file hfile = c_func(CreateFileA, {allocate_string(fname), 0, 0, 0, OPEN_EXISTING, 0, 0}) if not hfile then -- something went wrong, do something useful here warnErr("can't open " & fname) abort(1) end if -- now we have a file handle, let's get the timestamps -- you may wish to Check if return_code = 0, which notifies of an error return_code = c_func(GetFileTime, {hfile, file_create_time, file_last_access, file_last_write}) -- convert the data to something of use. Again, return_code = 0 means something went wrong return_code = c_func(FileTimeToSystemTime, {file_create_time, system_create_time}) makeDate("system_create_time", system_create_time) return_code = c_func(FileTimeToSystemTime, {file_last_access, system_last_access}) makeDate("system_last_access", system_last_access) return_code = c_func(FileTimeToSystemTime, {file_last_write, system_last_write}) makeDate("system_last_write", system_last_write) wwait(sprintf("modified = %s \ncreation = %s \nlastAccess = %s", {updated, creation, lastAccess})) -- now convert to local time return_code = c_func(FileTimeToLocalFileTime, {file_create_time, local_file_create_time}) return_code = c_func(FileTimeToSystemTime, {local_file_create_time, local_system_create_time}) makeDate("local_system_create_time", local_system_create_time) return_code = c_func(FileTimeToLocalFileTime, {file_last_access, local_file_last_access}) return_code = c_func(FileTimeToSystemTime, {local_file_last_access, local_system_last_access}) makeDate("local_system_last_access", local_system_last_access) return_code = c_func(FileTimeToLocalFileTime, {file_last_write, local_file_last_write}) return_code = c_func(FileTimeToSystemTime, {local_file_last_write, local_system_last_write}) makeDate("local_system_last_write", local_system_last_write) wwait(sprintf("modified = %s \ncreation = %s \nlastAccess = %s", {local_updated, local_creation, local_lastAccess})) return_code = c_func(CloseHandle, {hfile})
Yours, OtterDad Don't sweat it -- it's not real life. It's only ones and zeroes. Gene Spafford
19. Re: Other information and dates of an archive
- Posted by ZNorQ <znorq at holhaug.com> Feb 08, 2007
- 635 views
OtterDad wrote: > > [snipped code] > > i couldn't help but keep trying at this code, if nothing else but for my own > education. i wrapped the FileTimeToLocalFileTime function, which handles all > the time zone, daylight savings time, time bias, etc. for you. i also added > the windows api documentation more for my benefit. i tried to leave the > original coding style in place to not confuse the original author. > Nice work, OtterDad! I'll have a go at it, and give you some feedback later! This is probably what I need. ZNorQ