On Mar 31, 2005, at 10:56 AM, syounker at bco dot com wrote:
Here is the basic loop of my code which creates an array of all the
files on
a particular volume. I store the absolute path and the total size of
the
file.
Well, I'm not seeing anything offhand that looks concerning. It looks
like it should work, as long as you don't end up with the recursion
causing a stack overflow (which would happen only with *extremely*
deeply nested hierarchies that are rather unlikely in the real world,
IMHO).
Question: based on what do you say you're missing files? Are you
examining the array in the debugger, or just looking at some final
display later on in your program? In other words, is it possible this
is not where the error is occurring? Might the code that generates the
list you're looking at be at fault?
Also, I notice you're combining both AbsolutePath and file size in the
same array. If the sole purpose of this information is user display,
that's fine, but if you later are pulling the path back out and doing
something with it, you may want to consider breaking this up into two
arrays, one containing FolderItems and the other containing integers.
In other words, you may want to consider changing this:
ComparisonFileArray.append
theFolder.item(loopCounter).absolutePath + chr(9) +
str(theFolder.item(LoopCounter).Length +
theFolder.item(LoopCounter).ResourceForkLength)
to this:
ComparisonFiles.Append theFolder.item(loopCounter)
ComparisonFileSizes.Append theFolder.item(loopCounter).Length +
theFolder.item(loopCounter).ResourceForkLength
That way, you've still got the original FolderItem when you need it
later. Of course, you can't save a FolderItem to disk as-is, so if
that's the ultimate goal of this array, you may want to look into the
FolderItem.GetSaveInfo function as a replacement for AbsolutePath.
Also, your repeated use of theFolder.item(loopCounter) is not only
cumbersome reading, it is inefficient. You're calling a function each
time you do this, and in a long loop like this, that can significantly
slow your app. Instead, call it once, cache the result in a local
variable, and use that variable for the remainder of that loop
iteration.
-Thomas
Personal web page:
<http://homepage.mac.com/thomasareed/>
My shareware:
<http://www.bitjuggler.com/>
Free REALbasic code:
<http://www.bitjuggler.com/extra/>
There are 10 kinds of people in the world -- those who understand binary
numbers and those who don't.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|