472,954 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

C++/CLI and Boost.Filesystem

Has anyone tried to use Boost.Filesystem with C++/CLI? I'm trying to
get some code that worked correctly in my native application to work on
my C++/CLI program. The code is in a header file in a native C++ static
library.

inline void execute_files(std::string const& dir, std::string
const& match, bool recursive = true, lua_State* interpreter = 0)
{
namespace bfs = boost::filesystem;

bfs::path dirpath(dir); // (1)

if (!bfs::exists(dirpath)) return;
if (!interpreter) interpreter = lua_interpreter();

bfs::directory_iterator end_itr;
for (bfs::directory_iterator itr(dirpath); itr != end_itr;
++itr)
{
if (!bfs::is_directory(*itr))
{
if (itr->leaf().find(match) != std::string::npos)
execute_file(itr->string());
}
else if (recursive)
{
execute_files(itr->string(), match, recursive,
interpreter);
}
}
}

The problem I'm having happens in the constructor of bfs::path (namely
line (1)) at the first recursive call. An exception is thrown which I
can't seem to get a helpful message from. It seems the string returned
from itr->string() is invalid. Has anyone tried to use Boost.Filesystem
in C++/CLI before? Any ideas on what could be causing this problem?

Thanks,
George Faraj

Jan 21 '07 #1
2 2916
Joe

<gf****@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Has anyone tried to use Boost.Filesystem with C++/CLI? I'm trying to
get some code that worked correctly in my native application to work on
my C++/CLI program. The code is in a header file in a native C++ static
library.
Boost does not support the CLR platform.

http://www.boost.org/tools/build/v1/vc-8_0-tools.html


>
inline void execute_files(std::string const& dir, std::string
const& match, bool recursive = true, lua_State* interpreter = 0)
{
namespace bfs = boost::filesystem;

bfs::path dirpath(dir); // (1)

if (!bfs::exists(dirpath)) return;
if (!interpreter) interpreter = lua_interpreter();

bfs::directory_iterator end_itr;
for (bfs::directory_iterator itr(dirpath); itr != end_itr;
++itr)
{
if (!bfs::is_directory(*itr))
{
if (itr->leaf().find(match) != std::string::npos)
execute_file(itr->string());
}
else if (recursive)
{
execute_files(itr->string(), match, recursive,
interpreter);
}
}
}

The problem I'm having happens in the constructor of bfs::path (namely
line (1)) at the first recursive call. An exception is thrown which I
can't seem to get a helpful message from. It seems the string returned
from itr->string() is invalid. Has anyone tried to use Boost.Filesystem
in C++/CLI before? Any ideas on what could be causing this problem?

Thanks,
George Faraj

Feb 5 '07 #2

"Joe" <ju**@junk.comwrote in message
news:80**************************@KNOLOGY.NET...
>
<gf****@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
>Has anyone tried to use Boost.Filesystem with C++/CLI? I'm trying to
get some code that worked correctly in my native application to work on
my C++/CLI program. The code is in a header file in a native C++ static
library.

Boost does not support the CLR platform.
That just means you can't get pure managed code. C++/CLI lets you mix
managed code with native, and the native code can use the full C++ language
essentially without restrictions.
>
http://www.boost.org/tools/build/v1/vc-8_0-tools.html


>>
inline void execute_files(std::string const& dir, std::string
const& match, bool recursive = true, lua_State* interpreter = 0)
{
namespace bfs = boost::filesystem;

bfs::path dirpath(dir); // (1)

if (!bfs::exists(dirpath)) return;
if (!interpreter) interpreter = lua_interpreter();

bfs::directory_iterator end_itr;
for (bfs::directory_iterator itr(dirpath); itr != end_itr;
++itr)
{
if (!bfs::is_directory(*itr))
{
if (itr->leaf().find(match) != std::string::npos)
execute_file(itr->string());
}
else if (recursive)
{
execute_files(itr->string(), match, recursive,
interpreter);
}
}
}

The problem I'm having happens in the constructor of bfs::path (namely
line (1)) at the first recursive call. An exception is thrown which I
can't seem to get a helpful message from. It seems the string returned
from itr->string() is invalid. Has anyone tried to use Boost.Filesystem
in C++/CLI before? Any ideas on what could be causing this problem?

Thanks,
George Faraj


Feb 6 '07 #3

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

Similar topics

3
by: Michael | last post by:
Is this the correct place to ask about Boost libs? If it is.............. #include <boost/filesystem/path.hpp> #include <boost/filesystem/operations.hpp> using namespace boost; using...
4
by: Gary Wessle | last post by:
hi I did not find any way to traverse a given directory in c++ till I found boost, not sure if there many boost(ers) out here. but this is given me some error I cannot locate a fix. thanks ...
3
by: Andreas S. | last post by:
Hi, I don't any solution any more... I have written a small tool wich uses the boost library. It compiles fine, but I can't link it. I am on a Fedora Core 6 x86_64 system. The boost library is...
2
by: soren.andersen | last post by:
Hello out there :-) I'm new to c++, coming from Java, and trying to learn the basics of the language and all that, basically just for fun. :-) So, when once I played around with c++ a bit i...
5
by: GaryE | last post by:
Hello: I am having trouble linking a couple of files using the boost::filesystem. I am using MSVC 6.0. Here is an abbreviated version of my problem: foo.h: #ifndef __FOO_ #define...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.