Re: Other information and dates of an archive

new topic     » goto parent     » topic index » view thread      » older message » newer message

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>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu