Beege Posted October 13, 2006 Share Posted October 13, 2006 (edited) Heres a couple UDFs I helped put together for array data. They both work but Any help on how they can be writen better would be great.expandcollapse popup;=============================================================================== ; ; Function Name: _FtpFileListTo2DArray() ; Description: Get Filenames and filesizes of a Directory. ; Parameter(s): $Remote_Dir - The Directory to be set. ; $Server - Server address ; $username - User name ; $pass - Password ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Me ; ;=============================================================================== Func _FTPFileListTo2DArray($Remote_Dir, $server = '', $username = '', $pass = '') Local $2DArray $2DArray = _ArrayCreate($2DArray) $Open = _FTPOpen('xbox') $Conn = _FTPConnect($Open, $server, $username, $pass, 1) $setdir = _FtpSetCurrentDir($Conn, $Remote_Dir) $cdir = _FTPGetCurrentDir($Conn) $files = _FTPFilesListToArray($Conn, 2) $max = UBound($files) ReDim $2DArray[$max][2] For $i = 0 To $files[0] $2DArray[$i][0] = $files[$i] Next $Totalsize = 0 $end = $2DArray[0][0] ProgressOn('FTP', 'Getting File Sizes...') For $i = 1 To $end $setdir = _FtpSetCurrentDir($Conn, '/F/Videos/') $size = _FTPGetFileSize($Conn, $2DArray[$i][0]) $2DArray[$i][1] = $size $size = Round($size / 1048576, 1) $Totalsize = $size + $Totalsize ProgressSet(($i / $end) * 100, Round(($i / $end) * 100, 1) & ' % ' & $2DArray[$i][0], $end - $i & ' Files ' & $Totalsize & ' MB Total') Next ProgressOff() $Ftpc = _FTPClose($Open) $2DArray[0][1] = $Totalsize Return $2DArray EndFunc ;==>_FTPFileListTo2DArray ;=============================================================================== ; ; Function Name: _FtpFilesListToArray() ; Description: Get Filenames, Directorys, or Both of a Directory. ; Parameter(s): $l_FTPSession - Long From _FileConnect ; $Return_type - 0 = Both Files and Directorys, 1 = Directorys, 2 = Files ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): Me ; ;=============================================================================== Func _FTPFilesListToArray($l_FTPSession, $Return_Type = 0, $l_Flags = 0, $l_Context = 0) Dim $array, $array2d $array = _ArrayCreate($array) $array2d = _ArrayCreate($array2d) $str = "dword;int64;int64;int64;dword;dword;dword;dword;char[256];char[14]" $WIN32_FIND_DATA = DllStructCreate($str) Local $callFindFirst = DllCall('wininet.dll', 'int', 'FtpFindFirstFile', 'long', $l_FTPSession, 'str', "", 'ptr', DllStructGetPtr($WIN32_FIND_DATA), 'long', $l_Flags, 'long', $l_Context) If Not $callFindFirst[0] Then MsgBox(0, "Folder Empty", "No Files Found ") SetError(-1) Return 0 EndIf $ret = "" While 1 Select Case $Return_Type = 0 ; Folders and files If DllStructGetData($WIN32_FIND_DATA, 1) = 16 Then _ArrayInsert($array, 1, DllStructGetData($WIN32_FIND_DATA, 9)) ; Add Folder to top of array Else _ArrayAdd($array, DllStructGetData($WIN32_FIND_DATA, 9)) ; Add folder to array EndIf Case $Return_Type = 1 ; Folders only If DllStructGetData($WIN32_FIND_DATA, 1) = 16 Then _ArrayAdd($array, DllStructGetData($WIN32_FIND_DATA, 9)) Case $Return_Type = 2 ; Files only If DllStructGetData($WIN32_FIND_DATA, 1) <> 16 Then _ArrayAdd($array, DllStructGetData($WIN32_FIND_DATA, 9)) EndSelect Local $callFindNext = DllCall('wininet.dll', 'int', 'InternetFindNextFile', 'long', $callFindFirst[0], 'ptr', DllStructGetPtr($WIN32_FIND_DATA)) If Not $callFindNext[0] Then ExitLoop EndIf WEnd $WIN32_FIND_DATA = 0 $array[0] = UBound($array) - 1 Return $array EndFunc ;==>_FTPFilesListToArray_FTPFileListTo2DArray() Example: #include<ftp.au3>#include<array.au3>#include<Array2D.au3>$server = '192.168.0.3'$username = 'xbox'$pass = 'xbox'$Open = _FTPOpen('xbox')$Conn = _FTPConnect($Open, $server, $username, $pass, 1)$setdir = _FTPSetCurrentDir($Conn, '/F/Videos/')$Arrayfilelist = _FTPFileListTo2DArray('/F/Videos/', $server, $username, $pass)_Array2dDisplay2($Arrayfilelist); _FTPFilesListToArray() Example:$Open = _FTPOpen('xbox')$Conn = _FTPConnect($Open, $server, $username, $pass, 1)$setdir = _FTPSetCurrentDir($Conn, '/F/Videos/')$Dirlist = _FTPFilesListToArray($Conn, 1) _ArrayDisplay($Dirlist, 'Directorys List')$Ftpc = _FTPClose($Open)$Open = _FTPOpen('xbox')$Conn = _FTPConnect($Open, $server, $username, $pass, 1)$setdir = _FTPSetCurrentDir($Conn, '/F/Videos/')$Fileslist = _FTPFilesListToArray($Conn, 2) _ArrayDisplay($Fileslist, 'Files List')$Ftpc = _FTPClose($Open)$Open = _FTPOpen('xbox')$Conn = _FTPConnect($Open, $server, $username, $pass, 1)$setdir = _FTPSetCurrentDir($Conn, '/F/Videos/')$DirFileslist = _FTPFilesListToArray($Conn, 0)_ArrayDisplay($DirFileslist, 'Directorys & Files List')$Ftpc = _FTPClose($Open)Exit Edited August 31, 2010 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now