delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/04/12:18:39

From: myknees AT aol DOT com (Myknees)
Newsgroups: comp.os.msdos.djgpp
Subject: findfirst attrib parameter -- I must be missing something
Date: 4 Apr 1998 17:13:07 GMT
Lines: 37
Message-ID: <1998040417130700.MAA06105@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
References: <35256D08 DOT 5B85 AT cs DOT com>
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have this sickening feeling that I am missing something really obvious.  I
have done the normal things--mail archives, FAQ, docs, sources, fiddling--but I
still don't understand why this doesn't work.

I'm trying to list only subdirectories.  Here's the little test program:
#include	<stdio.h>
#include	<dir.h>

void show_dirs(char *files)
{
    /* this is only slightly modified from the docs */
    struct ffblk f;
    int done = findfirst(files, &f, FA_DIREC);
    while (!done)
    {
      printf("%10u\t%20s\n",
                   /* show attrib for debugging. 16 corresponds to a subdir. */
	     f.ff_attrib,
	     f.ff_name);
      done = findnext(&f);
    }
    putchar('\n');
    
    return;
}

int main(void)
{
    show_dirs("*");
    return 0;
}

It looks like it should find and show subdirectories, but it shows all the
files, including the ones whose ff_attrib != FA_DIREC.  Confusion.  One weird
thing is that using -1 as the attrib makes the program not output anything.

--Ed (Myknees)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019