How to get Date and Time with oFTP

How to get Date and Time with oFTP

Postby John » Sat Nov 04, 2006 11:06 am

Hi,

i'm using oFTP:Directory("*.*"), but it seems it only returns the name and file size. Is there any way to also retrieve the file's date and time?

Thanks,

John.
John
 
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Postby Antonio Linares » Fri Nov 10, 2006 7:30 am

John,

Please modify Class TFtp Method Directory this way:
Code: Select all  Expand view
...
      if ! Empty( oWin32FindData:cFileName )
         AAdd( aFiles, { oWin32FindData:cFileName,;
                         oWin32FindData:nSizeLow,;
                         oWin32FindData:nLastWriteAccess,;
                         oWin32FindData:nCreationTime } )
         while InternetFindNextFile( hFTPDir, @cBuffer )
            oWin32FindData:cBuffer = cBuffer
            AAdd( aFiles, { oWin32FindData:cFileName,;
                            oWin32FindData:nSizeLow,;
                            oWin32FindData:nLastWriteAccess,;
                            oWin32FindData:nCreationTime } )
         end
      endif
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby John » Fri Nov 10, 2006 8:30 am

Hi Antonio,

thanks for the reply. It seems i only get the time returned in this case?

Regards,

John.
John
 
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Postby Antonio Linares » Fri Nov 10, 2006 9:27 am

John,

What value do you get for oWin32FindData:nLastWriteAccess ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby John » Sat Nov 11, 2006 8:46 am

Hi Antonio,

i probably did something wrong because i get only empty strings returned for the date and time:

aFtpList:=oFTP:Directory("*.*")
ShowArr(aFtpList)

Function ShowArr(aDirList)
aEval(aDirList,{|i,t| iif(Valtype(i)=="A",(ShowArr(i)),(msgalert(i)) ) })
Return (.t.)

Any suggestions?

Regards,

John.
John
 
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Postby Antonio Linares » Sat Nov 11, 2006 9:23 am

John,

Please try this:

aFtpList:=oFTP:Directory("*.*")
MsgInfo( Len( aFtpList[ 1 ][ 3 ] ) )

and let me know what you get, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby John » Sat Nov 11, 2006 3:25 pm

Antonio,

it returns an 8, but i can't relate that to a file present...

Regards,

John.
John
 
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Postby Antonio Linares » Mon Nov 13, 2006 7:24 am

John,

It looks like there is something different from a number there.
Please try this:
Code: Select all  Expand view
aFtpList:=oFTP:Directory("*.*")
for n = 1 to Len( aFtpList[ 1 ][ 3 ] )
   MsgInfo( Asc( SubStr( aFtpList[ 1 ][ 3 ], n, 1 ) ) )
next

and let me know what you get, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby John » Thu Nov 16, 2006 6:22 pm

Hi Antonio,

the following files are present in the ftp directory:
Image

I get the following results:
0, 46, 46, 201, 78, 240, 198, 1

Best regards,

John.
John
 
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Postby Antonio Linares » Thu Nov 16, 2006 6:34 pm

John,

Please copy here the values that you get for each of the four items that you have in the directory, thanks.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Fri Nov 17, 2006 7:26 am

John,
Code: Select all  Expand view
aFtpList:=oFTP:Directory("*.*")
for m = 1 to Len( aFtpList )
   for n = 1 to Len( aFtpList[ m ][ 3 ] )
      MsgInfo( Asc( SubStr( aFtpList[ m ][ 3 ], n, 1 ) ) )
   next
next

so we can see the eight bytes for each file.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby John » Sat Nov 18, 2006 5:24 am

Antonio,

the values are:
0, 46, 46, 201, 78, 240, 198, 1, 0, 232, 33, 111, 190, 255, 198, 1, 0, 46, 46, 201, 78, 240, 198, 1, 0, 46, 46, 201, 78, 240, 198, 1.

Saludos,

John.
John
 
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Postby Antonio Linares » Sat Nov 18, 2006 7:40 am

John,

It looks as three files have the same date:

0, 46, 46, 201, 78, 240, 198, 1
0, 46, 46, 201, 78, 240, 198, 1
0, 46, 46, 201, 78, 240, 198, 1
0, 232, 33, 111, 190, 255, 198, 1

From the image that you provided, three have the same date too:

15-10-2006
15-10-2006
15-10-2006
4-11-2006

Now we need to find in what data format the dates are stored.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sat Nov 18, 2006 8:06 am

The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601.

typedef struct _FILETIME { // ft
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;

Lets see how to get a Clipper date and time from that :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sat Nov 18, 2006 8:22 am

This is the API function to use:

The FileTimeToSystemTime function converts a 64-bit file time to system time format.

BOOL FileTimeToSystemTime(

CONST FILETIME *lpFileTime, // pointer to file time to convert
LPSYSTEMTIME lpSystemTime // pointer to structure to receive system time
);
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 128 guests