#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <exception>
#include <iostream>

void ls(const boost::filesystem::path &pfad) {
  if(!boost::filesystem::exists(pfad))
    std::cerr << "Pfad '" << pfad.string() << "' existiert nicht" << std::endl;
  else
    std::cout << pfad.native_file_string() << std::endl;

  if(boost::filesystem::is_directory(pfad)) {
    boost::filesystem::directory_iterator end;
    for( boost::filesystem::directory_iterator i(pfad);
	 i!=end;
	 ++i)
      ls(*i);
  }
}

int main(int argc,char **argv) {
  try {
    if(argc > 1)
      for(int i=1;i<argc;++i)
	ls(boost::filesystem::path(argv[i],boost::filesystem::native));
    else {
      std::cerr << "usage: " << *argv << " <pfad> ..." << std::endl;
      return 1;
    }
  }
  catch(std::exception &e) {
    std::cerr << "Fehler: " << e.what() << std::endl;
    return 1;
  }
  catch(...) {
    std::cerr << "Fehler: unbekannt" << std::endl;
    return 1;
  }
}
