From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux-c-programming@vger.kernel.org, linux-assembly@vger.kernel.org
Subject: Re: Directory contents
Date: Mon, 29 Nov 2004 08:57:04 +0100 [thread overview]
Message-ID: <20041129075704.GN14719@lug-owl.de> (raw)
In-Reply-To: <41AACEDD.4080509@codito.com>
[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]
On Mon, 2004-11-29 12:55:17 +0530, sandeep <sandeep@codito.com>
wrote in message <41AACEDD.4080509@codito.com>:
> >I want to write a function that can read the contents of a specified
> >directory
> >in order to find a certain type of file or to copy a directory-tree or
> >something else.
> >Neverthless I need of some system functions that find the files that are
> >contained in that directory (like FINDFIRST and FINDNEXT under ms-dos).
> >
> >Who can help me?
> "man scandir" and man on functions mentioned at the end of that manpage.
From the man page:
----------------------------- >8 ======================================
CONFORMING TO
None of these functions is in POSIX. LSB has deprecated the library
call alphasort() and never contained scandir().
The functions scandir() and alphasort() are from BSD 4.3, and have been
available under Linux since libc4. Libc4 and libc5 use the more pre-
cise prototype
int alphasort(const struct dirent **a, const struct dirent **b);
but glibc 2.0 returns to the imprecise BSD prototype.
The function versionsort() is a GNU extension, available since glibc
2.1. Since glibc 2.1, alphasort() calls strcoll(3); earlier it used
strcmp(3).
============================================ 8< -----------------------
So I guess you don't really want to use these functions. opendir(),
readdir() and closedir() are what's ment for that. If you're actually
writing an libc replacement (and thus need to use the syscall interface
instead of the libc interface), you can use open(..., ... | O_DIRECTORY)
in conjunction with getdents().
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2004-11-29 7:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-27 18:00 Directory contents HIToC
2004-11-27 18:26 ` SVisor
2004-11-27 22:38 ` Emmet Ford
2004-11-29 4:13 ` Brian Raiter
2004-11-29 7:25 ` sandeep
2004-11-29 7:57 ` Jan-Benedict Glaw [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041129075704.GN14719@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=linux-assembly@vger.kernel.org \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).