Listing directories within a directory

Discussion in 'C++' started by mattcarpenter@gmail.com, Jul 4, 2005.

  1. Guest

    Heya,

    I'm in need of a way to list the directories inside of a directory
    using C++ and the linux C libraries. I've tried readdir() and
    scandir(), however those return the entire contents of a directory --
    including the files within. I would like just a list of the
    directories. Is there a way to do this without downloading another
    library like boost? Thanks!

    Regards,
    Matt Carpenter
     
    , Jul 4, 2005
    #1
    1. Advertising

  2. Rolf Magnus Guest

    wrote:

    > Heya,
    >
    > I'm in need of a way to list the directories inside of a directory
    > using C++ and the linux C libraries. I've tried readdir() and
    > scandir(), however those return the entire contents of a directory --
    > including the files within. I would like just a list of the
    > directories. Is there a way to do this without downloading another
    > library like boost? Thanks!


    Well, your question is off-topic here. You should better ask it in a linux
    programming newsgroup.
    Having that said, the answer to your question depends on what you want to do
    with the subdirectories. Do you just want to open them again? Then just try
    opendir() on everything you get. If it's not a directory, you'll get
    ENOTDIR back. If you don't want to open them, you can use stat() to test
    whether an entry is a directory or not.
     
    Rolf Magnus, Jul 5, 2005
    #2
    1. Advertising

  3. Guest

    Sorry about posting in the wrong newsgroup, I'll be sure to direct my
    quesiton towards the appropriate one next time. Your suggestion is
    exactly what I needed however. Thanks!

    Regards,
    Matt
     
    , Jul 5, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UkhQVA==?=

    Listing Directories by Creation Date

    =?Utf-8?B?UkhQVA==?=, Aug 30, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,159
    =?Utf-8?B?UkhQVA==?=
    Aug 30, 2005
  2. Jennica Humphrey
    Replies:
    7
    Views:
    3,541
    Evan Carew
    Jan 29, 2004
  3. salvo
    Replies:
    12
    Views:
    4,944
    Ron Natalie
    Feb 2, 2005
  4. Samir Bouzid
    Replies:
    2
    Views:
    713
    Samir Bouzid
    Sep 8, 2009
  5. Adam Petrie
    Replies:
    8
    Views:
    333
    Adam Petrie
    Oct 11, 2004
Loading...

Share This Page