Get directory from full path

Requires boost 1.37 of higher.

#include <boost/filesystem.hpp>


std::string full_path="whatever...";

std::string directory = boost::filesystem::path(full_path).parent_path().string();

... and the file name (no extension)
std::string name = boost::filesystem::path(full_path).stem().string();

... and the extension
std::string ext = boost::filesystem::path(full_path).extension().string();

No comments:

Post a Comment