From: Luciano Moreira - igLnx <lucianolnx@ig.com.br>
To: "Alphex K." <alphex@crew.org.ru>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Implementing a file counter (like "ls | wc")
Date: Wed, 07 Apr 2004 11:47:42 -0300 [thread overview]
Message-ID: <4074148E.9060205@ig.com.br> (raw)
In-Reply-To: <20040407183558.77510679.alphex@crew.org.ru>
-------------- THE CODE HAVE THIS STRUCTURE:
while ((pFile=readdir(pDir))!=NULL) {
sprintf(szBuf, "%s/%s", pPath, pFile->d_name);
stat(szBuf, &statFile);
if (S_ISDIR(statFile.st_mode)) /// LOOK THAT: We don't use
recursive searching, we count only files at current directory excluding
others directories.
continue;
/* Filtering */
if (nNeedFilter) {
//// I DONT HAVE THE CODE OF FILTERING NOW
//// BUT I CAN SEND IT LATER IF NECESSARY
}
}
-------------- CODE FINISH HERE
Does have another mechanism to filter without using of strcmp() /
memcmp() ? How if we dont know the size of extension (.c, .cpp, .teste,
.longextension, and so on). ?
Luciano
Alphex K. wrote:
>On Wed, 07 Apr 2004 11:27:02 -0300
>Luciano Moreira - igLnx <lucianolnx@ig.com.br> wrote:
>
>
>
>>We implemented a program that use "opendir()", "readdir()", and
>>"closedir()" to scan a directory and count the files contained into it.
>>
>>
>How U use this functions?
>But I'm think that it's not good method
>
>
>>But, it program have taking more time than "ls | wc" to count files.
>>
>>Does have any other way to count files faster?
>>
>>PS: Our program needs sometime to filter files by extension (like: *.c,
>>*.cpp, and so on. Thus we use strcmp() to compare last letters of both
>>strings).
>>
>>
>If U want a more speed don't use strcmp or strncmp functions.
>
>
>>Luciano
>>
>>
>>
>U use a C++ ? or C ?
>
>
>>-
>>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>>the body of a message to majordomo@vger.kernel.org
>>More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>>
>
>
>---===---
>Alphex Kaanoken
>Senior developer of Crew IT research labs
>web: http://crew.org.ru
>mailto:Alphex@Crew.Org.RU
>
>
>---===---
>Alphex Kaanoken
>Senior developer of Crew IT research labs
>web: http://crew.org.ru
>mailto:Alphex@Crew.Org.RU
>
>
>
>
next prev parent reply other threads:[~2004-04-07 14:47 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 [this message]
2004-04-07 15:34 ` Holger Kiehl
2004-04-13 12:52 ` Steven Smith
-- 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=4074148E.9060205@ig.com.br \
--to=lucianolnx@ig.com.br \
--cc=alphex@crew.org.ru \
--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).