| |
|
|
Frank Abbing | Perhaps is so one Thread time nice. Someone asks a programming task and the rest trying to find a short and good solution... The best solution would be put to the code snippets.
My task for today is:
Find a short and fast Solution to determine, if a directory is empty or not! |
|
|
| |
|
|
|
Rolf Koch | Mach time whom beginning make. naturally only secular nature
And from the length I find it personally still in order, I very highly compressed codes leseunfreundlich find ^^ CompileMarkSeparation |
|
|
| |
|
|
|
Jörg Sellmeyer | the falls me to a. is longer but faster. Turnaround times for example, Rolfs C.: on, then is first Waiting angesagt. Also should return to ursprüngliche Directory to be changed. CompileMarkSeparation
Proc DirIsEmpty
Parameters Dir$
Declare Dir1$
CaseNot DirExists(Dir$):Return -1
Dir1$ = GetDir$("@")
ChDir Dir$
If (Len(Dir$) <= 3) = 0
FindFirst$("*")
FindNext$()
Dir$ = FindNext$()
Else
Dir$ = FindFirst$("*")
EndIf
ChDir Dir1$
Return Len(Dir$) = 0
EndProc
Declare Ausgabe$
Ausgabe$ = "qnicht vorhanden!q,qnicht leerq,qleerq"
Print "C:XXXXX ist " + SubStr$(Ausgabe$,DirIsEmpty("C:XXXXX") + 2,",")
MkDir "C:XXXXX"
Print "C:XXXXX ist " + SubStr$(Ausgabe$,DirIsEmpty("C:XXXXX") + 2,",")
Assign #1,"Test.txt"
ReWrite #1
Print #1,"Test"
Close #1
Print "C:XXXXX ist " + SubStr$(Ausgabe$,DirIsEmpty("C:XXXXX") + 2,",")
Erase "C:XXXXXTest.txt"
RMDir "C:XXXXX"
' das Löschen funktioniert bei mir nicht - keine Ahnung warum
' liegts am System oder an Profan?
' also gegebenenfalls von Hand löschen
Print $Winpath + " ist " + SubStr$(Ausgabe$,DirIsEmpty($winpath) + 2,",")
Print "C: ist " + SubStr$(Ausgabe$,DirIsEmpty("C:") + 2,",")
WaitInput
Edit: ne still small correction applied! |
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 08/25/08 ▲ |
|
|
|
|
Rolf Koch | back in that old directory? Jo haste full right But the root C:?? Should always be something drinne
Edit: Habs also adapted. Determined as still missing what, but yes should also be short ^^ C: E: and Co are indeed not directly drives and directories, or I see it wrong? |
|
|
| |
|
|
|
| Can we look at "performantestes Beispiel" some? |
|
|
| |
|
|
|
Jörg Sellmeyer |
C: E: and Co are indeed not directly drives and directories, or I see it wrong?
you know never, what a user of your program. Something like must But we are definitely. Also glite the same for deeply nested directories. I had folder structures with 20 - 30000 Files and subfolders hundreds. 'll Ask people with 'ner large mp3-collection how to feel, if you empty folder with a program tracking want and at first at each check 10 min coffee break is announced. |
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 08/26/08 ▲ |
|
|
|
|
| Especially when not even no coffee in the house! |
|
|
| |
|
|
|
| Certainly no other provisos Frank?
A directory is a folder, So a list - not equal to any arbitrary path - and c: Although a path, but not a folder.
A performant way with XProfan, to determine, if a directory is empty, could therefore be the examination, if the directory can Delete. CompileMarkSeparation An exception for the root of a drive can be installed as easily, imho is not the task. |
|
|
| |
|
|
|
Jörg Sellmeyer | Delete, to determine, whether it is there? But this is the absolute sledgehammer. |
|
|
| Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 08/26/08 ▲ |
|
|
|
|
| No, whether it is empty. The previous versions require a lot more load, however, these variants are therefore jackhammer. (Then dear Holzhammer... ) |
|
|
| |
|
|
|
Dieter Zornow | |
|
| Er ist ein Mann wie ein Baum. Sie nennen ihn Bonsai., Win 7 32 bit und Win 7 64 bit, mit XProfan X2 | 08/26/08 ▲ |
|
|
|
|
| My version is so cheese because it requires write access and also probably from a release as well as other attributes, Dieter was now just posting the faster I rauskrahmte Api...
Hrm, nevertheless: PathIsDirectoryEmpty |
|
|
| |
|
|