equivalent.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // equivalent program -------------------------------------------------------//
  2. // Copyright (c) 2004 Beman Dawes
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
  5. // at http://www.boost.org/LICENSE_1_0.txt)
  6. // See library home page at http://www.boost.org/libs/filesystem
  7. //----------------------------------------------------------------------------//
  8. #include <boost/filesystem/operations.hpp>
  9. #include <iostream>
  10. #include <exception>
  11. int main( int argc, char * argv[] )
  12. {
  13. boost::filesystem::path::default_name_check( boost::filesystem::native );
  14. if ( argc != 3 )
  15. {
  16. std::cout << "Usage: equivalent path1 path2\n";
  17. return 2;
  18. }
  19. bool eq;
  20. try
  21. {
  22. eq = boost::filesystem::equivalent( argv[1], argv[2] );
  23. }
  24. catch ( const std::exception & ex )
  25. {
  26. std::cout << ex.what() << "\n";
  27. return 3;
  28. }
  29. std::cout << (eq ? "Paths are equivalent\n" : "Paths are not equivalent\n");
  30. return !eq;
  31. }