Page 1 of 1

DirectoryEntryType()

Posted: Sun Apr 11, 2010 10:22 pm
by Thomas
The command ExamineDirectory() normally works as designed. But I have written a procedure which recursively goes through the filesystem. When the NextDirectoryEntry() command gets the next element and it's a symbolic link, the DirectoryEntryType() command treats it like a directory. Maybe it's not really a bug but symbolic links should not be treated as directories. A new type #PB_DirectoryEntry_Link should do the trick.

Code: Select all

Procedure recursive(dir,path.s,files)
  While NextDirectoryEntry(dir)
    If DirectoryEntryType(dir)=#PB_DirectoryEntry_Directory
      If DirectoryEntryName(dir)<>"." And DirectoryEntryName(dir)<>".."
        If ExamineDirectory(dir+1,path+DirectoryEntryName(dir),"")
          files=files+recursive(dir+1,path+DirectoryEntryName(dir)+"\",0)
          FinishDirectory(dir+1)
        Else
          Debug "error for "+path+DirectoryEntryName(dir)
        EndIf
      EndIf
    Else
      files=files+1
    EndIf
  Wend
  ProcedureReturn files
EndProcedure

ExamineDirectory(1,"C:\","")
Debug Str(recursive(1,"C:\",0))+" files in the filesystem"