Jean-Marc Lasgouttes wrote:
> Angus> Here's patch 1, to Boost.Filesystem. Beman Dawes, the libraries
> Angus> author, has indicated that he's "sympathetic" to the patch:
> Angus> http://article.gmane.org/gmane.comp.lib.boost.devel/131958
> Same remark as the other patch. I'd rather condition on
> HAVE_NEWAPIS_H.
Sheesh, you make me jump through hoops! :)
The attached patch will enable the Boost.Filesystem code to run on Win95.
It's conditioned on WANT_GETFILEATTRIBUTESEX_WRAPPER rather than
HAVE_NEWAPIS_H because that is all that is needed to get the code to work.
The HAVE_NEWAPIS_H is an artificial, autoconf construct that Beman Dawes
certainly won't accept into his library.
Similarly, I decided to add the WANT_GETFILEATTRIBUTESEX_WRAPPER definition
to config.h because Boost certainly won't accept it into their
config/user.hpp. They provide hooks for our config.h and they expect us to
use them.
Nonetheless, all the nastiness is confined to only one place and that place
is the right place IMO.
The code will compile both with MinGW and with MSVC and is kludge-free
albeit ugly. I'm going to propose this for merger back into the official
Boost sources.
OK to commit to the LyX devel tree?
--
Angus
Index: configure.ac
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/configure.ac,v
retrieving revision 1.61
diff -u -p -r1.61 configure.ac
--- configure.ac 29 Sep 2005 13:25:36 -0000 1.61
+++ configure.ac 29 Sep 2005 17:47:31 -0000
@@ -249,7 +249,7 @@ AC_LANG_POP(C)
# some standard header files
AC_HEADER_DIRENT
AC_HEADER_MAJOR
-AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h io.h process.h)
+AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h io.h process.h NewAPIs.h)
# some standard structures
AC_HEADER_STAT
@@ -405,6 +405,10 @@ int mkstemp(char*);
#ifdef __CYGWIN__
#define BOOST_POSIX 1
+#endif
+
+#if definded (HAVE_NEWAPIS_H) && defined (_WIN32)
+# define WANT_GETFILEATTRIBUTESEX_WRAPPER 1
#endif
#endif
Index: boost/libs/filesystem/src/operations_posix_windows.cpp
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/boost/libs/filesystem/src/operations_posix_windows.cpp,v
retrieving revision 1.3
diff -u -p -r1.3 operations_posix_windows.cpp
--- boost/libs/filesystem/src/operations_posix_windows.cpp 20 Nov 2004 09:08:44 -0000 1.3
+++ boost/libs/filesystem/src/operations_posix_windows.cpp 29 Sep 2005 17:47:32 -0000
@@ -46,6 +46,50 @@ namespace fs = boost::filesystem;
# if defined(BOOST_WINDOWS)
# include "windows.h"
+
+ //////////////////////////////////////////////////////////////////////
+ //
+ // Enable Boost.Filesystem to run on Win95 using the emulation
+ // of GetFileAttributesEx available in the Microsoft Platform SDK
+ // header file NewAPIs.h.
+ //
+ // The user needs only to define WANT_GETFILEATTRIBUTESEX_WRAPPER
+ // to enable this emulation.
+ //
+ // Please note, however, that this block of preprocessor code enables
+ // the user to compile against the emulation code. To link the
+ // executable the user must also compile the function definitions in
+ // NewAPIs.h. See NewAPIs.h for further details.
+ //
+ // This code should work both with Microsoft's native implementation
+ // of the winapi headers and also with MinGW/Cygwin's version.
+ //
+ //////////////////////////////////////////////////////////////////////
+# if defined(WANT_GETFILEATTRIBUTESEX_WRAPPER)
+# if (defined(__MINGW__) || defined(__CYGWIN__)) && WINVER < 0x040A
+ // MinGW/Cygwin's winapi header files and NewAPIs.h do not live
+ // well together because NewAPIs.h redefines
+ // WIN32_FILE_ATTRIBUTE_DATA if WINVER < 0x04A.
+# include <w32api.h>
+# if __W32API_MAJOR_VERSION < 3 || \
+ __W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION <= 3
+# define BOOST_FILESYSTEM_WINVER WINVER
+# undef WINVER
+# define WINVER 0x040A
+# endif
+# endif
+
+# include <NewAPIs.h>
+
+ // Return macro definitions to their original state.
+# ifdef BOOST_FILESYSTEM_WINVER
+# undef WINVER
+# define WINVER BOOST_FILESYSTEM_WINVER
+# undef BOOST_FILESYSTEM_WINVER
+# endif
+# endif
+ //////////////////////////////////////////////////////////////////////
+
# if defined(__BORLANDC__) || defined(__MWERKS__)
# if defined(__BORLANDC__)
using std::time_t;
@@ -391,7 +435,7 @@ namespace boost
: path_stat.st_size == 0;
# else
WIN32_FILE_ATTRIBUTE_DATA fad;
- if ( !::GetFileAttributesExA( ph.string().c_str(),
+ if ( !::GetFileAttributesEx( ph.string().c_str(),
::GetFileExInfoStandard, &fad ) )
boost::throw_exception( filesystem_error(
"boost::filesystem::is_empty",
@@ -538,7 +582,7 @@ namespace boost
# else
// by now, intmax_t is 64-bits on all Windows compilers
WIN32_FILE_ATTRIBUTE_DATA fad;
- if ( !::GetFileAttributesExA( ph.string().c_str(),
+ if ( !::GetFileAttributesEx( ph.string().c_str(),
::GetFileExInfoStandard, &fad ) )
boost::throw_exception( filesystem_error(
"boost::filesystem::file_size",