LPARAMETERS OUTREF laDirectory, INP lcMask,OPT_INP lnFlag
LOCAL cStruct, liResult, lnCount, fResult, lffHandle,lihFTP,liRead,lii,lcBuffer,lcData,liData
IF This.OpenFTPConnection(This.cCurrentDir) && Open an FTP Handle
* Dimension the array to store the directory
* [x, 1] = FileName
* [x, 2] = Alternate FileName
* [x, 3] = File Size
* [x, 4] = File Create Date
* [x, 5] = File Last Access Time
* [x, 6] = File Last Write Time
* [x, 7] = File Attributes
DIMENSION laDirectory [1, 7]
laDirectory [1, 1] = .F.
fResult=IIF(This.FTPCommand("LIST "+lcMask,FTP_TRANSFER_TYPE_ASCII,0,@lihFTP),1,0)
IF fResult #0 && OK, FTP list is openned
lii=0
liData=500
STORE 1 TO fResult,liRead
lcData=""
DO WHILE liRead>0
liRead=0
lcBuffer=SPACE(liData)
fResult = InternetReadFile(lihFTP, @lcBuffer, liData, @liRead)
=This.GetExtendedError()
lcData=lcData+LEFT(lcBuffer,liRead)
lii=lii+liRead
ENDDO
IF VAL(STRTRAN(SUBS(VERSION(),LEN("Visual FoxPro ")+1,2),"0",""))>=6
* liCount=ALINES()
ELSE
ENDIF
*SUSPEND
=STRTOFILE(lcData,"e:\list.txt")
* fòuk, fnuk, I'm lazy : http://cr.yp.to/ftpparse/ftpparse.c
*!* /* UNIX-style listing, without inum and without blocks */
*!* /* "-rw-r--r-- 1 root other 531 Jan 29 03:26 README" */
*!* /* "dr-xr-xr-x 2 root other 512 Apr 8 1994 etc" */
*!* /* "dr-xr-xr-x 2 root 512 Apr 8 1994 etc" */
*!* /* "lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin" */
*!* /* Also produced by Microsoft's FTP servers for Windows: */
*!* /* "---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z" */
*!* /* "d--------- 1 owner group 0 May 9 19:45 Softlib" */
*!* /* Also WFTPD for MSDOS: */
*!* /* "-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp" */
*!* /* Also NetWare: */
*!* /* "d [R----F--] supervisor 512 Jan 16 18:53 login" */
*!* /* "- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe" */
*!* /* Also NetPresenz for the Mac: */
*!* /* "-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit" */
*!* /* "drwxrwxr-x folder 2 May 10 1996 network" */
* STRTOFILE(lcData,"e:\list.txt")
*!* * This is for a FoxPro Quirk.
*!* lcStruct = SPACE(319) && Allocate space for the returned structure
*!*
*!* * =This.BeforeGetFTPDirectoryArray(@laDirectory, @lcMask,lnFlag)
*!* * Get the first file or find out if
*!* lffHandle = FtpFindFirstFile(This.nConnect_Handle, @lcMask, @lcStruct, lnFlag, 0)
*!* This.GetExtendedError()
*!*
*!* IF lffHandle = 0 OR This.nResult_Code = ERROR_NO_MORE_FILES
*!* This.CloseFTPConnection() && Close FTP Handle
*!* RETURN .F.
*!* ENDIF
*!* * Parse out First File Information
*!* =This.CrackFile(lcStruct, @laDirectory)
*!*
*!* llResult = 1
*!* DO WHILE This.nResult_Code != ERROR_NO_MORE_FILES AND llResult != 0
*!* lcStruct = SPACE(319)
*!* * Get next files
*!* liResult = InternetFindNextFile(lffHandle, @lcStruct)
*!* =This.GetExtendedError()
*!*
*!* * If we got good information, go ahead and parse it
*!* IF This.nResult_Code != ERROR_NO_MORE_FILES AND llResult != 0
*!* =This.CrackFile(lcStruct, @laDirectory)
*!* ENDIF
*!* ENDDO
* =This.AfterGetFTPDirectoryArray(@laDirectory, @lcMask, lnFlag,liResult)
ENDIF
=This.CloseFTPConnection() && Close FTP Handle
ELSE
RETURN .F. && Unable to get FTP Connection
ENDIF
RETURN .T.