From: "Steven Smith" <sos22@cam.ac.uk>
To: Luciano Moreira - igLnx <lucianolnx@ig.com.br>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Implementing a file counter (like "ls | wc")
Date: Tue, 13 Apr 2004 13:52:58 +0100 [thread overview]
Message-ID: <20040413125258.GA2565@archibold.chu.cam.ac.uk> (raw)
In-Reply-To: <4074148E.9060205@ig.com.br>
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
> while ((pFile=readdir(pDir))!=NULL) {
> sprintf(szBuf, "%s/%s", pPath, pFile->d_name);
> stat(szBuf, &statFile);
> if (S_ISDIR(statFile.st_mode))
> continue;
If the only reason you're statting the files is to check whether
they're directories, then you can save yourself a system call per
file:
while ((pFile=readdir(pDir))!=NULL) {
if (pFile->d_type == DT_DIR)
continue;
This'll probably be quite a bit quicker, and may also save you needing
to call sprintf(), which can be somewhat expensive.
Steven Smith.
[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]
next prev parent reply other threads:[~2004-04-13 12:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-07 14:35 Implementing a file counter (like "ls | wc") Alphex K.
2004-04-07 14:47 ` Luciano Moreira - igLnx
2004-04-07 15:34 ` Holger Kiehl
2004-04-13 12:52 ` Steven Smith [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-04-07 14:27 Luciano Moreira - igLnx
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=20040413125258.GA2565@archibold.chu.cam.ac.uk \
--to=sos22@cam.ac.uk \
--cc=linux-c-programming@vger.kernel.org \
--cc=lucianolnx@ig.com.br \
/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).