realbasic-nug
[Top] [All Lists]

Re: Delete folder not empty

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Delete folder not empty
From: Norman Palardy <npalardy at zymetacorp dot com>
Date: Sun, 30 Mar 2003 13:09:06 -0700

On Sunday, March 30, 2003, at 06:19  AM, Richard Altenburg wrote:

On 30-03-2003 02:43, "Thomas Tempelmann" <listuser at tempel dot org> wrote:

       for i = f.count downto 1
           deleteAnything(f.trueitem(i))
       next

This is also a bad idea:

Some disks (file systems) may not be able to report the
correct file count (might be true for FAT, and even
UFS), so they'd either return a too high or too low
number.

The only safe way is to count up, starting at 1,
and check if a delete failed, thus increasing the
number by one, until one gets to a nil folderitem,
which means you're at the end of the list.

I believe that I read, somewhere, that counting up from 1 can cause the
Windows-version of our idea to crash. It should be from the higher count donwto 1 for them. But cannot confirm it anymore and don't know where I read
it too. Maybe Matt is going to tell us...

If you count UP like this you should get rid of item 1 all the time

If you dont you will only get rid of half the items
The reason is that once you delete item 1& bump the counter up to 2, item 2 has become item 1 (you deleted item 1 right ?) and so you are now in fact getting rid of what was item 3 when you started out. This will continue each time you do this so you will really get rid of items 1,3,5,7, etc

If you count DOWN from count to 1 you will not have this issue


---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe:
<mailto:realbasic-nug-off at lists dot realsoftware dot com>

Subscribe to the digest: <mailto:realbasic-nug-digest at lists dot realsoftware dot com>
.


<Prev in Thread] Current Thread [Next in Thread>