|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71201 - in trunk/libs/filesystem/v3: doc test test/msvc10 test/msvc10/long_path_test
From: bdawes_at_[hidden]
Date: 2011-04-12 10:34:17
Author: bemandawes
Date: 2011-04-12 10:34:16 EDT (Tue, 12 Apr 2011)
New Revision: 71201
URL: http://svn.boost.org/trac/boost/changeset/71201
Log:
Add comment to docs on Windows extended-length prefix paths. Add test program for experimenting with extended-length prefix paths.
Added:
trunk/libs/filesystem/v3/test/long_path_test.cpp (contents, props changed)
trunk/libs/filesystem/v3/test/msvc10/long_path_test/
trunk/libs/filesystem/v3/test/msvc10/long_path_test/long_path_test.vcxproj (contents, props changed)
Text files modified:
trunk/libs/filesystem/v3/doc/reference.html | 37 +++++++++++++++++++++++++++++++++++--
trunk/libs/filesystem/v3/test/msvc10/filesystem-v3.sln | 10 ++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
Modified: trunk/libs/filesystem/v3/doc/reference.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/reference.html (original)
+++ trunk/libs/filesystem/v3/doc/reference.html 2011-04-12 10:34:16 EDT (Tue, 12 Apr 2011)
@@ -124,6 +124,8 @@
<td width="34%" valign="top">
<a href="#File-streams">File streams</a><br>
<a href="#Path-decomposition-table">Path decomposition table</a><br>
+ <a href="#long-path-warning">Warning: Long paths on Windows and the
+ extended-length <b>\\?\ </b>prefix</a><br>
<a href="#Acknowledgements">Acknowledgements</a><br>
<a href="#References">References</a><br>
</td>
@@ -3225,6 +3227,37 @@
<td><span style="background-color: #CCFFCC"><code>foo\bar</code><br><code>bar</code></span></td>
</tr>
</table>
+<h2><a name="long-path-warning"></a>Warning: Long paths on Windows and the
+extended-length <b>\\?\ </b>prefix</h2>
+<p>The Microsoft Windows "Maximum Path Length Limitation" specifies:</p>
+<blockquote>
+<p>In the Windows API (with some exceptions ...), the maximum length for a path
+is MAX_PATH, which is defined as 260 characters.</p>
+<p>The Windows API has many functions that also have Unicode versions to permit
+an extended-length path for a maximum total path length of 32,767 characters.
+... To specify an extended-length path, use the <b>"\\?\" prefix</b>. For
+example, "\\?\D:\very long path".
+<i>[C++ string literals require backslashes be doubled, of course.]</i></p>
+</blockquote>
+<p>Because most Boost.Filesystem operational functions just pass the contents of
+a class path object to the Windows API, they do work with the extended-length
+prefixes. But some won't work, because to the limitations imposed by Windows.
+Read the following cautions carefully!</p>
+<h3>Cautions for paths with extended-length prefixes</h3>
+<ul>
+ <li>Individual components of a path are still are limited to whatever is
+ supported for the particular filesystem, commonly 255 characters.</li>
+ <li>Only backslashes only are acceptable as directory separators. Slashes are
+ not treated as separators.</li>
+ <li>All paths must be absolute - relative paths are not allowed.</li>
+ <li>Once an absolute path grows beyond 260 characters, it is essentially
+ poisoned and all operations must use extended-length prefixes. So even a
+ simple operation like <code>create_directory("a")</code> will fail if the
+ absolute path of the resulting directory would exceed 260 characters.</li>
+ <li>Certain Boost.Filesystem functions that decompose their argument path and
+ then work on individual relative directories or files will not work properly
+ with extended-length prefix paths.</li>
+</ul>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>This Filesystem Library is dedicated to my wife, Sonda, who provided the
support necessary to see both a trial implementation and the proposal itself
@@ -3265,11 +3298,11 @@
</tr>
</table>
<hr>
-<p>© Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010</p>
+<p>© Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
<p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->25 February 2011<!--webbot bot="Timestamp" endspan i-checksum="40677" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->12 April 2011<!--webbot bot="Timestamp" endspan i-checksum="28281" --></p>
</body>
Added: trunk/libs/filesystem/v3/test/long_path_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/filesystem/v3/test/long_path_test.cpp 2011-04-12 10:34:16 EDT (Tue, 12 Apr 2011)
@@ -0,0 +1,61 @@
+// long_path_test.cpp ----------------------------------------------------------------//
+
+// Copyright Beman Dawes 2011
+
+// Distributed under the Boost Software License, Version 1.0.
+// http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/btree for documentation.
+
+// See http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
+
+#define BOOST_FILESYSTEM_VERSION 3
+
+#include <boost/config/warning_disable.hpp>
+
+#include <boost/filesystem.hpp>
+#include <iostream>
+#include <string>
+
+using namespace boost::filesystem;
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/lightweight_main.hpp>
+
+namespace
+{
+} // unnamed namespace
+
+int cpp_main(int, char*[])
+{
+
+ std::string prefix("d:\\temp\\");
+ std::cout << "prefix is " << prefix << '\n';
+
+ const std::size_t safe_size
+ = 260 - prefix.size() - 100; // Windows MAX_PATH is 260
+
+ std::string safe_x_string(safe_size, 'x');
+ std::string safe_y_string(safe_size, 'y');
+ std::string path_escape("\\\\?\\");
+
+ path x_p(prefix + safe_x_string);
+ path y_p(path_escape + prefix + safe_x_string + "\\" + safe_y_string);
+
+ std::cout << "x_p.native().size() is " << x_p.native().size() << '\n';
+ std::cout << "y_p.native().size() is " << y_p.native().size() << '\n';
+
+ create_directory(x_p);
+ BOOST_TEST(exists(x_p));
+ create_directory(y_p);
+ BOOST_TEST(exists(y_p));
+
+ //std::cout << "directory x.../y... ready for testing, where ... is " << safe_size
+ // << " repeats of x and y, respectively\n";
+
+ BOOST_TEST(exists(x_p));
+
+ //remove_all(x_p);
+
+ return ::boost::report_errors();
+}
Modified: trunk/libs/filesystem/v3/test/msvc10/filesystem-v3.sln
==============================================================================
--- trunk/libs/filesystem/v3/test/msvc10/filesystem-v3.sln (original)
+++ trunk/libs/filesystem/v3/test/msvc10/filesystem-v3.sln 2011-04-12 10:34:16 EDT (Tue, 12 Apr 2011)
@@ -65,6 +65,12 @@
{FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "long_path_test", "long_path_test\long_path_test.vcxproj", "{1A6A7DAF-8705-4B2B-83B5-93F84A63496C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F94CCADD-A90B-480C-A304-C19D015D36B1} = {F94CCADD-A90B-480C-A304-C19D015D36B1}
+ {FFD738F7-96F0-445C-81EA-551665EF53D1} = {FFD738F7-96F0-445C-81EA-551665EF53D1}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -148,6 +154,10 @@
{23C735E1-0195-467F-BE9F-314829402FCF}.Debug|Win32.Build.0 = Debug|Win32
{23C735E1-0195-467F-BE9F-314829402FCF}.Release|Win32.ActiveCfg = Release|Win32
{23C735E1-0195-467F-BE9F-314829402FCF}.Release|Win32.Build.0 = Release|Win32
+ {1A6A7DAF-8705-4B2B-83B5-93F84A63496C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1A6A7DAF-8705-4B2B-83B5-93F84A63496C}.Debug|Win32.Build.0 = Debug|Win32
+ {1A6A7DAF-8705-4B2B-83B5-93F84A63496C}.Release|Win32.ActiveCfg = Release|Win32
+ {1A6A7DAF-8705-4B2B-83B5-93F84A63496C}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Added: trunk/libs/filesystem/v3/test/msvc10/long_path_test/long_path_test.vcxproj
==============================================================================
--- (empty file)
+++ trunk/libs/filesystem/v3/test/msvc10/long_path_test/long_path_test.vcxproj 2011-04-12 10:34:16 EDT (Tue, 12 Apr 2011)
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{1A6A7DAF-8705-4B2B-83B5-93F84A63496C}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>long_path_test</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\common.props" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\common.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ <PostBuildEvent>
+ <Command>"$(TargetDir)\$(TargetName).exe"</Command>
+ <Message>Executing test $(TargetName).exe...</Message>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ <PostBuildEvent>
+ <Command>"$(TargetDir)\$(TargetName).exe"</Command>
+ <Message>Executing test $(TargetName).exe...</Message>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\long_path_test.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\filesystem_dll\filesystem_dll.vcxproj">
+ <Project>{ffd738f7-96f0-445c-81ea-551665ef53d1}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\system_dll\system_dll.vcxproj">
+ <Project>{f94ccadd-a90b-480c-a304-c19d015d36b1}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk