How similar are Boost.Filesystem and the C++ standard filesystem library?

There are a number of differences. Some were, I believe, Boost changes that were never propagated. For example, there is no path.filename_is_dot() query (as discussed below, it would be less useful in std::filesystem anyway). There was also a good bit of late-breaking news on this front: Support for non-POSIX-like filesystems: Specify whether a string is … Read more

boost::filesystem get relative path

In new versions of boost (starting in 1.60), you can use boost::filesystem::relative. (See the documentation here.) #include <boost/filesystem.hpp> #include <iostream> namespace fs = boost::filesystem; int main() { fs::path parentPath(“/home/user1/”); fs::path childPath(“/home/user1/Downloads/Books”); fs::path relativePath = fs::relative(childPath, parentPath); std::cout << relativePath << std::endl; }

Get relative path from two absolute paths

With C++17 and its std::filesystem::relative, which evolved from boost, this is a no-brainer: #include <filesystem> #include <iostream> namespace fs = std::filesystem; int main() { const fs::path base(“/is/the/speed/of/light/absolute”); const fs::path p(“/is/the/speed/of/light/absolute/or/is/it/relative/to/the/observer”); const fs::path p2(“/little/light/races/in/orbit/of/a/rogue/planet”); std::cout << “Base is base: ” << fs::relative(p, base).generic_string() << ‘\n’ << “Base is deeper: ” << fs::relative(base, p).generic_string() << ‘\n’ << … Read more

boost directory_iterator example – how to list directory files not recursive

The tut3 example is what you’re looking for: See it Live on Coliru Here’s a simplified version based on c++11: Live On Coliru #include <boost/filesystem.hpp> #include <boost/range/iterator_range.hpp> #include <iostream> using namespace boost::filesystem; int main(int argc, char *argv[]) { path p(argc>1? argv[1] : “.”); if(is_directory(p)) { std::cout << p << ” is a directory containing:\n”; for(auto& … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)