473,657 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling directories with C++

Dear all,

Despite a good few hours of googling, I have been unable to find out
what the standard C++ libraries are for handling directories and getting
a list of the files inside them.

I am using the mingw c++ compiler on a windows machine to write a
console application. system("mkdir blah") calls aren't what I need
because I need return values to check for things going wrong.

It's the sort of thing that's easy if you know the answer, but
impossible if you don't...

Thanks,

Jamie

Jul 22 '05 #1
3 1869
Jamie Vicary wrote:
Dear all,

Despite a good few hours of googling, I have been unable to find out
what the standard C++ libraries are for handling directories and
getting a list of the files inside them.
C++ only has one standard library, and that doesn't provide any
functionality for directory handling.
I am using the mingw c++ compiler on a windows machine to write a
console application. system("mkdir blah") calls aren't what I need
because I need return values to check for things going wrong.

It's the sort of thing that's easy if you know the answer, but
impossible if you don't...


You have to use system-specific functions, or maybe boost helps.

Jul 22 '05 #2
Jamie Vicary posted:
Dear all,

Despite a good few hours of googling, I have been unable to find out what the standard C++ libraries are for handling directories and getting a list of the files inside them.

I am using the mingw c++ compiler on a windows machine to write a console application. system("mkdir blah") calls aren't what I need because I need return values to check for things going wrong.
It's the sort of thing that's easy if you know the answer, but impossible if you don't...

Thanks,

Jamie


On Windows:

FindFirstFileEx
FindNextFileEx
FindClose
-JKop
Jul 22 '05 #3

"Jamie Vicary" <Xj************ @Xmansf.Xox.Xac .Xuk> wrote in message
news:cf******** **@uns-a.ucl.ac.uk...
Dear all,

Despite a good few hours of googling, I have been unable to find out
what the standard C++ libraries are for handling directories and getting
a list of the files inside them.

I am using the mingw c++ compiler on a windows machine to write a
console application. system("mkdir blah") calls aren't what I need
because I need return values to check for things going wrong.

It's the sort of thing that's easy if you know the answer, but
impossible if you don't...

See http://www.boost.org/libs/filesystem/doc/index.htm for a portable, and
IMHO, the best solution.

Jeff F
Jul 22 '05 #4

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

Similar topics

6
4819
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 Authentication set up and it worked just fine. Then I realized that I needed to have some pages unsecure. I then created 2 directories. One named Secure and the other named Public. I placed my web.config file in my
1
1547
by: Heath | last post by:
I'm dealing with a C# application that monitors changes to the file system, and need to exclude irrelevent directories, temp directories for example. Is there any way to identify such directories, perhaps through DirectoryInfo or something similar that might give some attribute that temp, system, hidden, etc directories might be tagged with? I wanted to write this code to check and ignore such directories dynamically based on...
2
4221
by: Jeffry van de Vuurst | last post by:
Hi, (sorry for the crosspost, I wasn't sure which was the best place to put this). I was just thinking about something and wondered if any of you has some ideas about this. I'm using the NetAdvantage component suite from Infragistics for my web applications. When installing they create several virtual
4
4221
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not the 2 of them together. This is what I tried: Sub Page_Load(.....) Dim dInfo As DirectoryInfo dInfo = New DirectoryInfo(Server.MapPath(MyDir))
1
1680
by: rn5a | last post by:
A ListBox lists all the folders & files existing in a directory named 'MyDir' on the server. Assume that the ListBox lists 2 directories - 'Dir1' & 'Dir2' i.e. these 2 directories reside in the 'MyDir' directory. Both 'Dir1' & 'Dir2' also house sub-directories & files. Assume that the sub-directory 'Dir1' has 3 directories & 3 files. When a user comes to a ASPX page for the first time, the ListBox lists all the directories & files...
6
17009
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project as "Additional Dependencies" under Linker-Input options. Since those libraries are also in different directory, I specified that library path in project as "Additional Library Directories" under Linker-General options. This is where I see some...
3
1096
by: WAP | last post by:
Hi all, I am struggling to do things such as create directories and run a check to see if certain files are in these directories. What is the procedure in order to add this functionality to my program. Please excuse me i'm very new at VB. Thank you.
4
1882
by: Edwin Velez | last post by:
http://msdn.microsoft.com/en-us/library/806sc8c5.aspx The URL above gives sample code for use within a Console Application. What I would like to do is use this code within a Windows Form. That part is easy. The part that I am having trouble with is using the code in a form and having a Label's Text property update as a new directory or file is found. What I keep getting is the work being done before it is shown to the user via the...
5
14315
by: kellygreer1 | last post by:
I think I'm not quite understanding something about error handling in PHP5. I have written some PHP code to index the contents of C drive on a Windows machine. When it gets to certain special folders (fake folders) it runs into errors. Directories it can not read from. I have tried wrapping the code in a Try / Catch and the error still comes through. What am I missing? <?php // Here is the code: function indexFiles($path, $handle) {
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.