10-09-2008
2,
0
Join Date: Oct 2008
Last Activity: 12 December 2008, 12:15 AM EST
Location: NJ
Posts: 2
Thanks Given: 0
Thanked 0 Times in 0 Posts
need help in file traversal via FTS(3)
Hi friends,
I was trying to traverse a file using FTS(3) . this is the code below.. but I am getting segmentation error in the line fts_read(...) ,
anybody have any idea , why it is?
Please, help me. Thanks in advance.
-------------------------------------------------------------------------------------------------------
Program:
-------------------------------------------------------------------------------------------------------
FTS *fileStruct;
FTSENT *dirList, *fileInfo;
int ftsResult;
fileStruct = fts_open(&argv[1], FTS_COMFOLLOW, 0);
dirList = fts_children(fileStruct, FTS_NAMEONLY);
do
{
fileInfo = fts_read(dirList->fts_pointer);
fileStruct = fts_open((char * const *)dirList->fts_link->fts_name, FTS_PHYSICAL, (void *)result);
}while (dirList->fts_link != NULL);
ftsResult = fts_close(fileStruct);
-------------------------------------------------------------------------------------------------------
Result of Debugging:
-------------------------------------------------------------------------------------------------------
Starting program: a.out temp
0x0000000000400b78 in main ()
Current language: auto; currently asm
(gdb)
(gdb) n
Single stepping until exit from function main,
which has no line number information.
-- Done with option processing. -- optind is 1
first non-option arg: argv[1] = 'temp'
200810090259
destination directory path : temp/200810090259
checking
fileStruct is not null
Program received signal SIGSEGV, Segmentation fault.
0x00007fc797a4d5c8 in fts_read () from /lib/libc.so.6
(gdb) bt
#0 0x00007fc797a4d5c8 in fts_read () from /lib/libc.so.6
#1 0x0000000000400f4d in main ()
(gdb) Quit
(gdb)
-------------------------------------------------------------------------------------------------------
Last edited by jack85; 10-09-2008 at 05:04 AM..
Reason: updated