Jan Slodicka wrote:
> 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.

Uh, well I guess that should have seemed obvious to me, huh?  You know I had
a do-while loop in there at one point and was getting another error (for
reasons I won't now go into)....  Well, suffice it to see I stopped thinking
when in my casting about I put the condition at the top and the other error
went away.

Thanks for pointing out that the emperor has no clothes!

David

> ----- 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.


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

Reply via email to