ftw , nftw doesn't work
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.
Quoted 32 lines · 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#
Quoted 6 lines
------------------------------------------------------
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.
Quoted 36 lines · Stephen Kratzer
Quoted 34 lines · 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#------------------------------------------------------
Quoted 9 lines
Quoted 5 lines
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
Signature · 2 lines
Purple Labs S.A. www.purplelabs.com
Quoted 3 lines · Nikola
int
fn(const char *file, const struct stat *sb, int flag){printf("-->\n"); }
You don't actually print the file name here.
Leslie
Signature · 2 lines
NEW homepage: https://viridian.dnsalias.net/~sky/homepage/ gpg --keyserver pgp.mit.edu --recv-keys DD4EBF83