Описание функции


EmptyFoldersSearch

Поиск пустых папок

EmptyFoldersSearch(Dir.s, List Folder.s())

Параметры

Dir.s Папка в которой искать
Folder.s() Пустой список, куда будут добавлены пустые папки

Возвращаемое значение

ничего

Пример

; AZJIO
; https://www.purebasic.fr/english/viewtopic.php?p=584960#p584960

Procedure EmptyFoldersSearch(Dir.s, List Folder.s())
    Protected ID, EntryName.s, d, z
    ID = ExamineDirectory(#PB_Any, Dir, "")
    If ID
        Repeat
            z = NextDirectoryEntry(ID)
            d + 1
            If z
                EntryName=DirectoryEntryName(ID)
                If EntryName = "." Or EntryName = ".."
                    Continue
                EndIf
                If DirectoryEntryType(ID) = #PB_DirectoryEntry_Directory
                    EmptyFoldersSearch(Dir + #PS$ + EntryName, Folder())
                EndIf
            Else
                If d = 3 And AddElement(Folder())
                    Folder() = Dir
                EndIf
                d = 0
                Break
            EndIf
        ForEver
        FinishDirectory(ID)
    EndIf
EndProcedure

Define NewList Folder.s()
Define Path.s = "C:\ProgramData"
; If Right(Path, 1) = #PS$
Path = RTrim(Path, #PS$)
; EndIf
EmptyFoldersSearch(Path, Folder())
Debug ListSize(Folder())

ForEach Folder()
    Debug Folder()
Next