TriSight Regular
Joined: 12 Oct 2004 Posts: 69 Location: Mobile, AL
|
Posted: Oct 28th, 2004 10:37 AM Post subject: Unix FTP LIST Parser -_Snippet_- |
|
|
When you send a LIST command to a unix system, it will return a packet of data (delimited by vbCRLF (carriage return/line feed)). The following is a function to send in a line and have it return an array of information.. I will let you figure out the column positions of the information returned but I will say that the first column is the permissions, the 9th column is the Filename and the 5th column is the Filesize.. the other things you can get on your own :-D Hope this helps someone else ..
[vb:1:670dd5f480]Public Function aGet_UnixTokens(strLineIn As String) As String()
'// Written by Jimmy C. Broadhead, Jr. 10/21/2004
Dim intCurrentToken As Integer
Dim intTokenLength As Integer
Dim intTokenStart As Integer
Dim intStartingPosition As Integer
Dim intLineLength As Integer
Dim astrDataTokens(1 To 9) As String
On Error GoTo GetTokens_Errors
intCurrentToken = 1
intTokenLength = 0
intStartingPosition = 1
intLineLength = Len(strLineIn)
While (intTokenStart + intTokenLength) < intLineLength
If Trim(Mid(strLineIn, intStartingPosition, 1)) = "" Then
If intTokenLength > 0 Then
astrDataTokens(intCurrentToken) = Mid(strLineIn, intTokenStart, intTokenLength)
intCurrentToken = intCurrentToken + 1
intTokenLength = 0
End If
Else
If intTokenLength = 0 Then
intTokenStart = intStartingPosition
End If
intTokenLength = intTokenLength + 1
End If
intStartingPosition = intStartingPosition + 1
Wend
If intTokenLength > 0 Then astrDataTokens(9) = Mid(strLineIn, intTokenStart, intTokenLength + 1)
aGet_UnixTokens = astrDataTokens
On Error GoTo 0
GetTokens_Errors:
' // Error handling code goes here
End Function[/vb:1:670dd5f480] _________________ /=--_The Nomad_--=\
"Men of lofty genius when they are doing the least work are most active. " - Leonardo da Vinci |
|