LPARAMETERS OUTREF laDirectory, INP lcMask,OPT_INP lnFlag, OUTREF liCount
LOCAL cStruct, liResult, fResult, lffHandle,lii,lnSize
IF This.OpenFTPConnection(This.cCurrentDir) && Open an FTP Handle
lcMask = m.lcMask + cNULL
* 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 m.laDirectory [1, 7]
laDirectory [1, 1] = .F.
lnFlag=BITOR(INTERNET_FLAG_RELOAD,IIF(PCOUNT()<=3,0,m.lnFlag))
liCount=0
* This is for a FoxPro Quirk.
lcStruct = REPL(CHR(0),319)+CHR(0) && Allocate space for the returned structure
=This.BeforeGetFTPDirectoryArray(@m.laDirectory, @m.lcMask,m.lnFlag)
* Get the first file or find out if
lffHandle = FtpFindFirstFile(This.nConnect_Handle, @m.lcMask, @m.lcStruct, m.lnFlag, 0)
This.GetExtendedError()
IF m.lffHandle = 0 AND This.nResult_Code <> ERROR_NO_MORE_FILES
RETURN .F.
ENDIF
IF m.lffHandle = 0 AND This.nResult_Code = ERROR_NO_MORE_FILES
RETURN .T.
ENDIF
* Parse out First File Information
=This.CrackFile(m.lcStruct, @m.laDirectory)
liCount=1
llResult = 1
DO WHILE This.nResult_Code != ERROR_NO_MORE_FILES AND m.llResult != 0
lcStruct = SPACE(319)
* Get next files
liResult = InternetFindNextFile(m.lffHandle, @m.lcStruct)
=This.GetExtendedError()
* If we got good information, go ahead and parse it
IF This.nResult_Code != ERROR_NO_MORE_FILES AND m.llResult != 0
liCount=m.liCount+1
=This.CrackFile(m.lcStruct, @m.laDirectory)
ENDIF
ENDDO
=This.AfterGetFTPDirectoryArray(@m.laDirectory, @m.lcMask, m.lnFlag,m.liResult)
=InternetCloseHandle(m.lffHandle)
FOR lii=1 TO ALEN(m.laDirectory,1)
IF ATC(m.laDirectory(m.lii,7),"D")=0 AND This.GetFileSize(m.laDirectory(m.lii,1),@m.lnSize)
laDirectory(m.lii,3)=m.lnSize
ENDIF
NEXT
=IIF(This.lMultiOperations,.T.,This.CloseFTPConnection()) && Close FTP Handle
RETURN .T.
ELSE
RETURN .F. && Unable to get FTP Connection
ENDIF