]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/filesystem/test/issues/99_canonical_with_junction_point.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / filesystem / test / issues / 99_canonical_with_junction_point.cpp
index d62215762390eac14397864ee504df529979d76f..38e3bc078920cc060e7ca74bfd80f5d04dddcf25 100644 (file)
@@ -21,16 +21,17 @@ namespace fs = boost::filesystem;
 
 struct TmpDir
 {
-  fs::path path;
-  TmpDir(const fs::path& base): path(fs::absolute(base) / fs::unique_path())
-  {
-    fs::create_directories(path);
-  }
-  ~TmpDir()
-  {
-    boost::system::error_code ec;
-    fs::remove_all(path, ec);
-  }
+    fs::path path;
+    TmpDir(const fs::path& base) :
+        path(fs::absolute(base) / fs::unique_path())
+    {
+        fs::create_directories(path);
+    }
+    ~TmpDir()
+    {
+        boost::system::error_code ec;
+        fs::remove_all(path, ec);
+    }
 };
 
 // Test fs::canonical for various path in a Windows directory junction point
@@ -38,48 +39,47 @@ struct TmpDir
 int main()
 {
 
-  const fs::path cwd = fs::current_path();
-  const TmpDir tmp(cwd);
-  const fs::path junction = tmp.path / "junction";
-  const fs::path real = tmp.path / "real";
-  const fs::path subDir = "sub";
-  fs::create_directories(real / subDir);
-  fs::current_path(tmp.path);
-  BOOST_TEST(std::system("mklink /j junction real") == 0);
-  BOOST_TEST(fs::exists(junction));
-
-  // Due to a bug there was a dependency on the current path so try the below for all:
-  std::vector<fs::path> paths;
-  paths.push_back(cwd);
-  paths.push_back(junction);
-  paths.push_back(real);
-  paths.push_back(junction / subDir);
-  paths.push_back(real / subDir);
-  for (std::vector<fs::path>::iterator it = paths.begin(); it != paths.end(); ++it)
-  {
-    std::cout << "Testing in " << *it << std::endl;
-    fs::current_path(*it);
-
-    // Used by canonical, must work too
-    BOOST_TEST(fs::read_symlink(junction) == real);
-
-    BOOST_TEST(fs::canonical(junction) == real);
-    BOOST_TEST(fs::canonical(junction / subDir) == real / subDir);
-  }
-
-  // Restore the original current directory so that temp directory can be removed
-  fs::current_path(cwd);
-
-  return boost::report_errors();
+    const fs::path cwd = fs::current_path();
+    const TmpDir tmp(cwd);
+    const fs::path junction = tmp.path / "junction";
+    const fs::path real = tmp.path / "real";
+    const fs::path subDir = "sub";
+    fs::create_directories(real / subDir);
+    fs::current_path(tmp.path);
+    BOOST_TEST(std::system("mklink /J junction real") == 0);
+    BOOST_TEST(fs::exists(junction));
+
+    // Due to a bug there was a dependency on the current path so try the below for all:
+    std::vector< fs::path > paths;
+    paths.push_back(cwd);
+    paths.push_back(junction);
+    paths.push_back(real);
+    paths.push_back(junction / subDir);
+    paths.push_back(real / subDir);
+    for (std::vector< fs::path >::iterator it = paths.begin(); it != paths.end(); ++it)
+    {
+        std::cout << "Testing in " << *it << std::endl;
+        fs::current_path(*it);
+
+        // Used by canonical, must work too
+        BOOST_TEST(fs::read_symlink(junction) == real);
+
+        BOOST_TEST(fs::canonical(junction) == real);
+        BOOST_TEST(fs::canonical(junction / subDir) == real / subDir);
+    }
+
+    // Restore the original current directory so that temp directory can be removed
+    fs::current_path(cwd);
+
+    return boost::report_errors();
 }
 
 #else // defined(BOOST_FILESYSTEM_HAS_MKLINK)
 
 int main()
 {
-  std::cout << "Skipping test as the target system does not support mklink." << std::endl;
-  return 0;
+    std::cout << "Skipping test as the target system does not support mklink." << std::endl;
+    return 0;
 }
 
 #endif // defined(BOOST_FILESYSTEM_HAS_MKLINK)
-