Date: Thu, 29 Jul 1999 11:06:01 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: "Cesar S. Rabak" 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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"?