FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to get Date and Time with oFTP
Posts: 67
Joined: Mon Dec 26, 2005 07:44 AM
How to get Date and Time with oFTP
Posted: 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.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Fri Nov 10, 2006 07:30 AM
John,

Please modify Class TFtp Method Directory this way:
...
      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
Posts: 67
Joined: Mon Dec 26, 2005 07:44 AM
How to get Date and Time with oFTP
Posted: Fri Nov 10, 2006 08:30 AM

Hi Antonio,

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

Regards,

John.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Fri Nov 10, 2006 09:27 AM

John,

What value do you get for oWin32FindData:nLastWriteAccess ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 67
Joined: Mon Dec 26, 2005 07:44 AM
How to get Date and Time with oFTP
Posted: Sat Nov 11, 2006 08: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.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Sat Nov 11, 2006 09: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
Posts: 67
Joined: Mon Dec 26, 2005 07:44 AM
How to get Date and Time with oFTP
Posted: Sat Nov 11, 2006 03:25 PM

Antonio,

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

Regards,

John.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Mon Nov 13, 2006 07:24 AM
John,

It looks like there is something different from a number there.
Please try this:
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
Posts: 67
Joined: Mon Dec 26, 2005 07:44 AM
How to get Date and Time with oFTP
Posted: Thu Nov 16, 2006 06:22 PM
Hi Antonio,

the following files are present in the ftp directory:


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

Best regards,

John.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Thu Nov 16, 2006 06: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Fri Nov 17, 2006 07:26 AM
John,
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
Posts: 67
Joined: Mon Dec 26, 2005 07:44 AM
How to get Date and Time with oFTP
Posted: Sat Nov 18, 2006 05: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.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Sat Nov 18, 2006 07: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Sat Nov 18, 2006 08: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
How to get Date and Time with oFTP
Posted: Sat Nov 18, 2006 08: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