mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 13:41:47 +00:00
Initial directory junction support. See release_history.html
This commit is contained in:
parent
06dde1a832
commit
d774842f39
@ -36,6 +36,19 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>1.56.1</h2>
|
||||
<ul>
|
||||
<li>The Windows implementation now treats NTFS directory junctions (also known
|
||||
as junctions, also known as mount points) as symlinks. This has the effect of
|
||||
treating directory junctions as directories, and thus supporting all
|
||||
operations suitable for directories. This resolves
|
||||
<a href="https://svn.boost.org/trac/boost/ticket/9016">#9016</a>. Directory
|
||||
junctions are very similar to symlinks, but may have performance or other
|
||||
advantages in some situations. They can be created from the command line with
|
||||
"<code>mklink /j link target</code>". There is no plan for Boost.Filesystem to
|
||||
be able to create them directly other than by calling <code>std::system()</code>.</li>
|
||||
</ul>
|
||||
|
||||
<h2>1.56.0</h2>
|
||||
<ul>
|
||||
<li>Reorganize <code>recursive_directory_iterator::increment</code>, adding an
|
||||
@ -225,7 +238,7 @@
|
||||
</ul>
|
||||
<hr>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->22 July, 2014<!--webbot bot="Timestamp" endspan i-checksum="21122" --></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->25 July, 2014<!--webbot bot="Timestamp" endspan i-checksum="21128" --></p>
|
||||
<p>© Copyright Beman Dawes, 2011</p>
|
||||
<p> Use, modification, and distribution are subject to the Boost Software
|
||||
License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
|
@ -53,6 +53,7 @@
|
||||
#endif
|
||||
#include <cerrno>
|
||||
|
||||
#define BOOST_FILEYSTEM_INCLUDE_IOSTREAM
|
||||
#ifdef BOOST_FILEYSTEM_INCLUDE_IOSTREAM
|
||||
# include <iostream>
|
||||
#endif
|
||||
@ -586,9 +587,18 @@ namespace
|
||||
BOOL result = ::DeviceIoControl(h.handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buf.get(),
|
||||
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &dwRetLen, NULL);
|
||||
if (!result) return false;
|
||||
|
||||
return reinterpret_cast<const REPARSE_DATA_BUFFER*>(buf.get())
|
||||
->ReparseTag == IO_REPARSE_TAG_SYMLINK;
|
||||
|
||||
return reinterpret_cast<const REPARSE_DATA_BUFFER*>(buf.get())->ReparseTag
|
||||
== IO_REPARSE_TAG_SYMLINK
|
||||
// Issue 9016 asked that NTFS directory junctions be recognized as directories.
|
||||
// That is equivalent to recognizing them as symlinks, and then the normal symlink
|
||||
// mechanism will take care of recognizing them as directories.
|
||||
//
|
||||
// Directory junctions are very similar to symlinks, but have some performance
|
||||
// and other advantages over symlinks. They can be created from the command line
|
||||
// with "mklink /j junction-name target-path".
|
||||
|| reinterpret_cast<const REPARSE_DATA_BUFFER*>(buf.get())->ReparseTag
|
||||
== IO_REPARSE_TAG_MOUNT_POINT; // aka "directory junction" or "junction"
|
||||
}
|
||||
|
||||
inline std::size_t get_full_path_name(
|
||||
|
@ -1684,6 +1684,61 @@ namespace
|
||||
== "c:/foo");
|
||||
BOOST_TEST(fs::system_complete(fs::path("//share")).generic_string()
|
||||
== "//share");
|
||||
|
||||
// Issue 9016 asked that NTFS directory junctions be recognized as directories.
|
||||
// That is equivalent to recognizing them as symlinks, and then the normal symlink
|
||||
// mechanism will take care of recognizing them as directories.
|
||||
//
|
||||
// Directory junctions are very similar to symlinks, but have some performance
|
||||
// and other advantages over symlinks. They can be created from the command line
|
||||
// with "mklink /j junction-name target-path".
|
||||
|
||||
if (create_symlink_ok) // only if symlinks supported
|
||||
{
|
||||
cout << " directory junction tests..." << endl;
|
||||
BOOST_TEST(fs::exists(dir));
|
||||
BOOST_TEST(fs::exists(dir / "d1f1"));
|
||||
|
||||
fs::path junc(dir / "junc");
|
||||
std::string cmd = "pushd ";
|
||||
cmd += dir.string();
|
||||
std::system(cmd.c_str());
|
||||
std::system("mklink /j junc d1");
|
||||
std::system("popd");
|
||||
|
||||
BOOST_TEST(fs::exists(junc));
|
||||
BOOST_TEST(fs::is_symlink(junc));
|
||||
BOOST_TEST(fs::is_directory(junc));
|
||||
BOOST_TEST(!fs::is_regular_file(junc));
|
||||
BOOST_TEST(fs::exists(junc / "d1f1"));
|
||||
BOOST_TEST(fs::is_regular_file(junc / "d1f1"));
|
||||
|
||||
int count = 0;
|
||||
for (fs::directory_iterator itr(junc);
|
||||
itr != fs::directory_iterator(); ++itr)
|
||||
{
|
||||
cout << itr->path() << endl;
|
||||
++count;
|
||||
}
|
||||
BOOST_TEST(count > 0);
|
||||
|
||||
fs::path new_junc(dir / "new-junc");
|
||||
fs::rename(junc, new_junc);
|
||||
BOOST_TEST(!fs::exists(junc));
|
||||
BOOST_TEST(fs::exists(new_junc));
|
||||
BOOST_TEST(fs::is_symlink(new_junc));
|
||||
BOOST_TEST(fs::is_directory(new_junc));
|
||||
BOOST_TEST(!fs::is_regular_file(new_junc));
|
||||
BOOST_TEST(fs::exists(new_junc / "d1f1"));
|
||||
BOOST_TEST(fs::is_regular_file(new_junc / "d1f1"));
|
||||
|
||||
fs::remove(new_junc);
|
||||
BOOST_TEST(!fs::exists(new_junc / "d1f1"));
|
||||
BOOST_TEST(!fs::exists(new_junc));
|
||||
BOOST_TEST(fs::exists(dir));
|
||||
BOOST_TEST(fs::exists(dir / "d1f1"));
|
||||
}
|
||||
|
||||
} // Windows
|
||||
|
||||
else if (platform == "POSIX")
|
||||
|
Loading…
x
Reference in New Issue
Block a user