C++/CLI and Boost.Filesystem

G

gfaraj

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
 
B

Ben Voigt

Joe said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top