Initial directory junction support. See release_history.html

This commit is contained in:
Beman 2014-07-25 11:00:54 -04:00
parent 06dde1a832
commit d774842f39
3 changed files with 82 additions and 4 deletions

View File

@ -36,6 +36,19 @@
</tr> </tr>
</table> </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
&quot;<code>mklink /j link target</code>&quot;. 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> <h2>1.56.0</h2>
<ul> <ul>
<li>Reorganize <code>recursive_directory_iterator::increment</code>, adding an <li>Reorganize <code>recursive_directory_iterator::increment</code>, adding an
@ -225,7 +238,7 @@
</ul> </ul>
<hr> <hr>
<p>Revised <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>© Copyright Beman Dawes, 2011</p>
<p> Use, modification, and distribution are subject to the Boost Software <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"> License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">

View File

@ -53,6 +53,7 @@
#endif #endif
#include <cerrno> #include <cerrno>
#define BOOST_FILEYSTEM_INCLUDE_IOSTREAM
#ifdef BOOST_FILEYSTEM_INCLUDE_IOSTREAM #ifdef BOOST_FILEYSTEM_INCLUDE_IOSTREAM
# include <iostream> # include <iostream>
#endif #endif
@ -587,8 +588,17 @@ namespace
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &dwRetLen, NULL); MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &dwRetLen, NULL);
if (!result) return false; if (!result) return false;
return reinterpret_cast<const REPARSE_DATA_BUFFER*>(buf.get()) return reinterpret_cast<const REPARSE_DATA_BUFFER*>(buf.get())->ReparseTag
->ReparseTag == IO_REPARSE_TAG_SYMLINK; == 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( inline std::size_t get_full_path_name(

View File

@ -1684,6 +1684,61 @@ namespace
== "c:/foo"); == "c:/foo");
BOOST_TEST(fs::system_complete(fs::path("//share")).generic_string() BOOST_TEST(fs::system_complete(fs::path("//share")).generic_string()
== "//share"); == "//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 } // Windows
else if (platform == "POSIX") else if (platform == "POSIX")