Hello David

You really ignore the last file.
For the last file VFSDirEntryEnumerate() returns 0 (no error) and sets
iterator to vfsIteratorStop. Instead of processing that file you terminate
the loop.

Jan Slodicka


----- Original Message -----
From: "David Beers" <[EMAIL PROTECTED]>


> I'm trying out VFS for the first time and having a little trouble
iterating
> through files in a volume.  Using code such as the following (and also
code
> that opens and reads files) I always find that the last file created in
> external memory is missed.  So, in the case of the snippet below, the
count
> is always 1 less than the number of files and in the case where I'm
opening
> files and performing operations on them the one most recently created is
> unavailable.  Probably something I don't understand about how the iterator
> works?
>
> FWIW, these are .wav files created by the Sony Voice Recorder application,
> which my application starts and stops using virtual button presses on the
> hardware Record button.  The file that is being missed in this loop shows
up
> in the list of files in the Voice Recorder application before my app
> terminates it. And it can be seen by browsing the directory right after
it's
> created.
>
>    error = VFSFileOpen(gVolRefNum, dirPathStr, vfsModeReadWrite, &dirRef);
>    if (!error) {
>     // initializations
>     counter = 0;
>     dirEntryIterator = vfsIteratorStart;
>     info.nameP = nameInit;
>     info.nameBufLen = 25;
>
>     // enumerate the volume
>     error = VFSDirEntryEnumerate(dirRef, &dirEntryIterator, &info);
>     if (!error) {
>      // count the files in the volume
>      while (dirEntryIterator != vfsIteratorStop){
>       counter++;
>       error = VFSDirEntryEnumerate(dirRef, &dirEntryIterator, &info);
>       if (error) ErrAlert(error);
>      }
>     } else {
>      ErrAlert(error);
>     }
>    } else {
>     ErrAlert(error);
>    }
>    VFSFileClose(dirRef);
>
> TIA for any help you folks can provide.
>
> David
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to