Boost logo

Boost Users :

Subject: [Boost-users] [filesystem] get relative path from recursive_directory_iterator
From: Ivan Sorokin (sorokin_at_[hidden])
Date: 2011-04-24 16:03:58


Hello!

I'm using boost::filesystem v3. Currently recursive_directory_iterator
returns absolute path. So the program

for (fs::recursive_directory_iterator it("/home/ivan"); it !=
fs::recursive_directory_iterator(); ++it)
    std::cout << *it << std::endl;

may output

/home/ivan/somedir/1.txt
/home/ivan/somedir/2.txt

But what I want is something like:

./somedir/1.txt
./somedir/2.txt

I use function naive_uncomplete described in
https://svn.boost.org/trac/boost/ticket/1976

fs::path base = "/home/ivan";
for (fs::recursive_directory_iterator it(base); it !=
fs::recursive_directory_iterator(); ++it)
   std::cout << naive_uncomplete(*it, base) << std::endl;

Is there any plans to include this function is boost? Is there any
possibility to get relative paths using only functions from boost?


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