Thread: Testing if an argument is a directory

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    17

    Testing if an argument is a directory

    How do you test if an argument passed is a directory???

    Expected argument:

    program name, filename, pattern 1, pattern 2

    Thanks

    Signed,

    Chris Beech

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    We need to know more information, for example the OS would be nice.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    17
    Using Red Hat Linux as OS and C as language.

  4. #4
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    man [2] readdir

    The 2 may not be correct for Red Hat, that is where it is in the default for Slackware 10.2.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >How do you test if an argument passed is a directory???
    The stat() function will provide you the required information.

  6. #6
    .
    Join Date
    Nov 2003
    Posts
    307
    Consider using nftw or ftw these functions were meant for this purpose - searching a file tree.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. argument testing
    By Draco in forum C Programming
    Replies: 10
    Last Post: 11-02-2003, 10:42 PM
  5. command line argument to accept entire directory
    By westm2000 in forum C Programming
    Replies: 2
    Last Post: 04-02-2002, 10:12 PM