const char *filename = "C:/Qt/progetti/worlds/fasr.world";
char *pathdir = "C:/Qt/progetti/worlds";
QDir(pathdir).relativeFilePath(filename);
pathdir
"C:/Qt/progetti"
std::string( basename(pathdir) ) + std::string("/") + std::string( basename(filename) );
123456789101112131415161718192021
#include <iostream> #include <boost/filesystem.hpp> namespace fs = boost::filesystem ; int main() { const char *filename = "C:/Qt/progetti/worlds/fasr.world"; char *pathdir = "C:/Qt/progetti/worlds"; std::cout << fs::basename(pathdir) + '/' + fs::basename(filename) + fs::extension(filename) << '\n' ; // Or: //fs::path path_with_name("C:/Qt/progetti/worlds/fasr.world") ; //fs::path base_path("C:/Qt/progetti/worlds") ; //std::cout << base_path.filename().string() + '/' + // path_with_name.filename().string() << '\n' ; }
worlds/fasr.world