On Feb 25, 2007, at 6:28 PM, Andy Dent wrote:

> Whilst the Count downto 1 idiom is faster for things like skimming
> through arrays, in this case isn't it a bit unsafe if the size of the
> directory changes through other means whilst you are deleting?
>
> How much slower is 1 to Count for directories?

The "Count DownTo 1" idiom is used not because of speed but because  
this is a routine to delete files. If you go the other direction,  
starting with 1 and going to Count, you will find that when you are  
done you have deleted only half of the files. Think about it, when  
you delete the first file, all the remaining files shift down such  
that when you now reference 2 in your loop you will actually end up  
with what was originally the third file and so the original second  
file is not deleted etc. etc.

As to your question about the possibility of other processes making  
changes to this same directory it depends on the directory I would  
guess. If it is some directory used only by the program that is  
running the file deletion routine I doubt if you need to worry about  
this. If it is some directory shared by many processes it could  
possibly be a problem, for several reasons.



=== A Mac addict in Tennessee ===

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to