* ftw , nftw doesn't work
@ 2007-04-25 12:45 Nikola
2007-04-25 13:16 ` Stephen Kratzer
2007-04-25 14:05 ` leslie.polzer
0 siblings, 2 replies; 4+ messages in thread
From: Nikola @ 2007-04-25 12:45 UTC (permalink / raw)
To: linux-c-programming
Hi,
I am trying to parse dir tree with ftw and nftw on Linux (debian) but
without result.
------------------------------------------------------
#include <stdio.h>
#include <ftw.h>
int fn(const char *file, const struct stat *sb, int flag){
printf("-->\n");
}
int main(int argc,char **argv){
ftw("/etc/", fn, 5);
return 0;
}
------------------------------------------------------
bash# gcc test.c
bash# ./a.out
-->
bash#
------------------------------------------------------
Does anyone knows what might be the problem.
tnx in advance.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ftw , nftw doesn't work
2007-04-25 12:45 ftw , nftw doesn't work Nikola
@ 2007-04-25 13:16 ` Stephen Kratzer
2007-04-25 13:43 ` Benoit Fouet
2007-04-25 14:05 ` leslie.polzer
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Kratzer @ 2007-04-25 13:16 UTC (permalink / raw)
To: Nikola; +Cc: linux-c-programming
On Wednesday 25 April 2007 08:45:27 Nikola wrote:
> Hi,
>
> I am trying to parse dir tree with ftw and nftw on Linux (debian) but
> without result.
>
> ------------------------------------------------------
>
> #include <stdio.h>
> #include <ftw.h>
>
>
> int fn(const char *file, const struct stat *sb, int flag){
>
> printf("-->\n");
> }
>
>
> int main(int argc,char **argv){
>
>
> ftw("/etc/", fn, 5);
>
> return 0;
> }
>
> ------------------------------------------------------
>
> bash# gcc test.c
> bash# ./a.out
> -->
> bash#
>
> ------------------------------------------------------
>
> Does anyone knows what might be the problem.
>
> tnx in advance.
>
The return value of fn should be 0 if you want the walk to continue past the
first file or directory.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ftw , nftw doesn't work
2007-04-25 13:16 ` Stephen Kratzer
@ 2007-04-25 13:43 ` Benoit Fouet
0 siblings, 0 replies; 4+ messages in thread
From: Benoit Fouet @ 2007-04-25 13:43 UTC (permalink / raw)
To: kratzers; +Cc: Nikola, linux-c-programming
Stephen Kratzer wrote:
> On Wednesday 25 April 2007 08:45:27 Nikola wrote:
>
>> Hi,
>>
>> I am trying to parse dir tree with ftw and nftw on Linux (debian) but
>> without result.
>>
>> ------------------------------------------------------
>>
>> #include <stdio.h>
>> #include <ftw.h>
>>
>>
>> int fn(const char *file, const struct stat *sb, int flag){
>>
>> printf("-->\n");
>> }
>>
>>
>> int main(int argc,char **argv){
>>
>>
>> ftw("/etc/", fn, 5);
>>
>> return 0;
>> }
>>
>> ------------------------------------------------------
>>
>> bash# gcc test.c
>> bash# ./a.out
>> -->
>> bash#
>>
>> ------------------------------------------------------
>>
>> Does anyone knows what might be the problem.
>>
>> tnx in advance.
>>
>>
>
> The return value of fn should be 0 if you want the walk to continue past the
> first file or directory.
>
and compiling with warning outputs could have helped, too :)
$ gcc -Wall test.c
surely leads to a "control reaches end of a non void function" or
something similar...
Ben
--
Purple Labs S.A.
www.purplelabs.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ftw , nftw doesn't work
2007-04-25 12:45 ftw , nftw doesn't work Nikola
2007-04-25 13:16 ` Stephen Kratzer
@ 2007-04-25 14:05 ` leslie.polzer
1 sibling, 0 replies; 4+ messages in thread
From: leslie.polzer @ 2007-04-25 14:05 UTC (permalink / raw)
To: Nikola; +Cc: linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]
On Wed, Apr 25, 2007 at 02:45:27PM +0200, Nikola wrote:
> int fn(const char *file, const struct stat *sb, int flag){
>
> printf("-->\n"); }
You don't actually print the file name here.
Leslie
--
NEW homepage: https://viridian.dnsalias.net/~sky/homepage/
gpg --keyserver pgp.mit.edu --recv-keys DD4EBF83
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-25 14:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-25 12:45 ftw , nftw doesn't work Nikola
2007-04-25 13:16 ` Stephen Kratzer
2007-04-25 13:43 ` Benoit Fouet
2007-04-25 14:05 ` leslie.polzer
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).