Getting a filename from a path with Boost - C++ boost

C++ examples for boost:file system

Description

Getting a filename from a path with Boost

#include <iostream>
#include <cstdlib>
#include <boost/filesystem/operations.hpp>

using namespace std;
using namespace boost::filesystem;

int main(int argc, char** argv) {
   try {
      path p = complete(path("test", native));
      cout << p.leaf() << " is a " << (is_directory(p) ? "directory" : "file") << endl;
   }
   catch (exception& e) {
      cerr << e.what() << endl;
   }

  return(EXIT_SUCCESS);
}

Related Tutorials