Boost logo

Boost Users :

From: George Faraj (gfaraj_at_[hidden])
Date: 2007-01-21 19:11:23


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net