Code: Select all
; Is it safe to do this:
Procedure IsDirEmpty1(Path$)
Protected i = 0
If ExamineDirectory(0, Path$, "*")
While NextDirectoryEntry(0)
i+1
If i > 2
i = 0
Break
EndIf
Wend
FinishDirectory(0)
Else
i = -1
EndIf
ProcedureReturn i
EndProcedure
Procedure IsDirEmpty(Path$)
Protected res$, i = 1
If ExamineDirectory(0, Path$, "*")
While NextDirectoryEntry(0)
res$ = DirectoryEntryName(0)
If res$ = ".." Or res$ = "."
res$ = ""
Continue
EndIf
If res$
i = 0
Break
EndIf
Wend
FinishDirectory(0)
Else
i = -1
EndIf
ProcedureReturn i
EndProcedure
Debug IsDirEmpty(GetHomeDirectory() + "test1")