Verfasst: 19.12.2005 15:12
ich wollt ne seach funktion baun die leere ordner und 0 byte datein erkennt und in eine liste (NewList files.files()) schreibt
Code: Alles auswählen
Procedure.l IsEmptyDir(Dir$)
Protected DirElement.l
Protected wasgefunden.s
ExamineDirectory(0, Dir$, "*.*")
DirElement = NextDirectoryEntry(0)
While direlement <> 0
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
wasgefunden = "wahr"
direlement = 0
Else
If DirectoryEntryName(0) = "."
wasgefunden = "falsch"
ElseIf DirectoryEntryName(0) = ".."
wasgefunden = "falsch"
Else
wasgefunden = "wahr"
direlement = 0
EndIf
EndIf
DirElement = NextDirectoryEntry(0)
Wend
If wasgefunden = "falsch"
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
;(*)
; "." und ".." sind Bestandteil eines jeden Verzeichnisses unter Windows.
EndProcedure
; --- Anwendungsbeispiel ---
Dir$ = PathRequester("Verzeichnis wählen", "C:\")
If IsEmptyDir(Dir$)
MessageRequester("Ergebnis", "Das Verzeichnis " + Dir$ + " ist leer.")
Else
MessageRequester("Ergebnis", "Das Verzeichnis " + Dir$ + " ist nicht leer.")
EndIf
End
Code: Alles auswählen
Procedure dirIsEmpty(path.s)
Protected res.l
Protected name.s
Protected dir.l
If Right( path, 1) <> "\"
path+"\"
EndIf
dir=ExamineDirectory(#PB_Any, path, "*.*")
If dir
res=1
While NextDirectoryEntry(dir) And res
name=DirectoryEntryName(dir)
If name <> "." And name <> ".."
res=0
EndIf
Wend
FinishDirectory(dir)
EndIf
ProcedureReturn res
EndProcedure
Debug dirIsEmpty("C:\test\empty.dir\")
Debug dirIsEmpty("C:\Windows")
Debug dirIsEmpty("C:\Windows\")
Debug dirIsEmpty("T:\I_am_not\")
Debug dirIsEmpty(" h th6tht öpö tht ht #+#+ 3547")
Code: Alles auswählen
Procedure.q isNotEmpty(pfad$)
If Not Right(pfad$, 1) = "\"
pfad$+"\"
EndIf
Protected dir=ExamineDirectory(#PB_Any, pfad$, ""), empty=0
If dir
While NextDirectoryEntry(dir)
If DirectoryEntryName(dir) <> "." And DirectoryEntryName(dir) <> ".."
empty=-3
Break
EndIf
Wend
FinishDirectory(dir)
ProcedureReturn empty
EndIf
ProcedureReturn FileSize(Left(pfad$, Len(pfad$)-1))
EndProcedure
Debug isEmpty("C:\") ; gibt es, NICHT leer
Debug isEmpty("C:\temp") ; gibt es auch, NICHT leer
Debug isEmpty("C:\temp\egal") ; gibt es, >>>LEER<<<
Debug isEmpty("C:\temp\GIBT ES NICHT!!!!") ; gibt es NICHT
Debug isEmpty("C:\pagefile.sys") ; kein gültiger ordner, sondern eine datei
#NULL hat geschrieben:__ IsEmpty() ?
_____ YES, äh..naja
__ IS_EMPTY() ??
_____ YES, but, äh no, is not
__ IS_EMPTY() ????
_____ NO,, äh, ..#TRUE, but NO, is not empty,
__ ???????
_____ is file.
_____ and file is IsEmpty() bytes groß.
__ ...
_____![]()
![]()
![]()
__ If IsEmpty()=1 And One()=Empty() And Not One()=OneByteFile()
...
AND51 hat geschrieben:Machst du dich über mich lustig?