473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Listing directories within a directory

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 23 '05 #1
2 1318
ma***********@gmail.com 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.

Jul 23 '05 #2
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 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paweł Gałecki | last post by:
I used following code to scan & list directory contents (including all subdirectories). It turns out that subdirectories are NOT recognized as directories when the function is called in a recursive...
6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
3
by: dave | last post by:
I am using vs.net 2003 on windows xp. After clicking on a project within my solution and selecting create new folder vs.net responds back with , the "directory already exists". If i look at the...
19
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing =...
3
by: Nathan Young | last post by:
Hello. Perhaps this isn't really a .NET question, but I'm hoping there is an easy solution within .NET/VC++. The problem: I have a directory full of different types of data files and I need...
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
2
by: ngr | last post by:
I used to use the DirListox control in VB6 but this is no longer supported in VB.NET. What I want to do: I want to take a directory listing and show any subdirectories in a list. When you click...
4
by: techusky | last post by:
I have a *very* simple script written that displays the directory listing of the current working directory, but I am having some difficulty when I try to change folders. Basically, I have my $dir...
3
by: kimiraikkonen | last post by:
Hi, I'd like to know whether it is possible to know the sub-directories and also files of a domain, especially domains. Does system.net provides such a function? For example: you only know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.