directory_symlink_parent_resolution.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // directory_symlink_parent_resolution.cpp -------------------------------------------//
  2. // Copyright Beman Dawes 2015
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. // Library home page: http://www.boost.org/libs/filesystem
  6. #include <boost/filesystem.hpp>
  7. #include <boost/filesystem/string_file.hpp>
  8. #include <boost/detail/lightweight_main.hpp>
  9. #include <iostream>
  10. #include <string>
  11. using std::cout;
  12. using std::endl;
  13. using namespace boost::filesystem;
  14. int cpp_main(int argc, char* argv[])
  15. {
  16. # ifdef BOOST_WINDOWS_API
  17. cout << "BOOST_WINDOWS_API" << endl;
  18. # else
  19. cout << "BOOST_POSIX_API" << endl;
  20. # endif
  21. path test_dir(current_path() / "dspr_demo");
  22. remove_all(test_dir);
  23. create_directories(test_dir / "a/c/d");
  24. current_path(test_dir / "a");
  25. create_directory_symlink("c/d", "b");
  26. save_string_file("name.txt", "Windows");
  27. save_string_file("c/name.txt", "POSIX");
  28. current_path(test_dir);
  29. std::string s;
  30. load_string_file("a/b/../name.txt", s);
  31. cout << s << endl;
  32. return 0;
  33. }