TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Phil Crown
from: jari laaksonen
date: 1995-12-14 21:40:48
subject: PFILEFINDBUF3

PC> Can anyone tell me why this does not work?  It will print the first
PC> file found, but nothing else.  The problems seem to be in getting a
PC> pointer to the next oNextEntryOffset;

Here is a corrected version. Changed lines are marked as /*JJL*/

#define INCL_DOS
#include 
#include 
#include 
#include 

#define FILES_TO_GET       100    // Nbr of files to search for at a time
#define FF_BUFFSIZE        (sizeof( FILEFINDBUF3 ) * FILES_TO_GET)

VOID ProcessDirectory   (PSZ szDirBase, PSZ szDirectory);

// -+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---

VOID ProcessDirectory(PSZ szDirBase, PSZ szDirectory)
{
  PFILEFINDBUF3     pffb          = malloc( FF_BUFFSIZE );
  char             *pff;                                  /*JJL*/
  PSZ               szFileSpec    = malloc( CCHMAXPATH + 1 );
  INT               i;

  if( pffb && szFileSpec ) {
     HDIR        hdir        = HDIR_SYSTEM;
     ULONG       ulMaxFiles  = FILES_TO_GET;
     PCH         pchEndPath;
     APIRET      rc;

     (void) strcpy( szFileSpec, szDirBase );

     if( szDirectory ) {
       (void) strcat( szFileSpec, "\\" );
       (void) strcat( szFileSpec, szDirectory );
     }

     pchEndPath = szFileSpec + strlen( szFileSpec );
     (void) strcat( szFileSpec, "\\*.*" );

     rc = DosFindFirst( szFileSpec, &hdir, FILE_NORMAL | FILE_DIRECTORY,
                        pffb, FF_BUFFSIZE, &ulMaxFiles, FIL_STANDARD );
     *pchEndPath = 0;

     while( !rc ) {
       pff = (char *) pffb;                                /*JJL*/
       for(i = 0; i < ulMaxFiles; i++) {
         printf("%s\n", pffb->achName);                    /*JJL*/
         pff += pffb->oNextEntryOffset;                    /*JJL*/
         pffb = (FILEFINDBUF3 *) pff;                      /*JJL*/ /* + */
       }
       ulMaxFiles  = FILES_TO_GET;                         /*JJL*/ /* + */
       rc = DosFindNext( hdir, pffb, FF_BUFFSIZE, &ulMaxFiles );
     }
     DosFindClose( hdir );
     DosSleep( 5 );
   }
   if( pffb )
     free( pffb );
   if( szFileSpec )
     free( szFileSpec );
}

        // Albert  (Team OS/2)         email: jla{at}to.icl.fi

--- GoldED/2 2.50
* Origin: Finland, Ice Hockey World Champion '95 (2:221/360.20)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 517 628 713/888 800/1 7877/2809
@PATH: 221/360 0 220/841 201/2104 109/347 716 13/25 396/1 270/101 712/515
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.