Vlatko
Dec 24th, 2000, 02:25 PM
Can someone translate this code i got from Jop to C++. I am having most trouble with the dinamyc arrays.
Public Sub GetAllFilesAPI(StartDir As String)
Dim d$, dr As Boolean, dts As Boolean, dirs() As String
Dim FindData As WIN32_FIND_DATA, c%, file&
If Right(StartDir, 1) <> "\" Then StartDir = StartDir & "\"
ReDim dirs(0)
file = FindFirstFile(StartDir & "*", FindData)
c = 1
Do While c <> 0
c = FindNextFile(file, FindData)
d = StripNulls(FindData.cFileName)
dts = d <> "." And d <> ".." And Len(d) > 0
If dts Then dr = (GetFileAttributes(StartDir & d) And FILE_ATTRIBUTE_DIRECTORY)
If dr = False And dts Then Form1.List1.AddItem StartDir & d 'add to list
If dr And dts Then 'dir found
ReDim Preserve dirs(UBound(dirs) + 1)
dirs(UBound(dirs)) = d
End If
Loop
Dim x&
FindClose file
For x = 1 To UBound(dirs)
GetAllFilesAPI StartDir & dirs(x)
Next x
End Sub
Public Sub GetAllFilesAPI(StartDir As String)
Dim d$, dr As Boolean, dts As Boolean, dirs() As String
Dim FindData As WIN32_FIND_DATA, c%, file&
If Right(StartDir, 1) <> "\" Then StartDir = StartDir & "\"
ReDim dirs(0)
file = FindFirstFile(StartDir & "*", FindData)
c = 1
Do While c <> 0
c = FindNextFile(file, FindData)
d = StripNulls(FindData.cFileName)
dts = d <> "." And d <> ".." And Len(d) > 0
If dts Then dr = (GetFileAttributes(StartDir & d) And FILE_ATTRIBUTE_DIRECTORY)
If dr = False And dts Then Form1.List1.AddItem StartDir & d 'add to list
If dr And dts Then 'dir found
ReDim Preserve dirs(UBound(dirs) + 1)
dirs(UBound(dirs)) = d
End If
Loop
Dim x&
FindClose file
For x = 1 To UBound(dirs)
GetAllFilesAPI StartDir & dirs(x)
Next x
End Sub