getting directory information

This is a discussion on getting directory information within the C++ Programming forums, part of the General Programming Boards category; say I have a directory /user with 3 subdirectories /user/code, /user/docs, /user/pics. my program is in /user, how do I ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    10

    getting directory information

    say I have a directory /user with 3 subdirectories /user/code, /user/docs, /user/pics.
    my program is in /user, how do I do it find out 1. how many subdirectories there are and 2. get their names into variables.

    what my program does, it copies a file into every directory of a whole (large) webserver. but it has to output the names of all the directories it put the file in and it has to omit some directories.

    I hope someone understands me and can help!
    thank you!

    N8760

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    You can use the findfirst, findnext functions to walk through a directory and the stat function to check if the file is a directory on not. But I'm not sure if this functions are supported on your system.

    Check the manual pages for more information about this functions.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    10

    findfirst/findnext

    I use linux, but what header files do I need? I just found relatively poor information about findfirst/findnext. It seems to be exactly what I need! Could someone give me an example how to use those functions?
    thanks

  4. #4
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163
    i think dir.h
    +++
    ++
    + Sekti
    ++
    +++

  5. #5
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    - Take a look at the opendir, closedir and readdir functions on this site: UNIX Manual Pages
    - Try searching the board (there are a lot discussions about this topic)

    Cheers, Monster

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Building a tree from a directory structure
    By geekoftheweek in forum C Programming
    Replies: 2
    Last Post: 11-26-2007, 03:15 AM
  2. About current working directory
    By George2 in forum Linux Programming
    Replies: 3
    Last Post: 05-02-2007, 11:34 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 07:27 PM
  5. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21