1 // filesystem example stems.cpp ------------------------------------------------------// 2 3 // Copyright Beman Dawes 2011 4 5 // Distributed under the Boost Software License, Version 1.0. 6 // See http://www.boost.org/LICENSE_1_0.txt 7 8 // Library home page: http://www.boost.org/libs/filesystem 9 10 #include <boost/filesystem.hpp> 11 #include <iostream> 12 main(int argc,char * argv[])13int main(int argc, char* argv[]) 14 { 15 if (argc < 2) 16 { 17 std::cout << "Usage: stems <path>\n"; 18 return 1; 19 } 20 21 boost::filesystem::path p(argv[1]), name(p.filename()); 22 23 for(;;) 24 { 25 std::cout << "filename " << name << " has stem " << name.stem() 26 << " and extension " << name.extension() << "\n"; 27 if (name.stem().empty() || name.extension().empty()) 28 return 0; 29 name = name.stem(); 30 } 31 } 32