mirror of
https://github.com/boostorg/filesystem.git
synced 2026-07-21 13:13:44 +00:00
Switch to POSIX API on Cygwin.
This follows other Boost libraries (in particular, Boost.System) in treating Cygwin as a POSIX platform rather than Windows. This is a breaking change, but apparently downstream Boost.Filesystem packages on Cygwin are patched to the same effect. As part of this change, AT_NO_AUTOMOUNT is made an optional requirement to enable POSIX *at APIs. This flag is not POSIX-standard and is not supported on Cygwin, while *at APIs are.
This commit is contained in:
+2
-6
@@ -39,7 +39,7 @@ rule select-windows-crypto-api ( properties * )
|
||||
{
|
||||
local result ;
|
||||
|
||||
if <target-os>windows in $(properties) || <target-os>cygwin in $(properties)
|
||||
if <target-os>windows in $(properties)
|
||||
{
|
||||
if ! [ has-config-flag BOOST_FILESYSTEM_DISABLE_BCRYPT : $(properties) ] &&
|
||||
[ configure.builds ../config//has_bcrypt : $(properties) : "has BCrypt API" ]
|
||||
@@ -175,10 +175,6 @@ project
|
||||
<target-os>windows:<define>_WIN32_WINNT=0x0A00
|
||||
<target-os>windows:<define>WIN32_LEAN_AND_MEAN
|
||||
<target-os>windows:<define>NOMINMAX
|
||||
<target-os>cygwin:<define>BOOST_USE_WINDOWS_H
|
||||
<target-os>cygwin:<define>_WIN32_WINNT=0x0A00
|
||||
<target-os>cygwin:<define>WIN32_LEAN_AND_MEAN
|
||||
<target-os>cygwin:<define>NOMINMAX
|
||||
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651
|
||||
@@ -207,7 +203,7 @@ rule select-platform-specific-sources ( properties * )
|
||||
{
|
||||
local result ;
|
||||
|
||||
if <target-os>windows in $(properties) || <target-os>cygwin in $(properties)
|
||||
if <target-os>windows in $(properties)
|
||||
{
|
||||
result += <source>windows_file_codecvt.cpp ;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ int main()
|
||||
res |= renameat(AT_FDCWD, "x", fd1, "y");
|
||||
|
||||
struct stat st;
|
||||
res |= fstatat(fd1, "y", &st, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW);
|
||||
res |= fstatat(fd1, "y", &st, AT_SYMLINK_NOFOLLOW);
|
||||
|
||||
res |= linkat(fd1, "y", fd1, "z", 0);
|
||||
res |= symlinkat("foo/z", fd1, "sz");
|
||||
|
||||
+2
-2
@@ -338,8 +338,8 @@ Compilation</a> page for a description of the techniques used.</p>
|
||||
<p> <a href="http://www.cygwin.com/">Cygwin</a> version 1.7 or later is
|
||||
required because only versions of GCC with wide character strings are supported.</p>
|
||||
|
||||
<p> The library's implementation code treats Cygwin as a Windows platform, and
|
||||
thus uses the Windows API and uses Windows path syntax as the native path
|
||||
<p> The library's implementation code treats Cygwin as a POSIX platform, and
|
||||
thus uses the POSIX API and POSIX path syntax as the native path
|
||||
syntax.</p>
|
||||
|
||||
<h2><a name="Change-history">Version history</a></h2>
|
||||
|
||||
@@ -42,8 +42,17 @@
|
||||
|
||||
<h2>1.91.0</h2>
|
||||
<ul>
|
||||
<li>Due to a change in Boost.System, Boost.Filesystem now defines and uses its own platform macros <code>BOOST_FILESYSTEM_POSIX_API</code> and <code>BOOST_FILESYSTEM_WINDOWS_API</code>. These macros may not necessarily match the old <code>BOOST_POSIX_API</code> and <code>BOOST_WINDOWS_API</code> macros defined by Boost.System.</li>
|
||||
<li>Boost.Filesystem now defines and uses its own platform macros <code>BOOST_FILESYSTEM_POSIX_API</code> and <code>BOOST_FILESYSTEM_WINDOWS_API</code>. The old <code>BOOST_POSIX_API</code> and <code>BOOST_WINDOWS_API</code> macros are still defined by Boost.System.</li>
|
||||
<li>On POSIX platforms not supporting <code>openat</code> and related APIs, fixed an error reported by <code>recursive_directory_iterator</code> increment when the iterator encounters a dangling symlink and following symlinks is disabled.</li>
|
||||
<li><b>Breaking change for Cygwin users.</b> The library now treats Cygwin as a POSIX platform. This has several user-facing consequences, in particular:
|
||||
<ul>
|
||||
<li>The <code>path::value_type</code> type has changed from <code>wchar_t</code> to <code>char</code>. As on other POSIX platforms, wide character paths will be converted to the narrow character encoding using the locale set by <code>path::imbue</code>. Note that since Cygwin is running on top of Windows, it will also perform character code conversion internally. It is important that locale in the Cygwin environment is configured correctly.</li>
|
||||
<li>Path syntax now follows POSIX conventions, Windows-specific paths (e.g. UNC paths, drive names and path prefixes) are not supported.</li>
|
||||
<li>Certain Windows-specific parts of the API will become inaccessible. Since reparse points are a Windows-only feature, <code>file_type::reparse_file</code> will not be reported for files. Reparse point handling is dependent on Cygwin runtime behavior.</li>
|
||||
<li>Cygwin has its own implementation of symlinks that is incompatible with native Windows symlinks. Boost.Filesystem will now create and operate on Cygwin symlinks.</li>
|
||||
<li>Error codes reported by Boost.Filesystem will now use POSIX <code>errno</code> values.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2>1.90.0</h2>
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ several Boost releases. Version 2 was removed in Boost 1.50.0.</p>
|
||||
supported.<br/>
|
||||
</li>
|
||||
<li>Cygwin versions prior to 1.7 are no longer supported because they lack
|
||||
wide string support. Cygwin now compiles only for the Windows API and path
|
||||
wide string support. Cygwin now compiles only for the POSIX API and path
|
||||
syntax.<br/>
|
||||
</li>
|
||||
<li>MinGW versions not supporting wide strings are no longer supported.<br/>
|
||||
|
||||
@@ -59,8 +59,8 @@
|
||||
#error BOOST_FILESYSTEM_WINDOWS_API and BOOST_FILESYSTEM_POSIX_API must not be defined by users
|
||||
#endif
|
||||
|
||||
// Cygwin is treated as Windows to minimize path character code conversions
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)
|
||||
// Note: Cygwin is treated as a POSIX platform
|
||||
#if defined(BOOST_WINDOWS)
|
||||
#define BOOST_FILESYSTEM_WINDOWS_API
|
||||
#else
|
||||
#define BOOST_FILESYSTEM_POSIX_API
|
||||
|
||||
@@ -186,6 +186,11 @@ using boost::system::system_category;
|
||||
#define BOOST_FILESYSTEM_NO_O_CLOEXEC
|
||||
#endif
|
||||
|
||||
// At least Cygwin (cygwin1.dll 3.6.5, as of 2025-12-25) doesn't support AT_NO_AUTOMOUNT
|
||||
#ifndef AT_NO_AUTOMOUNT
|
||||
#define AT_NO_AUTOMOUNT 0
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
|
||||
#define BOOST_FILESYSTEM_HAS_FDATASYNC
|
||||
#endif
|
||||
|
||||
@@ -68,8 +68,11 @@
|
||||
#define _INCLUDE_STDCSOURCE_199901
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) || \
|
||||
defined(__CYGWIN__)
|
||||
#if defined(__CYGWIN__)
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#elif defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
|
||||
// Define target Windows version macros before including any other headers
|
||||
#include <boost/winapi/config.hpp>
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,7 @@ rule check-mklink ( properties * )
|
||||
project
|
||||
: requirements
|
||||
<include>.
|
||||
<include>../src
|
||||
<target-os>windows:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<target-os>windows:<define>_SCL_SECURE_NO_DEPRECATE
|
||||
<target-os>windows:<define>_CRT_SECURE_NO_WARNINGS
|
||||
|
||||
@@ -78,7 +78,7 @@ int cpp_main(int /*argc*/, char* /*argv*/[])
|
||||
// The choice of platform is make at runtime rather than compile-time
|
||||
// so that compile errors for all platforms will be detected even though
|
||||
// only the current platform is runtime tested.
|
||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin") ? "Windows" : "POSIX";
|
||||
platform = (platform == "Win32" || platform == "Win64") ? "Windows" : "POSIX";
|
||||
std::cout << "Platform is " << platform << '\n';
|
||||
|
||||
l.push_back('s');
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
// Library home page: http://www.boost.org/libs/filesystem
|
||||
|
||||
#include "platform_config.hpp"
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
// See deprecated_test for tests of deprecated features
|
||||
@@ -729,10 +731,13 @@ void recursive_directory_iterator_tests()
|
||||
it != fs::recursive_directory_iterator();
|
||||
it.increment(ec))
|
||||
{
|
||||
//std::cout << " iterator path: " << it->path().string() << std::endl;
|
||||
if (it->path().filename() == "d1f1")
|
||||
++d1f1_count;
|
||||
BOOST_TEST(it == it2); // verify single pass shallow copy semantics
|
||||
}
|
||||
if (ec)
|
||||
cout << " iterator increment returned error: " << ec << ", " << ec.message() << endl;
|
||||
BOOST_TEST(!ec);
|
||||
BOOST_TEST_EQ(d1f1_count, 1);
|
||||
BOOST_TEST(it == it2); // verify single pass shallow copy semantics
|
||||
|
||||
+1
-1
@@ -2936,7 +2936,7 @@ int cpp_main(int, char*[])
|
||||
// The choice of platform is make at runtime rather than compile-time
|
||||
// so that compile errors for all platforms will be detected even though
|
||||
// only the current platform is runtime tested.
|
||||
platform = (platform == "Win32" || platform == "Win64" || platform == "Cygwin") ? "Windows" : "POSIX";
|
||||
platform = (platform == "Win32" || platform == "Win64") ? "Windows" : "POSIX";
|
||||
std::cout << "Platform is " << platform << '\n';
|
||||
|
||||
BOOST_TEST(p1.string() != p3.string());
|
||||
|
||||
Reference in New Issue
Block a user