delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/29/19:49:25

Date: Thu, 29 Jul 1999 11:06:01 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Cesar S. Rabak" <csrabak AT ipt DOT br>
cc: djgpp AT delorie DOT com
Subject: Re: getting all filename in sub-directory
In-Reply-To: <3.0.6.32.19990728155751.00859240@dce03.ipt.br>
Message-ID: <Pine.SUN.3.91.990729110549.25908K-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 28 Jul 1999, Cesar S. Rabak wrote:

> >> About your system() command, you could do it as
> >> 
> >> char show_files[] = "dir *.exe /s > exe_files.txt";
> >> system(show_files);
> >
> >Or, even better:
> >
> >	FILE *fp = popen ("dir *.exe /s", "rt");
> >	fread (fp, ...);
> >
> Eli, but in this case the popen would prefer to use the "dir.exe" in
> DJGPP/BIN, wouldn't?

Yes, it would; but so would `system'.  They both do the same, so the
above two commands will work (or fail ;-) in the same way.

> If so, it will not honor the /s switch, but write in fp, something like "No
> /s: no such file or directory (ENOENT).

This is correct.  I cannot imagine why would anyone want to launch a
child program just to list a directory anyway, but here you are, take 2:

	FILE *fp = popen ("command.com /c dir *.exe /s", "rt");
	fread (fp, ...);

An excercise that is left to the interested reader: why did I say
"command.com" and not simply "command"?

- Raw text -


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