@@ -603,9 +603,10 @@ bool TDBMSD::InitFileNames(PGLOBAL g)
603603bool DIRDEF::DefineAM (PGLOBAL g, LPCSTR, int )
604604 {
605605 Desc = Fn = GetStringCatInfo (g, " Filename" , NULL );
606- Incl = (GetIntCatInfo (" Subdir" , 0 ) != 0 );
607- Huge = (GetIntCatInfo (" Huge" , 0 ) != 0 );
608- return false ;
606+ Incl = GetBoolCatInfo (" Subdir" , false );
607+ Huge = GetBoolCatInfo (" Huge" , false );
608+ Nodir = GetBoolCatInfo (" Nodir" , true );
609+ return false ;
609610 } // end of DefineAM
610611
611612/* **********************************************************************/
@@ -654,12 +655,14 @@ void TDBDIR::Init(void)
654655TDBDIR::TDBDIR (PDIRDEF tdp) : TDBASE(tdp)
655656{
656657 To_File = tdp->Fn ;
658+ Nodir = tdp->Nodir ;
657659Init ();
658660} // end of TDBDIR standard constructor
659661
660662TDBDIR::TDBDIR (PSZ fpat) : TDBASE((PTABDEF)NULL)
661663{
662664To_File = fpat;
665+ Nodir = true ;
663666Init ();
664667} // end of TDBDIR constructor
665668
@@ -812,27 +815,32 @@ int TDBDIR::ReadDB(PGLOBAL g)
812815 int rc = RC_OK;
813816
814817#if defined(__WIN__)
815- if (hSearch == INVALID_HANDLE_VALUE) {
816- /* ******************************************************************/
817- /* Start searching files in the target directory. The use of the */
818- /* Path function is required when called from TDBSDR. */
819- /* ******************************************************************/
820- hSearch = FindFirstFile (Path (g), &FileData);
818+ do {
819+ if (hSearch == INVALID_HANDLE_VALUE) {
820+ /* ****************************************************************/
821+ /* Start searching files in the target directory. The use of */
822+ /* the Path function is required when called from TDBSDR. */
823+ /* ****************************************************************/
824+ hSearch = FindFirstFile (Path (g), &FileData);
825+
826+ if (hSearch == INVALID_HANDLE_VALUE) {
827+ rc = RC_EF;
828+ break ;
829+ } else
830+ iFile++;
821831
822- if (hSearch == INVALID_HANDLE_VALUE)
823- rc = RC_EF;
824- else
825- iFile++;
832+ } else {
833+ if (!FindNextFile (hSearch, &FileData)) {
834+ // Restore file name and type pattern
835+ _splitpath (To_File, NULL , NULL , Fname, Ftype);
836+ rc = RC_EF;
837+ break ;
838+ } else
839+ iFile++;
826840
827- } else {
828- if (!FindNextFile (hSearch, &FileData)) {
829- // Restore file name and type pattern
830- _splitpath (To_File, NULL , NULL , Fname, Ftype);
831- rc = RC_EF;
832- } else
833- iFile++;
841+ } // endif hSearch
834842
835- } // endif hSearch
843+ } while (Nodir && FileData. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
836844
837845 if (rc == RC_OK)
838846 _splitpath (FileData.cFileName , NULL , NULL , Fname, Ftype);
@@ -1229,17 +1237,19 @@ int TDBSDR::ReadDB(PGLOBAL g)
12291237 retry:
12301238 do {
12311239 if (Sub->H == INVALID_HANDLE_VALUE) {
1232- _makepath (Fpath, Drive, Direc, " *" , " ." );
1233- Sub->H = FindFirstFile (Fpath, &FileData);
1240+ // _makepath(Fpath, Drive, Direc, "*", "."); why was this made?
1241+ _makepath (Fpath, Drive, Direc, " *" , NULL );
1242+ Sub->H = FindFirstFile (Fpath, &FileData);
12341243 } else if (!FindNextFile (Sub->H , &FileData)) {
12351244 FindClose (Sub->H );
12361245 Sub->H = INVALID_HANDLE_VALUE;
12371246 *FileData.cFileName = ' \0 ' ;
12381247break ;
12391248 } // endif findnext
12401249
1241- } while (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1242- || *FileData.cFileName == ' .' );
1250+ } while (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1251+ (*FileData.cFileName == ' .' &&
1252+ (!FileData.cFileName [1 ] || FileData.cFileName [1 ] == ' .' )));
12431253
12441254 if (Sub->H == INVALID_HANDLE_VALUE) {
12451255 // No more sub-directories. Are we in a sub-directory?
@@ -1293,8 +1303,9 @@ int TDBSDR::ReadDB(PGLOBAL g)
12931303 if (lstat (Fpath, &Fileinfo) < 0 ) {
12941304 sprintf (g->Message , " %s: %s" , Fpath, strerror (errno));
12951305 rc = RC_FX;
1296- } else if (S_ISDIR (Fileinfo.st_mode ) && *Entry->d_name != ' .' ) {
1297- // Look in the name sub-directory
1306+ } else if (S_ISDIR (Fileinfo.st_mode ) && strcmp (Entry->d_name , " ." )
1307+ && strcmp (Entry->d_name , " .." )) {
1308+ // Look in the name sub-directory
12981309 if (!Sub->Next ) {
12991310 PSUBDIR sup;
13001311
0 commit comments