Thread: recursive directory listing help

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    4

    recursive directory listing help

    i am trying to design and write a C program that carries out a recursive directory listing, functionally similar to the Unix "ls -lR". This C program will use at least the following system calls, opendir, chdir, readdir, and stat.

    A fairly crude version of doing this would be

    Code:
    	file recls in your home directory contains:
    		for I in * do
    			print $I
    			if test -d $I
    				cd $I
    				sh $HOME/recls
    				cd ..
    			fi
    		done
    but i am looking to do this in a more complex way, any help would be greatly recieved

    thanks

    laney

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Can we assume by context that you want to do this on a Linux / Unix machine?

    How about
    http://faq.cprogramming.com/cgi-bin/...&id=1044780608

    Or maybe using the ftw() function.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    4
    Yeah on a unix machine, ill look at that see if i can make any sense of it thank you, im a newbie but thanks for the help

    laney

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  2. PLEASE HELP ME!!! Recursive directory listing
    By laney69er in forum C Programming
    Replies: 1
    Last Post: 03-15-2006, 07:08 AM
  3. Improvements on Recursive Directory Listing
    By laney69er in forum C Programming
    Replies: 1
    Last Post: 03-15-2006, 01:39 AM
  4. Trying to write a recursive directory listing
    By crazeinc in forum C Programming
    Replies: 4
    Last Post: 04-28-2005, 12:35 AM
  5. Directory listing
    By brif in forum C++ Programming
    Replies: 1
    Last Post: 10-10-2002, 06:44 AM