* recursing through directories
@ 2002-04-22 14:48 Francesco Potorti`
2002-04-22 15:06 ` Andreas Schwab
2002-04-22 18:09 ` Paul Eggert
0 siblings, 2 replies; 7+ messages in thread
From: Francesco Potorti` @ 2002-04-22 14:48 UTC (permalink / raw)
I am going to add a new functionality to etags (by popular request).
Until now, when a directory name was given, etags would raise an error.
I want etags to recurse through it and look for source files.
Looking at the libc functions, I think that scandir is the most useful
for this job. Is it standard enough? The man page says it is
conformant to bsd4.3, so I should have no problems. The fact is that
the etags source is very conservative about systems compatibility.
Does anyone have a snippet of code as an example of usage? Not really
necessary, but it could help.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: recursing through directories
2002-04-22 14:48 recursing through directories Francesco Potorti`
@ 2002-04-22 15:06 ` Andreas Schwab
2002-04-22 18:09 ` Paul Eggert
1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2002-04-22 15:06 UTC (permalink / raw)
Cc: Emacs developers
Francesco Potorti` <pot@gnu.org> writes:
|> I am going to add a new functionality to etags (by popular request).
|>
|> Until now, when a directory name was given, etags would raise an error.
|> I want etags to recurse through it and look for source files.
|>
|> Looking at the libc functions, I think that scandir is the most useful
|> for this job. Is it standard enough? The man page says it is
|> conformant to bsd4.3, so I should have no problems. The fact is that
|> the etags source is very conservative about systems compatibility.
Maybe ftw would be better, since it's POSIX (scandir isn't).
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: recursing through directories
2002-04-22 14:48 recursing through directories Francesco Potorti`
2002-04-22 15:06 ` Andreas Schwab
@ 2002-04-22 18:09 ` Paul Eggert
2002-04-22 18:31 ` Eli Zaretskii
2002-04-23 9:45 ` Francesco Potorti`
1 sibling, 2 replies; 7+ messages in thread
From: Paul Eggert @ 2002-04-22 18:09 UTC (permalink / raw)
Cc: emacs-devel
> From: Francesco Potorti` <pot@gnu.org>
> Date: Mon, 22 Apr 2002 16:48:32 +0200
>
> Looking at the libc functions, I think that scandir is the most useful
> for this job. Is it standard enough?
Not really, unfortunately. ftw is standard, but it's a portability
hassle too. In practice, there are real problems in running out of
file descriptors when descending into deeply nested directories.
You might try taking a look at lib/savedir.[ch] from the GNU core
utilities, written by David MacKenzie.
<ftp://alpha.gnu.org/gnu/fetish/fileutils-4.1.8.tar.gz>
It's what I use in GNU tar. Here's a precis:
char *name_space = savedir (dir);
if (! name_space)
report_error (errno, dir);
else
{
char *base;
for (base = name_space; *base; base += strlen (base) + 1)
operate_on (string_concat (dir, "/", base));
free (name_space);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: recursing through directories
2002-04-22 18:09 ` Paul Eggert
@ 2002-04-22 18:31 ` Eli Zaretskii
2002-04-23 9:45 ` Francesco Potorti`
1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2002-04-22 18:31 UTC (permalink / raw)
Cc: pot, emacs-devel
> From: Paul Eggert <eggert@twinsun.com>
> Date: Mon, 22 Apr 2002 11:09:30 -0700 (PDT)
>
> > Looking at the libc functions, I think that scandir is the most useful
> > for this job. Is it standard enough?
>
> Not really, unfortunately. ftw is standard, but it's a portability
> hassle too.
I agree with Paul. I think it is best for etags to have code that
uses more portable functions such as opendir/readdir. I suspect that
even ftw is absent on some platforms like Windows (DJGPP does have it,
though).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: recursing through directories
2002-04-22 18:09 ` Paul Eggert
2002-04-22 18:31 ` Eli Zaretskii
@ 2002-04-23 9:45 ` Francesco Potorti`
2002-04-23 23:56 ` Paul Eggert
1 sibling, 1 reply; 7+ messages in thread
From: Francesco Potorti` @ 2002-04-23 9:45 UTC (permalink / raw)
Cc: emacs-devel
Not really, unfortunately. ftw is standard, but it's a portability
hassle too. In practice, there are real problems in running out of
file descriptors when descending into deeply nested directories.
Do you mean that there is an open file descriptor per directory level?
You might try taking a look at lib/savedir.[ch] from the GNU core
utilities, written by David MacKenzie.
I'll do that. Thanks to all for your advice.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: recursing through directories
2002-04-23 9:45 ` Francesco Potorti`
@ 2002-04-23 23:56 ` Paul Eggert
2002-04-24 1:11 ` Thien-Thi Nguyen
0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2002-04-23 23:56 UTC (permalink / raw)
Cc: emacs-devel
> From: Francesco Potorti` <pot@gnu.org>
> CC: emacs-devel@gnu.org
> Organization:
> Date: Tue, 23 Apr 2002 11:45:16 +0200
>
> Not really, unfortunately. ftw is standard, but it's a portability
> hassle too. In practice, there are real problems in running out of
> file descriptors when descending into deeply nested directories.
>
> Do you mean that there is an open file descriptor per directory level?
In some implementations, yes, I think so.
It's a tricky area. If you use an open file descriptor per directory,
you can always get back to where you came from. If not, then you can
run into other problems.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: recursing through directories
2002-04-23 23:56 ` Paul Eggert
@ 2002-04-24 1:11 ` Thien-Thi Nguyen
0 siblings, 0 replies; 7+ messages in thread
From: Thien-Thi Nguyen @ 2002-04-24 1:11 UTC (permalink / raw)
Cc: pot, emacs-devel
Paul Eggert <eggert@twinsun.com> writes:
It's a tricky area. If you use an open file descriptor per
directory, you can always get back to where you came from. If not,
then you can run into other problems.
perhaps restricting ftw usage to "depth" mode would help. in that case,
only a parent chain of directory descriptors is needed, i would think,
and so a smart implementation could make do w/ O(filesytstem-depth) fds
(for directories).
thi
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-04-24 1:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-22 14:48 recursing through directories Francesco Potorti`
2002-04-22 15:06 ` Andreas Schwab
2002-04-22 18:09 ` Paul Eggert
2002-04-22 18:31 ` Eli Zaretskii
2002-04-23 9:45 ` Francesco Potorti`
2002-04-23 23:56 ` Paul Eggert
2002-04-24 1:11 ` Thien-Thi Nguyen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.