summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-23 13:16:26 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-12-23 14:43:26 (GMT)
commit491ddd570a752cf9bda85933bed0c6942e39b1f9 (patch)
tree10c25c1be8cc08d0497df1dccd56a10fbb30beee /3rdParty/Boost/src/libs
parentda7d7a0ca71b80281aa9ff2526290b61ccb0cc60 (diff)
downloadswift-491ddd570a752cf9bda85933bed0c6942e39b1f9.zip
swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.tar.bz2
Update Boost to 1.52.0.
Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77
Diffstat (limited to '3rdParty/Boost/src/libs')
-rw-r--r--3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp4
-rw-r--r--3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp10
-rw-r--r--3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp2
-rw-r--r--3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp2
-rw-r--r--3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp2
-rw-r--r--3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp2
-rw-r--r--3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp285
-rw-r--r--3rdParty/Boost/src/libs/exception/build/Jamfile.v214
-rw-r--r--3rdParty/Boost/src/libs/exception/src/clone_current_exception_non_intrusive.cpp320
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/codecvt_error_category.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/codecvt_error_category.cpp)17
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/filesystem_utf8_codecvt_facet.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/filesystem_utf8_codecvt_facet.cpp)6
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/operations.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/operations.cpp)479
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/path.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/path.cpp)356
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/path_traits.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/path_traits.cpp)21
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/portability.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/portability.cpp)19
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/unique_path.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/unique_path.cpp)15
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/windows_file_codecvt.cpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/windows_file_codecvt.cpp)14
-rw-r--r--3rdParty/Boost/src/libs/filesystem/src/windows_file_codecvt.hpp (renamed from 3rdParty/Boost/src/libs/filesystem/v3/src/windows_file_codecvt.hpp)2
-rw-r--r--3rdParty/Boost/src/libs/filesystem/v2/src/v2_operations.cpp1372
-rw-r--r--3rdParty/Boost/src/libs/filesystem/v2/src/v2_path.cpp177
-rw-r--r--3rdParty/Boost/src/libs/filesystem/v2/src/v2_portability.cpp119
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/cmdline.cpp324
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/config_file.cpp6
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/options_description.cpp56
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/parsers.cpp10
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/positional_options.cpp2
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/program_options_utf8_codecvt_facet.cpp2
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/value_semantic.cpp279
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/variables_map.cpp132
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/winmain.cpp4
-rw-r--r--3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp21
-rw-r--r--3rdParty/Boost/src/libs/regex/src/cregex.cpp17
-rw-r--r--3rdParty/Boost/src/libs/regex/src/fileiter.cpp12
-rw-r--r--3rdParty/Boost/src/libs/regex/src/internals.hpp35
-rw-r--r--3rdParty/Boost/src/libs/regex/src/posix_api.cpp11
-rw-r--r--3rdParty/Boost/src/libs/regex/src/regex.cpp1
-rw-r--r--3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp4
-rw-r--r--3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp21
-rw-r--r--3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp16
-rw-r--r--3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp6
-rw-r--r--3rdParty/Boost/src/libs/system/src/error_code.cpp3
-rwxr-xr-x3rdParty/Boost/src/libs/thread/src/future.cpp61
-rw-r--r--3rdParty/Boost/src/libs/thread/src/pthread/once.cpp51
-rw-r--r--3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp232
-rw-r--r--3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl17
-rw-r--r--3rdParty/Boost/src/libs/thread/src/tss_null.cpp4
-rw-r--r--3rdParty/Boost/src/libs/thread/src/win32/thread.cpp331
-rw-r--r--3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl16
-rw-r--r--3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp1
-rw-r--r--3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp9
50 files changed, 2092 insertions, 2830 deletions
diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp
index bbef7f6..4669065 100644
--- a/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp
+++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp
@@ -3,7 +3,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
- * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
+ * $Date: 2012-09-24 11:08:16 -0700 (Mon, 24 Sep 2012) $
*/
@@ -22,7 +22,7 @@ namespace date_time {
//! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
BOOST_DATE_TIME_DECL const char* nth_as_str(int ele)
{
- if(ele >= 1 || ele <= 5) {
+ if(ele >= 1 && ele <= 5) {
return _nth_as_str[ele];
}
else {
diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp
index efca973..cce04f0 100644
--- a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp
+++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp
@@ -3,7 +3,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
- * $Date: 2008-11-23 06:13:35 -0500 (Sun, 23 Nov 2008) $
+ * $Date: 2012-09-30 16:25:22 -0700 (Sun, 30 Sep 2012) $
*/
@@ -108,7 +108,7 @@ namespace gregorian {
*/
BOOST_DATE_TIME_DECL
boost::date_time::all_date_names_put<greg_facet_config, char>*
- create_facet_def(char type)
+ create_facet_def(char /*type*/)
{
typedef
boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
@@ -121,7 +121,7 @@ namespace gregorian {
}
//! generates a locale with the set of gregorian name-strings of type char*
- BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char type){
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char /*type*/){
typedef boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
return std::locale(loc, new facet_def(short_month_names,
long_month_names,
@@ -139,7 +139,7 @@ namespace gregorian {
*/
BOOST_DATE_TIME_DECL
boost::date_time::all_date_names_put<greg_facet_config, wchar_t>*
- create_facet_def(wchar_t type)
+ create_facet_def(wchar_t /*type*/)
{
typedef
boost::date_time::all_date_names_put<greg_facet_config,wchar_t> facet_def;
@@ -152,7 +152,7 @@ namespace gregorian {
}
//! generates a locale with the set of gregorian name-strings of type wchar_t*
- BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t type){
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t /*type*/){
typedef boost::date_time::all_date_names_put<greg_facet_config, wchar_t> facet_def;
return std::locale(loc, new facet_def(w_short_month_names,
w_long_month_names,
diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp
index 76a1a24..44aa8b8 100644
--- a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp
+++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp
@@ -3,7 +3,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
- * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
+ * $Date: 2008-02-27 12:00:24 -0800 (Wed, 27 Feb 2008) $
*/
diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp
index 4057d29..fe83c15 100644
--- a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp
+++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp
@@ -3,7 +3,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
- * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
+ * $Date: 2008-02-27 12:00:24 -0800 (Wed, 27 Feb 2008) $
*/
diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp
index a856e79..341731f 100644
--- a/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp
+++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp
@@ -3,7 +3,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
- * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
+ * $Date: 2008-02-27 12:00:24 -0800 (Wed, 27 Feb 2008) $
*/
diff --git a/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp b/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp
index 06ef563..4916d36 100644
--- a/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp
+++ b/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp
@@ -4,7 +4,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
- * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
+ * $Date: 2008-02-27 12:00:24 -0800 (Wed, 27 Feb 2008) $
*/
diff --git a/3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp b/3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp
deleted file mode 100644
index 7ea5eeb..0000000
--- a/3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// utf8_codecvt_facet.cpp
-
-// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
-// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
-// Use, modification and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// Please see the comments in <boost/detail/utf8_codecvt_facet.hpp> to
-// learn how this file should be used.
-
-#include <boost/detail/utf8_codecvt_facet.hpp>
-
-#include <cstdlib> // for multi-byte converson routines
-#include <cassert>
-
-#include <boost/limits.hpp>
-#include <boost/config.hpp>
-
-// If we don't have wstring, then Unicode support
-// is not available anyway, so we don't need to even
-// compiler this file. This also fixes the problem
-// with mingw, which can compile this file, but will
-// generate link error when building DLL.
-#ifndef BOOST_NO_STD_WSTRING
-
-BOOST_UTF8_BEGIN_NAMESPACE
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// implementation for wchar_t
-
-// Translate incoming UTF-8 into UCS-4
-std::codecvt_base::result utf8_codecvt_facet::do_in(
- std::mbstate_t& /*state*/,
- const char * from,
- const char * from_end,
- const char * & from_next,
- wchar_t * to,
- wchar_t * to_end,
- wchar_t * & to_next
-) const {
- // Basic algorithm: The first octet determines how many
- // octets total make up the UCS-4 character. The remaining
- // "continuing octets" all begin with "10". To convert, subtract
- // the amount that specifies the number of octets from the first
- // octet. Subtract 0x80 (1000 0000) from each continuing octet,
- // then mash the whole lot together. Note that each continuing
- // octet only uses 6 bits as unique values, so only shift by
- // multiples of 6 to combine.
- while (from != from_end && to != to_end) {
-
- // Error checking on the first octet
- if (invalid_leading_octet(*from)){
- from_next = from;
- to_next = to;
- return std::codecvt_base::error;
- }
-
- // The first octet is adjusted by a value dependent upon
- // the number of "continuing octets" encoding the character
- const int cont_octet_count = get_cont_octet_count(*from);
- const wchar_t octet1_modifier_table[] = {
- 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
- };
-
- // The unsigned char conversion is necessary in case char is
- // signed (I learned this the hard way)
- wchar_t ucs_result =
- (unsigned char)(*from++) - octet1_modifier_table[cont_octet_count];
-
- // Invariants :
- // 1) At the start of the loop, 'i' continuing characters have been
- // processed
- // 2) *from points to the next continuing character to be processed.
- int i = 0;
- while(i != cont_octet_count && from != from_end) {
-
- // Error checking on continuing characters
- if (invalid_continuing_octet(*from)) {
- from_next = from;
- to_next = to;
- return std::codecvt_base::error;
- }
-
- ucs_result *= (1 << 6);
-
- // each continuing character has an extra (10xxxxxx)b attached to
- // it that must be removed.
- ucs_result += (unsigned char)(*from++) - 0x80;
- ++i;
- }
-
- // If the buffer ends with an incomplete unicode character...
- if (from == from_end && i != cont_octet_count) {
- // rewind "from" to before the current character translation
- from_next = from - (i+1);
- to_next = to;
- return std::codecvt_base::partial;
- }
- *to++ = ucs_result;
- }
- from_next = from;
- to_next = to;
-
- // Were we done converting or did we run out of destination space?
- if(from == from_end) return std::codecvt_base::ok;
- else return std::codecvt_base::partial;
-}
-
-std::codecvt_base::result utf8_codecvt_facet::do_out(
- std::mbstate_t& /*state*/,
- const wchar_t * from,
- const wchar_t * from_end,
- const wchar_t * & from_next,
- char * to,
- char * to_end,
- char * & to_next
-) const
-{
- // RG - consider merging this table with the other one
- const wchar_t octet1_modifier_table[] = {
- 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
- };
-
- wchar_t max_wchar = (std::numeric_limits<wchar_t>::max)();
- while (from != from_end && to != to_end) {
-
- // Check for invalid UCS-4 character
- if (*from > max_wchar) {
- from_next = from;
- to_next = to;
- return std::codecvt_base::error;
- }
-
- int cont_octet_count = get_cont_octet_out_count(*from);
-
- // RG - comment this formula better
- int shift_exponent = (cont_octet_count) * 6;
-
- // Process the first character
- *to++ = static_cast<char>(octet1_modifier_table[cont_octet_count] +
- (unsigned char)(*from / (1 << shift_exponent)));
-
- // Process the continuation characters
- // Invariants: At the start of the loop:
- // 1) 'i' continuing octets have been generated
- // 2) '*to' points to the next location to place an octet
- // 3) shift_exponent is 6 more than needed for the next octet
- int i = 0;
- while (i != cont_octet_count && to != to_end) {
- shift_exponent -= 6;
- *to++ = static_cast<char>(0x80 + ((*from / (1 << shift_exponent)) % (1 << 6)));
- ++i;
- }
- // If we filled up the out buffer before encoding the character
- if(to == to_end && i != cont_octet_count) {
- from_next = from;
- to_next = to - (i+1);
- return std::codecvt_base::partial;
- }
- ++from;
- }
- from_next = from;
- to_next = to;
- // Were we done or did we run out of destination space
- if(from == from_end) return std::codecvt_base::ok;
- else return std::codecvt_base::partial;
-}
-
-// How many char objects can I process to get <= max_limit
-// wchar_t objects?
-int utf8_codecvt_facet::do_length(
- BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &,
- const char * from,
- const char * from_end,
- std::size_t max_limit
-#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
-) const throw()
-#else
-) const
-#endif
-{
- // RG - this code is confusing! I need a better way to express it.
- // and test cases.
-
- // Invariants:
- // 1) last_octet_count has the size of the last measured character
- // 2) char_count holds the number of characters shown to fit
- // within the bounds so far (no greater than max_limit)
- // 3) from_next points to the octet 'last_octet_count' before the
- // last measured character.
- int last_octet_count=0;
- std::size_t char_count = 0;
- const char* from_next = from;
- // Use "<" because the buffer may represent incomplete characters
- while (from_next+last_octet_count <= from_end && char_count <= max_limit) {
- from_next += last_octet_count;
- last_octet_count = (get_octet_count(*from_next));
- ++char_count;
- }
- return static_cast<int>(from_next-from_end);
-}
-
-unsigned int utf8_codecvt_facet::get_octet_count(
- unsigned char lead_octet
-){
- // if the 0-bit (MSB) is 0, then 1 character
- if (lead_octet <= 0x7f) return 1;
-
- // Otherwise the count number of consecutive 1 bits starting at MSB
-// assert(0xc0 <= lead_octet && lead_octet <= 0xfd);
-
- if (0xc0 <= lead_octet && lead_octet <= 0xdf) return 2;
- else if (0xe0 <= lead_octet && lead_octet <= 0xef) return 3;
- else if (0xf0 <= lead_octet && lead_octet <= 0xf7) return 4;
- else if (0xf8 <= lead_octet && lead_octet <= 0xfb) return 5;
- else return 6;
-}
-BOOST_UTF8_END_NAMESPACE
-
-namespace {
-template<std::size_t s>
-int get_cont_octet_out_count_impl(wchar_t word){
- if (word < 0x80) {
- return 0;
- }
- if (word < 0x800) {
- return 1;
- }
- return 2;
-}
-
-template<>
-int get_cont_octet_out_count_impl<4>(wchar_t word){
- if (word < 0x80) {
- return 0;
- }
- if (word < 0x800) {
- return 1;
- }
-
- // Note that the following code will generate warnings on some platforms
- // where wchar_t is defined as UCS2. The warnings are superfluous as the
- // specialization is never instantitiated with such compilers, but this
- // can cause problems if warnings are being treated as errors, so we guard
- // against that. Including <boost/detail/utf8_codecvt_facet.hpp> as we do
- // should be enough to get WCHAR_MAX defined.
-#if !defined(WCHAR_MAX)
-# error WCHAR_MAX not defined!
-#endif
- // cope with VC++ 7.1 or earlier having invalid WCHAR_MAX
-#if defined(_MSC_VER) && _MSC_VER <= 1310 // 7.1 or earlier
- return 2;
-#elif WCHAR_MAX > 0x10000
-
- if (word < 0x10000) {
- return 2;
- }
- if (word < 0x200000) {
- return 3;
- }
- if (word < 0x4000000) {
- return 4;
- }
- return 5;
-
-#else
- return 2;
-#endif
-}
-
-} // namespace anonymous
-
-BOOST_UTF8_BEGIN_NAMESPACE
-// How many "continuing octets" will be needed for this word
-// == total octets - 1.
-int utf8_codecvt_facet::get_cont_octet_out_count(
- wchar_t word
-) const {
- return get_cont_octet_out_count_impl<sizeof(wchar_t)>(word);
-}
-BOOST_UTF8_END_NAMESPACE
-
-#endif
diff --git a/3rdParty/Boost/src/libs/exception/build/Jamfile.v2 b/3rdParty/Boost/src/libs/exception/build/Jamfile.v2
new file mode 100644
index 0000000..fb47659
--- /dev/null
+++ b/3rdParty/Boost/src/libs/exception/build/Jamfile.v2
@@ -0,0 +1,14 @@
+# Boost Exception Library build Jamfile
+#
+# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+project boost/exception
+ : source-location ../src
+ : requirements <link>static
+ ;
+
+lib boost_exception : clone_current_exception_non_intrusive.cpp ;
+boost-install boost_exception ;
diff --git a/3rdParty/Boost/src/libs/exception/src/clone_current_exception_non_intrusive.cpp b/3rdParty/Boost/src/libs/exception/src/clone_current_exception_non_intrusive.cpp
new file mode 100644
index 0000000..1710cd7
--- /dev/null
+++ b/3rdParty/Boost/src/libs/exception/src/clone_current_exception_non_intrusive.cpp
@@ -0,0 +1,320 @@
+//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+
+//Distributed under the Boost Software License, Version 1.0. (See accompanying
+//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+//This MSVC-specific cpp file implements non-intrusive cloning of exception objects.
+//Based on an exception_ptr implementation by Anthony Williams.
+
+#ifdef BOOST_NO_EXCEPTIONS
+#error This file requires exception handling to be enabled.
+#endif
+
+#include <boost/exception/detail/clone_current_exception.hpp>
+
+#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && defined(_M_IX86) && !defined(_M_X64)
+
+//Non-intrusive cloning support implemented below, only for MSVC versions mentioned above.
+//Thanks Anthony Williams!
+
+#include <boost/exception/exception.hpp>
+#include <boost/shared_ptr.hpp>
+#ifndef BOOST_NO_RTTI
+#include <typeinfo>
+#endif
+#include <windows.h>
+#include <malloc.h>
+
+namespace
+ {
+ unsigned const exception_maximum_parameters=15;
+ unsigned const exception_noncontinuable=1;
+
+#if _MSC_VER==1310
+ int const exception_info_offset=0x74;
+#elif (_MSC_VER==1400 || _MSC_VER==1500)
+ int const exception_info_offset=0x80;
+#else
+ int const exception_info_offset=-1;
+#endif
+
+ struct
+ exception_record
+ {
+ unsigned long ExceptionCode;
+ unsigned long ExceptionFlags;
+ exception_record * ExceptionRecord;
+ void * ExceptionAddress;
+ unsigned long NumberParameters;
+ ULONG_PTR ExceptionInformation[exception_maximum_parameters];
+ };
+
+ struct
+ exception_pointers
+ {
+ exception_record * ExceptionRecord;
+ void * ContextRecord;
+ };
+
+ unsigned const cpp_exception_code=0xE06D7363;
+ unsigned const cpp_exception_magic_flag=0x19930520;
+ unsigned const cpp_exception_parameter_count=3;
+
+ struct
+ dummy_exception_type
+ {
+ };
+
+ typedef int(dummy_exception_type::*normal_copy_constructor_ptr)(void * src);
+ typedef int(dummy_exception_type::*copy_constructor_with_virtual_base_ptr)(void * src,void * dst);
+ typedef void (dummy_exception_type::*destructor_ptr)();
+
+ union
+ cpp_copy_constructor
+ {
+ normal_copy_constructor_ptr normal_copy_constructor;
+ copy_constructor_with_virtual_base_ptr copy_constructor_with_virtual_base;
+ };
+
+ enum
+ cpp_type_flags
+ {
+ class_is_simple_type=1,
+ class_has_virtual_base=4
+ };
+
+ struct
+ cpp_type_info
+ {
+ unsigned flags;
+#ifndef BOOST_NO_RTTI
+ void const * type_info;
+#else
+ std::type_info * type_info;
+#endif
+ int this_offset;
+ int vbase_descr;
+ int vbase_offset;
+ unsigned long size;
+ cpp_copy_constructor copy_constructor;
+ };
+
+ struct
+ cpp_type_info_table
+ {
+ unsigned count;
+ const cpp_type_info * info[1];
+ };
+
+ struct
+ cpp_exception_type
+ {
+ unsigned flags;
+ destructor_ptr destructor;
+ void(*custom_handler)();
+ cpp_type_info_table const * type_info_table;
+ };
+
+ struct
+ exception_object_deleter
+ {
+ cpp_exception_type const & et_;
+
+ exception_object_deleter( cpp_exception_type const & et ):
+ et_(et)
+ {
+ }
+
+ void
+ operator()( void * obj )
+ {
+ BOOST_ASSERT(obj!=0);
+ dummy_exception_type * dummy_exception_ptr=reinterpret_cast<dummy_exception_type *>(obj);
+ (dummy_exception_ptr->*(et_.destructor))();
+ free(obj);
+ }
+ };
+
+ cpp_type_info const &
+ get_cpp_type_info( cpp_exception_type const & et )
+ {
+ cpp_type_info const * ti = et.type_info_table->info[0];
+ BOOST_ASSERT(ti!=0);
+ return *ti;
+ }
+
+ void
+ copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti )
+ {
+ if( !(ti.flags & class_is_simple_type) && ti.copy_constructor.normal_copy_constructor )
+ {
+ dummy_exception_type * dummy_exception_ptr = reinterpret_cast<dummy_exception_type *>(dst);
+ if( ti.flags & class_has_virtual_base )
+ (dummy_exception_ptr->*(ti.copy_constructor.copy_constructor_with_virtual_base))(src,dst);
+ else
+ (dummy_exception_ptr->*(ti.copy_constructor.normal_copy_constructor))(src);
+ }
+ else
+ memmove(dst,src,ti.size);
+ }
+
+ boost::shared_ptr<void>
+ clone_msvc_exception( void * src, cpp_exception_type const & et )
+ {
+ assert(src!=0);
+ cpp_type_info const & ti=get_cpp_type_info(et);
+ if( void * dst = malloc(ti.size) )
+ {
+ try
+ {
+ copy_msvc_exception(dst,src,ti);
+ }
+ catch(
+ ... )
+ {
+ free(dst);
+ throw;
+ }
+ return boost::shared_ptr<void>(dst,exception_object_deleter(et));
+ }
+ else
+ throw std::bad_alloc();
+ }
+
+ class
+ cloned_exception:
+ public boost::exception_detail::clone_base
+ {
+ cloned_exception( cloned_exception const & );
+ cloned_exception & operator=( cloned_exception const & );
+
+ cpp_exception_type const & et_;
+ boost::shared_ptr<void> exc_;
+
+ public:
+
+ cloned_exception( void * exc, cpp_exception_type const & et ):
+ et_(et),
+ exc_(clone_msvc_exception(exc,et_))
+ {
+ }
+
+ ~cloned_exception() throw()
+ {
+ }
+
+ boost::exception_detail::clone_base const *
+ clone() const
+ {
+ return new cloned_exception(exc_.get(),et_);
+ }
+
+ void
+ rethrow() const
+ {
+ cpp_type_info const & ti=get_cpp_type_info(et_);
+ void * dst = _alloca(ti.size);
+ copy_msvc_exception(dst,exc_.get(),ti);
+ ULONG_PTR args[cpp_exception_parameter_count];
+ args[0]=cpp_exception_magic_flag;
+ args[1]=reinterpret_cast<ULONG_PTR>(dst);
+ args[2]=reinterpret_cast<ULONG_PTR>(&et_);
+ RaiseException(cpp_exception_code,EXCEPTION_NONCONTINUABLE,cpp_exception_parameter_count,args);
+ }
+ };
+
+ bool
+ is_cpp_exception( EXCEPTION_RECORD const * record )
+ {
+ return record &&
+ (record->ExceptionCode==cpp_exception_code) &&
+ (record->NumberParameters==cpp_exception_parameter_count) &&
+ (record->ExceptionInformation[0]==cpp_exception_magic_flag);
+ }
+
+ unsigned long
+ exception_cloning_filter( int & result, boost::exception_detail::clone_base const * & ptr, void * info_ )
+ {
+ BOOST_ASSERT(exception_info_offset>=0);
+ BOOST_ASSERT(info_!=0);
+ EXCEPTION_POINTERS * info=reinterpret_cast<EXCEPTION_POINTERS *>(info_);
+ EXCEPTION_RECORD * record=info->ExceptionRecord;
+ if( is_cpp_exception(record) )
+ {
+ if( !record->ExceptionInformation[2] )
+ record = *reinterpret_cast<EXCEPTION_RECORD * *>(reinterpret_cast<char *>(_errno())+exception_info_offset);
+ if( is_cpp_exception(record) && record->ExceptionInformation[2] )
+ try
+ {
+ ptr = new cloned_exception(
+ reinterpret_cast<void *>(record->ExceptionInformation[1]),
+ *reinterpret_cast<cpp_exception_type const *>(record->ExceptionInformation[2]));
+ result = boost::exception_detail::clone_current_exception_result::success;
+ }
+ catch(
+ std::bad_alloc & )
+ {
+ result = boost::exception_detail::clone_current_exception_result::bad_alloc;
+ }
+ catch(
+ ... )
+ {
+ result = boost::exception_detail::clone_current_exception_result::bad_exception;
+ }
+ }
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+ }
+
+namespace
+boost
+ {
+ namespace
+ exception_detail
+ {
+ int
+ clone_current_exception_non_intrusive( clone_base const * & cloned )
+ {
+ BOOST_ASSERT(!cloned);
+ int result = clone_current_exception_result::not_supported;
+ if( exception_info_offset>=0 )
+ {
+ clone_base const * ptr=0;
+ __try
+ {
+ throw;
+ }
+ __except(exception_cloning_filter(result,ptr,GetExceptionInformation()))
+ {
+ }
+ if( result==clone_current_exception_result::success )
+ cloned=ptr;
+ }
+ BOOST_ASSERT(result!=clone_current_exception_result::success || cloned);
+ return result;
+ }
+ }
+ }
+
+#else
+
+//On all other compilers, return clone_current_exception_result::not_supported.
+//On such platforms, only the intrusive enable_current_exception() cloning will work.
+
+#include <boost/config.hpp>
+
+namespace
+boost
+ {
+ namespace
+ exception_detail
+ {
+ int
+ clone_current_exception_non_intrusive( clone_base const * & )
+ {
+ return clone_current_exception_result::not_supported;
+ }
+ }
+ }
+
+#endif
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/codecvt_error_category.cpp b/3rdParty/Boost/src/libs/filesystem/src/codecvt_error_category.cpp
index b35b4a9..245c3f3 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/codecvt_error_category.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/codecvt_error_category.cpp
@@ -9,13 +9,6 @@
//--------------------------------------------------------------------------------------//
-#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
-
#include <boost/config/warning_disable.hpp>
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
@@ -26,8 +19,8 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
-#include <boost/filesystem/v3/config.hpp>
-#include <boost/filesystem/v3/path_traits.hpp>
+#include <boost/filesystem/config.hpp>
+#include <boost/filesystem/path_traits.hpp>
#include <boost/system/error_code.hpp>
#include <locale>
#include <vector>
@@ -78,7 +71,7 @@ namespace
namespace boost
{
- namespace filesystem3
+ namespace filesystem
{
BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
@@ -87,7 +80,5 @@ namespace boost
return codecvt_error_cat_const;
}
- } // namespace filesystem3
+ } // namespace filesystem
} // namespace boost
-
-#endif // no wide character support
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/filesystem_utf8_codecvt_facet.cpp b/3rdParty/Boost/src/libs/filesystem/src/filesystem_utf8_codecvt_facet.cpp
index 1849a1a..8a5af1e 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/filesystem_utf8_codecvt_facet.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/filesystem_utf8_codecvt_facet.cpp
@@ -3,6 +3,10 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
+// For HP-UX, request that WCHAR_MAX and WCHAR_MIN be defined as macros,
+// not casts. See ticket 5048
+#define _INCLUDE_STDCSOURCE_199901
+
#ifndef BOOST_SYSTEM_NO_DEPRECATED
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
@@ -16,7 +20,7 @@
#define BOOST_UTF8_END_NAMESPACE }}}
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
-#include "libs/detail/utf8_codecvt_facet.cpp"
+#include <boost/detail/utf8_codecvt_facet.ipp>
#undef BOOST_UTF8_BEGIN_NAMESPACE
#undef BOOST_UTF8_END_NAMESPACE
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/operations.cpp b/3rdParty/Boost/src/libs/filesystem/src/operations.cpp
index 2460c1d..16a336f 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/operations.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/operations.cpp
@@ -10,28 +10,8 @@
//--------------------------------------------------------------------------------------//
-#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
-
-// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
-// the library is being built (possibly exporting rather than importing code)
-
-#define BOOST_FILESYSTEM_SOURCE
-
-#ifndef BOOST_SYSTEM_NO_DEPRECATED
-# define BOOST_SYSTEM_NO_DEPRECATED
-#endif
-
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS // Sun readdir_r()needs this
-#endif
-
-#if !(defined(__HP_aCC) && defined(_ILP32) && \
- !defined(_STATVFS_ACPP_PROBLEMS_FIXED))
+// define 64-bit offset macros BEFORE including boost/config.hpp (see ticket #5355)
+#if !(defined(__HP_aCC) && defined(_ILP32) && !defined(_STATVFS_ACPP_PROBLEMS_FIXED))
#define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect,
#endif
#if !defined(__PGI)
@@ -49,19 +29,38 @@
#define _FILE_OFFSET_BITS 64
#endif
-#include <boost/filesystem/v3/operations.hpp>
+// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_FILESYSTEM_SOURCE
+
+#ifndef BOOST_SYSTEM_NO_DEPRECATED
+# define BOOST_SYSTEM_NO_DEPRECATED
+#endif
+
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS // Sun readdir_r()needs this
+#endif
+
+#include <boost/filesystem/operations.hpp>
#include <boost/scoped_array.hpp>
#include <boost/detail/workaround.hpp>
-#include <cstdlib> // for malloc, free
-#include <vector>
+#include <vector>
+#include <cstdlib> // for malloc, free
+#include <cstring>
+#include <cstdio> // for remove, rename
+#if defined(__QNXNTO__) // see ticket #5355
+# include <stdio.h>
+#endif
+#include <cerrno>
#ifdef BOOST_FILEYSTEM_INCLUDE_IOSTREAM
# include <iostream>
#endif
-namespace fs = boost::filesystem3;
-using boost::filesystem3::path;
-using boost::filesystem3::filesystem_error;
+namespace fs = boost::filesystem;
+using boost::filesystem::path;
+using boost::filesystem::filesystem_error;
+using boost::filesystem::perms;
using boost::system::error_code;
using boost::system::error_category;
using boost::system::system_category;
@@ -70,7 +69,10 @@ using std::wstring;
# ifdef BOOST_POSIX_API
+ const fs::path dot_path(".");
+ const fs::path dot_dot_path("..");
# include <sys/types.h>
+# include <sys/stat.h>
# if !defined(__APPLE__) && !defined(__OpenBSD__)
# include <sys/statvfs.h>
# define BOOST_STATVFS statvfs
@@ -91,11 +93,14 @@ using std::wstring;
# else // BOOST_WINDOW_API
+ const fs::path dot_path(L".");
+ const fs::path dot_dot_path(L"..");
# if (defined(__MINGW32__) || defined(__CYGWIN__)) && !defined(WINVER)
// Versions of MinGW or Cygwin that support Filesystem V3 support at least WINVER 0x501.
// See MinGW's windef.h
# define WINVER 0x501
# endif
+# include <io.h>
# include <windows.h>
# include <winnt.h>
# if !defined(_WIN32_WINNT)
@@ -178,14 +183,6 @@ typedef struct _REPARSE_DATA_BUFFER {
# define BOOST_FILESYSTEM_STATUS_CACHE
# endif
-#include <sys/stat.h> // even on Windows some functions use stat()
-#include <string>
-#include <cstring>
-#include <cstdio> // for remove, rename
-#include <cerrno>
-#include <cassert>
-// #include <iostream> // for debugging only; comment out when not in use
-
// POSIX/Windows macros ----------------------------------------------------//
// Portions of the POSIX and Windows API's are very similar, except for name,
@@ -226,7 +223,7 @@ typedef struct _REPARSE_DATA_BUFFER {
# define BOOST_DELETE_FILE(P)(::DeleteFileW(P)!= 0)
# define BOOST_COPY_DIRECTORY(F,T)(::CreateDirectoryExW(F, T, 0)!= 0)
# define BOOST_COPY_FILE(F,T,FailIfExistsBool)(::CopyFileW(F, T, FailIfExistsBool)!= 0)
-# define BOOST_MOVE_FILE(OLD,NEW)(::MoveFileExW(OLD, NEW, MOVEFILE_REPLACE_EXISTING)!= 0)
+# define BOOST_MOVE_FILE(OLD,NEW)(::MoveFileExW(OLD, NEW, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED)!= 0)
# define BOOST_RESIZE_FILE(P,SZ)(resize_file_api(P, SZ)!= 0)
# define BOOST_READ_SYMLINK(P,T)
@@ -244,15 +241,9 @@ typedef struct _REPARSE_DATA_BUFFER {
namespace
{
-# ifdef BOOST_POSIX_API
- const char dot = '.';
-# else
- const wchar_t dot = L'.';
-# endif
-
fs::file_type query_file_type(const path& p, error_code* ec);
- boost::filesystem3::directory_iterator end_dir_itr;
+ boost::filesystem::directory_iterator end_dir_itr;
const std::size_t buf_size(128);
const error_code ok;
@@ -411,6 +402,8 @@ namespace
// //
//--------------------------------------------------------------------------------------//
+ const char dot = '.';
+
bool not_found_error(int errval)
{
return errno == ENOENT || errno == ENOTDIR;
@@ -432,7 +425,10 @@ namespace
struct stat from_stat;
if (::stat(from_p.c_str(), &from_stat)!= 0)
- { return false; }
+ {
+ ::close(infile);
+ return false;
+ }
int oflag = O_CREAT | O_WRONLY | O_TRUNC;
if (fail_if_exists)
@@ -484,6 +480,8 @@ namespace
// //
//--------------------------------------------------------------------------------------//
+ const wchar_t dot = L'.';
+
bool not_found_error(int errval)
{
return errval == ERROR_FILE_NOT_FOUND
@@ -496,6 +494,28 @@ namespace
|| errval == ERROR_BAD_NETPATH; // "//nosuch" on Win32
}
+// some distributions of mingw as early as GLIBCXX__ 20110325 have _stricmp, but the
+// offical 4.6.2 release with __GLIBCXX__ 20111026 doesn't. Play it safe for now, and
+// only use _stricmp if _MSC_VER is defined
+#if defined(_MSC_VER) // || (defined(__GLIBCXX__) && __GLIBCXX__ >= 20110325)
+# define BOOST_FILESYSTEM_STRICMP _stricmp
+#else
+# define BOOST_FILESYSTEM_STRICMP strcmp
+#endif
+
+ perms make_permissions(const path& p, DWORD attr)
+ {
+ perms prms = fs::owner_read | fs::group_read | fs::others_read;
+ if ((attr & FILE_ATTRIBUTE_READONLY) == 0)
+ prms |= fs::owner_write | fs::group_write | fs::others_write;
+ if (BOOST_FILESYSTEM_STRICMP(p.extension().string().c_str(), ".exe") == 0
+ || BOOST_FILESYSTEM_STRICMP(p.extension().string().c_str(), ".com") == 0
+ || BOOST_FILESYSTEM_STRICMP(p.extension().string().c_str(), ".bat") == 0
+ || BOOST_FILESYSTEM_STRICMP(p.extension().string().c_str(), ".cmd") == 0)
+ prms |= fs::owner_exe | fs::group_exe | fs::others_exe;
+ return prms;
+ }
+
// these constants come from inspecting some Microsoft sample code
std::time_t to_time_t(const FILETIME & ft)
{
@@ -584,7 +604,7 @@ namespace
if (not_found_error(errval))
{
- return fs::file_status(fs::file_not_found);
+ return fs::file_status(fs::file_not_found, fs::no_perms);
}
else if ((errval == ERROR_SHARING_VIOLATION))
{
@@ -679,7 +699,7 @@ namespace
namespace boost
{
-namespace filesystem3
+namespace filesystem
{
BOOST_FILESYSTEM_DECL
@@ -750,6 +770,86 @@ namespace detail
}
BOOST_FILESYSTEM_DECL
+ path canonical(const path& p, const path& base, system::error_code* ec)
+ {
+ path source (p.is_absolute() ? p : absolute(p, base));
+ path result;
+
+ system::error_code local_ec;
+ file_status stat (status(source, local_ec));
+
+ if (stat.type() == fs::file_not_found)
+ {
+ if (ec == 0)
+ BOOST_FILESYSTEM_THROW(filesystem_error(
+ "boost::filesystem::canonical", source,
+ error_code(system::errc::no_such_file_or_directory, system::generic_category())));
+ ec->assign(system::errc::no_such_file_or_directory, system::generic_category());
+ return result;
+ }
+ else if (local_ec)
+ {
+ if (ec == 0)
+ BOOST_FILESYSTEM_THROW(filesystem_error(
+ "boost::filesystem::canonical", source, local_ec));
+ *ec = local_ec;
+ return result;
+ }
+
+ bool scan (true);
+ while (scan)
+ {
+ scan = false;
+ result.clear();
+ for (path::iterator itr = source.begin(); itr != source.end(); ++itr)
+ {
+ if (*itr == dot_path)
+ continue;
+ if (*itr == dot_dot_path)
+ {
+ result.remove_filename();
+ continue;
+ }
+
+ result /= *itr;
+
+ bool is_sym (is_symlink(detail::symlink_status(result, ec)));
+ if (ec && *ec)
+ return path();
+
+ if (is_sym)
+ {
+ path link(detail::read_symlink(result, ec));
+ if (ec && *ec)
+ return path();
+ result.remove_filename();
+
+ if (link.is_absolute())
+ {
+ for (++itr; itr != source.end(); ++itr)
+ link /= *itr;
+ source = link;
+ }
+ else // link is relative
+ {
+ path new_source(result);
+ new_source /= link;
+ for (++itr; itr != source.end(); ++itr)
+ new_source /= *itr;
+ source = new_source;
+ }
+ scan = true; // symlink causes scan to be restarted
+ break;
+ }
+ }
+ }
+ if (ec != 0)
+ ec->clear();
+ BOOST_ASSERT_MSG(result.is_absolute(), "canonical() implementation error; please report");
+ return result;
+ }
+
+ BOOST_FILESYSTEM_DECL
void copy(const path& from, const path& to, system::error_code* ec)
{
file_status s(symlink_status(from, *ec));
@@ -813,27 +913,43 @@ namespace detail
# endif
}
- BOOST_FILESYSTEM_DECL
+ BOOST_FILESYSTEM_DECL
bool create_directories(const path& p, system::error_code* ec)
{
- if (p.empty() || exists(p))
+ error_code local_ec;
+ file_status p_status = status(p, local_ec);
+
+ if (p_status.type() == directory_file)
{
- if (!p.empty() && !is_directory(p))
+ if (ec != 0)
+ ec->clear();
+ return false;
+ }
+
+ path parent = p.parent_path();
+ if (!parent.empty())
+ {
+ // determine if the parent exists
+ file_status parent_status = status(parent, local_ec);
+
+ // if the parent does not exist, create the parent
+ if (parent_status.type() == file_not_found)
{
- if (ec == 0)
- BOOST_FILESYSTEM_THROW(filesystem_error(
- "boost::filesystem::create_directories", p,
- error_code(system::errc::file_exists, system::generic_category())));
- else ec->assign(system::errc::file_exists, system::generic_category());
+ create_directories(parent, local_ec);
+ if (local_ec)
+ {
+ if (ec == 0)
+ BOOST_FILESYSTEM_THROW(filesystem_error(
+ "boost::filesystem::create_directories", parent, local_ec));
+ else
+ *ec = local_ec;
+ return false;
+ }
}
- return false;
}
- // First create branch, by calling ourself recursively
- create_directories(p.parent_path(), ec);
- // Now that parent's path exists, create the directory
- create_directory(p, ec);
- return true;
+ // create the directory
+ return create_directory(p, ec);
}
BOOST_FILESYSTEM_DECL
@@ -841,7 +957,8 @@ namespace detail
{
if (BOOST_CREATE_DIRECTORY(p.c_str()))
{
- if (ec != 0) ec->clear();
+ if (ec != 0)
+ ec->clear();
return true;
}
@@ -850,7 +967,8 @@ namespace detail
error_code dummy;
if (errval == BOOST_ERROR_ALREADY_EXISTS && is_directory(p, dummy))
{
- if (ec != 0) ec->clear();
+ if (ec != 0)
+ ec->clear();
return false;
}
@@ -1243,6 +1361,94 @@ namespace detail
# endif
}
+# ifdef BOOST_POSIX_API
+ const perms active_bits(all_all | set_uid_on_exe | set_gid_on_exe | sticky_bit);
+ inline mode_t mode_cast(perms prms) { return prms & active_bits; }
+# endif
+
+ BOOST_FILESYSTEM_DECL
+ void permissions(const path& p, perms prms, system::error_code* ec)
+ {
+ BOOST_ASSERT_MSG(!((prms & add_perms) && (prms & remove_perms)),
+ "add_perms and remove_perms are mutually exclusive");
+
+ if ((prms & add_perms) && (prms & remove_perms)) // precondition failed
+ return;
+
+# ifdef BOOST_POSIX_API
+ error_code local_ec;
+ file_status current_status((prms & symlink_perms)
+ ? fs::symlink_status(p, local_ec)
+ : fs::status(p, local_ec));
+ if (local_ec)
+ {
+ if (ec == 0)
+ BOOST_FILESYSTEM_THROW(filesystem_error(
+ "boost::filesystem::permissions", p, local_ec));
+ else
+ *ec = local_ec;
+ return;
+ }
+
+ if (prms & add_perms)
+ prms |= current_status.permissions();
+ else if (prms & remove_perms)
+ prms = current_status.permissions() & ~prms;
+
+ // Mac OS X Lion and some other platforms don't support fchmodat().
+ // Solaris (SunPro and gcc) only support fchmodat() on Solaris 11 and higher,
+ // and a runtime check is too much trouble.
+ // Linux does not support permissions on symbolic links and has no plans to
+ // support them in the future. The chmod() code is thus more practical,
+ // rather than always hitting ENOTSUP when sending in AT_SYMLINK_NO_FOLLOW.
+ // - See the 3rd paragraph of
+ // "Symbolic link ownership, permissions, and timestamps" at:
+ // "http://man7.org/linux/man-pages/man7/symlink.7.html"
+ // - See the fchmodat() Linux man page:
+ // "http://man7.org/linux/man-pages/man2/fchmodat.2.html"
+# if defined(AT_FDCWD) && defined(AT_SYMLINK_NOFOLLOW) \
+ && !(defined(__SUNPRO_CC) || defined(sun)) \
+ && !(defined(linux) || defined(__linux) || defined(__linux__))
+ if (::fchmodat(AT_FDCWD, p.c_str(), mode_cast(prms),
+ !(prms & symlink_perms) ? 0 : AT_SYMLINK_NOFOLLOW))
+# else // fallback if fchmodat() not supported
+ if (::chmod(p.c_str(), mode_cast(prms)))
+# endif
+ {
+ if (ec == 0)
+ BOOST_FILESYSTEM_THROW(filesystem_error(
+ "boost::filesystem::permissions", p,
+ error_code(errno, system::generic_category())));
+ else
+ ec->assign(errno, system::generic_category());
+ }
+
+# else // Windows
+
+ // if not going to alter FILE_ATTRIBUTE_READONLY, just return
+ if (!(!((prms & (add_perms | remove_perms)))
+ || (prms & (owner_write|group_write|others_write))))
+ return;
+
+ DWORD attr = ::GetFileAttributesW(p.c_str());
+
+ if (error(attr == 0, p, ec, "boost::filesystem::permissions"))
+ return;
+
+ if (prms & add_perms)
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ else if (prms & remove_perms)
+ attr |= FILE_ATTRIBUTE_READONLY;
+ else if (prms & (owner_write|group_write|others_write))
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ else
+ attr |= FILE_ATTRIBUTE_READONLY;
+
+ error(::SetFileAttributesW(p.c_str(), attr) == 0,
+ p, ec, "boost::filesystem::permissions");
+# endif
+ }
+
BOOST_FILESYSTEM_DECL
path read_symlink(const path& p, system::error_code* ec)
{
@@ -1406,7 +1612,7 @@ namespace detail
if (not_found_error(errno))
{
- return fs::file_status(fs::file_not_found);
+ return fs::file_status(fs::file_not_found, fs::no_perms);
}
if (ec == 0)
BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::status",
@@ -1415,17 +1621,23 @@ namespace detail
}
if (ec != 0) ec->clear();;
if (S_ISDIR(path_stat.st_mode))
- return fs::file_status(fs::directory_file);
+ return fs::file_status(fs::directory_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISREG(path_stat.st_mode))
- return fs::file_status(fs::regular_file);
+ return fs::file_status(fs::regular_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISBLK(path_stat.st_mode))
- return fs::file_status(fs::block_file);
+ return fs::file_status(fs::block_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISCHR(path_stat.st_mode))
- return fs::file_status(fs::character_file);
+ return fs::file_status(fs::character_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISFIFO(path_stat.st_mode))
- return fs::file_status(fs::fifo_file);
+ return fs::file_status(fs::fifo_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISSOCK(path_stat.st_mode))
- return fs::file_status(fs::socket_file);
+ return fs::file_status(fs::socket_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
return fs::file_status(fs::type_unknown);
# else // Windows
@@ -1436,7 +1648,9 @@ namespace detail
return process_status_failure(p, ec);
}
- // reparse point handling
+ // reparse point handling;
+ // since GetFileAttributesW does not resolve symlinks, try to open a file
+ // handle to discover if the file exists
if (attr & FILE_ATTRIBUTE_REPARSE_POINT)
{
handle_wrapper h(
@@ -1454,13 +1668,13 @@ namespace detail
}
if (!is_reparse_point_a_symlink(p))
- return file_status(reparse_file);
+ return file_status(reparse_file, make_permissions(p, attr));
}
if (ec != 0) ec->clear();
return (attr & FILE_ATTRIBUTE_DIRECTORY)
- ? file_status(directory_file)
- : file_status(regular_file);
+ ? file_status(directory_file, make_permissions(p, attr))
+ : file_status(regular_file, make_permissions(p, attr));
# endif
}
@@ -1478,7 +1692,7 @@ namespace detail
if (errno == ENOENT || errno == ENOTDIR) // these are not errors
{
- return fs::file_status(fs::file_not_found);
+ return fs::file_status(fs::file_not_found, fs::no_perms);
}
if (ec == 0)
BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::status",
@@ -1487,19 +1701,26 @@ namespace detail
}
if (ec != 0) ec->clear();
if (S_ISREG(path_stat.st_mode))
- return fs::file_status(fs::regular_file);
+ return fs::file_status(fs::regular_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISDIR(path_stat.st_mode))
- return fs::file_status(fs::directory_file);
+ return fs::file_status(fs::directory_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISLNK(path_stat.st_mode))
- return fs::file_status(fs::symlink_file);
+ return fs::file_status(fs::symlink_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISBLK(path_stat.st_mode))
- return fs::file_status(fs::block_file);
+ return fs::file_status(fs::block_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISCHR(path_stat.st_mode))
- return fs::file_status(fs::character_file);
+ return fs::file_status(fs::character_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISFIFO(path_stat.st_mode))
- return fs::file_status(fs::fifo_file);
+ return fs::file_status(fs::fifo_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
if (S_ISSOCK(path_stat.st_mode))
- return fs::file_status(fs::socket_file);
+ return fs::file_status(fs::socket_file,
+ static_cast<perms>(path_stat.st_mode) & fs::perms_mask);
return fs::file_status(fs::type_unknown);
# else // Windows
@@ -1514,12 +1735,12 @@ namespace detail
if (attr & FILE_ATTRIBUTE_REPARSE_POINT)
return is_reparse_point_a_symlink(p)
- ? file_status(symlink_file)
- : file_status(reparse_file);
+ ? file_status(symlink_file, make_permissions(p, attr))
+ : file_status(reparse_file, make_permissions(p, attr));
return (attr & FILE_ATTRIBUTE_DIRECTORY)
- ? file_status(directory_file)
- : file_status(regular_file);
+ ? file_status(directory_file, make_permissions(p, attr))
+ : file_status(regular_file, make_permissions(p, attr));
# endif
}
@@ -1660,7 +1881,7 @@ namespace path_traits
}
} // namespace path_traits
-} // namespace filesystem3
+} // namespace filesystem
} // namespace boost
//--------------------------------------------------------------------------------------//
@@ -1752,8 +1973,8 @@ namespace
dirent * entry(static_cast<dirent *>(buffer));
dirent * result;
int return_code;
- if ((return_code = readdir_r_simulator(static_cast<DIR*>(handle),
- entry, &result))!= 0)return error_code(errno, system_category());
+ if ((return_code = readdir_r_simulator(static_cast<DIR*>(handle), entry, &result))!= 0)
+ return error_code(errno, system_category());
if (result == 0)
return fs::detail::dir_itr_close(handle, buffer);
target = entry->d_name;
@@ -1800,7 +2021,7 @@ namespace
if ((handle = ::FindFirstFileW(dirpath.c_str(), &data))
== INVALID_HANDLE_VALUE)
{
- handle = 0;
+ handle = 0; // signal eof
return error_code( (::GetLastError() == ERROR_FILE_NOT_FOUND
// Windows Mobile returns ERROR_NO_MORE_FILES; see ticket #3551
|| ::GetLastError() == ERROR_NO_MORE_FILES)
@@ -1808,12 +2029,28 @@ namespace
}
target = data.cFileName;
if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
- // reparse points are complex, so don't try to handle them here
- { sf.type(fs::status_error); symlink_sf.type(fs::status_error); }
- else if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- { sf.type(fs::directory_file); symlink_sf.type(fs::directory_file); }
+ // reparse points are complex, so don't try to handle them here; instead just mark
+ // them as status_error which causes directory_entry caching to call status()
+ // and symlink_status() which do handle reparse points fully
+ {
+ sf.type(fs::status_error);
+ symlink_sf.type(fs::status_error);
+ }
else
- { sf.type(fs::regular_file); symlink_sf.type(fs::regular_file); }
+ {
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ sf.type(fs::directory_file);
+ symlink_sf.type(fs::directory_file);
+ }
+ else
+ {
+ sf.type(fs::regular_file);
+ symlink_sf.type(fs::regular_file);
+ }
+ sf.permissions(make_permissions(data.cFileName, data.dwFileAttributes));
+ symlink_sf.permissions(sf.permissions());
+ }
return error_code();
}
@@ -1829,12 +2066,28 @@ namespace
}
target = data.cFileName;
if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
- // reparse points are complex, so don't try to handle them here
- { sf.type(fs::status_error); symlink_sf.type(fs::status_error); }
- else if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- { sf.type(fs::directory_file); symlink_sf.type(fs::directory_file); }
+ // reparse points are complex, so don't try to handle them here; instead just mark
+ // them as status_error which causes directory_entry caching to call status()
+ // and symlink_status() which do handle reparse points fully
+ {
+ sf.type(fs::status_error);
+ symlink_sf.type(fs::status_error);
+ }
else
- { sf.type(fs::regular_file); symlink_sf.type(fs::regular_file); }
+ {
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ sf.type(fs::directory_file);
+ symlink_sf.type(fs::directory_file);
+ }
+ else
+ {
+ sf.type(fs::regular_file);
+ symlink_sf.type(fs::regular_file);
+ }
+ sf.permissions(make_permissions(data.cFileName, data.dwFileAttributes));
+ symlink_sf.permissions(sf.permissions());
+ }
return error_code();
}
#endif
@@ -1851,7 +2104,7 @@ namespace
namespace boost
{
-namespace filesystem3
+namespace filesystem
{
namespace detail
@@ -1889,7 +2142,8 @@ namespace detail
const path& p, system::error_code* ec)
{
if (error(p.empty(), not_found_error_code, p, ec,
- "boost::filesystem::directory_iterator::construct"))return;
+ "boost::filesystem::directory_iterator::construct"))
+ return;
path::string_type filename;
file_status file_stat, symlink_file_stat;
@@ -1907,24 +2161,24 @@ namespace detail
return;
}
- if (it.m_imp->handle == 0)it.m_imp.reset(); // eof, so make end iterator
+ if (it.m_imp->handle == 0)
+ it.m_imp.reset(); // eof, so make end iterator
else // not eof
{
- it.m_imp->dir_entry.assign(p / filename,
- file_stat, symlink_file_stat);
+ it.m_imp->dir_entry.assign(p / filename, file_stat, symlink_file_stat);
if (filename[0] == dot // dot or dot-dot
&& (filename.size()== 1
|| (filename[1] == dot
&& filename.size()== 2)))
- { it.increment(); }
+ { it.increment(*ec); }
}
}
void directory_iterator_increment(directory_iterator& it,
system::error_code* ec)
{
- BOOST_ASSERT(it.m_imp.get() && "attempt to increment end iterator");
- BOOST_ASSERT(it.m_imp->handle != 0 && "internal program error");
+ BOOST_ASSERT_MSG(it.m_imp.get(), "attempt to increment end iterator");
+ BOOST_ASSERT_MSG(it.m_imp->handle != 0, "internal program error");
path::string_type filename;
file_status file_stat, symlink_file_stat;
@@ -1938,13 +2192,14 @@ namespace detail
# endif
filename, file_stat, symlink_file_stat);
- if (temp_ec)
+ if (temp_ec) // happens if filesystem is corrupt, such as on a damaged optical disc
{
+ path error_path(it.m_imp->dir_entry.path().parent_path()); // fix ticket #5900
it.m_imp.reset();
if (ec == 0)
BOOST_FILESYSTEM_THROW(
filesystem_error("boost::filesystem::directory_iterator::operator++",
- it.m_imp->dir_entry.path().parent_path(),
+ error_path,
error_code(BOOST_ERRNO, system_category())));
ec->assign(BOOST_ERRNO, system_category());
return;
@@ -1969,7 +2224,5 @@ namespace detail
}
}
} // namespace detail
-} // namespace filesystem3
+} // namespace filesystem
} // namespace boost
-
-#endif // no wide character support
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/path.cpp b/3rdParty/Boost/src/libs/filesystem/src/path.cpp
index cc30570..c740dec 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/path.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/path.cpp
@@ -7,12 +7,12 @@
// Library home page: http://www.boost.org/libs/filesystem
+// Old standard library configurations, particularly MingGW, don't support wide strings.
+// Report this with an explicit error message.
#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
+# if defined( BOOST_NO_STD_WSTRING )
+# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
+# endif
// define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
@@ -22,8 +22,8 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
-#include <boost/filesystem/v3/config.hpp>
-#include <boost/filesystem/v3/path.hpp>
+#include <boost/filesystem/config.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/scoped_array.hpp>
#include <boost/system/error_code.hpp>
#include <boost/assert.hpp>
@@ -44,9 +44,9 @@
# include <iomanip>
#endif
-namespace fs = boost::filesystem3;
+namespace fs = boost::filesystem;
-using boost::filesystem3::path;
+using boost::filesystem::path;
using std::string;
using std::wstring;
@@ -78,19 +78,23 @@ namespace
# ifdef BOOST_WINDOWS_API
const wchar_t separator = L'/';
- const wchar_t preferred_separator = L'\\';
const wchar_t* const separators = L"/\\";
const wchar_t* separator_string = L"/";
const wchar_t* preferred_separator_string = L"\\";
const wchar_t colon = L':';
const wchar_t dot = L'.';
+ const wchar_t questionmark = L'?';
const fs::path dot_path(L".");
const fs::path dot_dot_path(L"..");
+ inline bool is_letter(wchar_t c)
+ {
+ return (c >= L'a' && c <=L'z') || (c >= L'A' && c <=L'Z');
+ }
+
# else
const char separator = '/';
- const char preferred_separator = '/';
const char* const separators = "/";
const char* separator_string = "/";
const char* preferred_separator_string = "/";
@@ -105,12 +109,12 @@ namespace
{
return c == separator
# ifdef BOOST_WINDOWS_API
- || c == preferred_separator
+ || c == path::preferred_separator
# endif
;
}
- bool is_non_root_separator(const string_type& str, size_type pos);
+ bool is_root_separator(const string_type& str, size_type pos);
// pos is position of the separator
size_type filename_pos(const string_type& str,
@@ -141,32 +145,67 @@ namespace
namespace boost
{
-namespace filesystem3
+namespace filesystem
{
-
- path & path::operator/=(const path & p)
+ path& path::operator/=(const path& p)
{
if (p.empty())
return *this;
- if (!is_separator(*p.m_pathname.begin()))
- m_append_separator_if_needed();
- m_pathname += p.m_pathname;
+ if (this == &p) // self-append
+ {
+ path rhs(p);
+ if (!is_separator(rhs.m_pathname[0]))
+ m_append_separator_if_needed();
+ m_pathname += rhs.m_pathname;
+ }
+ else
+ {
+ if (!is_separator(*p.m_pathname.begin()))
+ m_append_separator_if_needed();
+ m_pathname += p.m_pathname;
+ }
return *this;
}
+ path& path::operator/=(const value_type* ptr)
+ {
+ if (!*ptr)
+ return *this;
+ if (ptr >= m_pathname.data()
+ && ptr < m_pathname.data() + m_pathname.size()) // overlapping source
+ {
+ path rhs(ptr);
+ if (!is_separator(rhs.m_pathname[0]))
+ m_append_separator_if_needed();
+ m_pathname += rhs.m_pathname;
+ }
+ else
+ {
+ if (!is_separator(*ptr))
+ m_append_separator_if_needed();
+ m_pathname += ptr;
+ }
+ return *this;
+ }
+
+ int path::compare(const path& p) const BOOST_NOEXCEPT
+ {
+ return detail::lex_compare(begin(), end(), p.begin(), p.end());
+ }
+
# ifdef BOOST_WINDOWS_API
const std::string path::generic_string(const codecvt_type& cvt) const
{
path tmp(*this);
- tmp.make_preferred();
+ std::replace(tmp.m_pathname.begin(), tmp.m_pathname.end(), L'\\', L'/');
return tmp.string(cvt);
}
const std::wstring path::generic_wstring() const
{
path tmp(*this);
- tmp.make_preferred();
+ std::replace(tmp.m_pathname.begin(), tmp.m_pathname.end(), L'\\', L'/');
return tmp.wstring();
}
@@ -207,7 +246,7 @@ namespace filesystem3
# ifdef BOOST_WINDOWS_API
path & path::make_preferred()
{
- std::replace(m_pathname.begin(), m_pathname.end(), L'\\', L'/');
+ std::replace(m_pathname.begin(), m_pathname.end(), L'/', L'\\');
return *this;
}
# endif
@@ -218,17 +257,18 @@ namespace filesystem3
return *this;
}
- path & path::replace_extension(const path & source)
+ path& path::replace_extension(const path& new_extension)
{
- // erase existing extension if any
- size_type pos(m_pathname.rfind(dot));
- if (pos != string_type::npos && pos >= filename_pos(m_pathname, m_pathname.size()))
- m_pathname.erase(pos);
+ // erase existing extension, including the dot, if any
+ m_pathname.erase(m_pathname.size()-extension().m_pathname.size());
- // append source extension if any
- pos = source.m_pathname.rfind(dot);
- if (pos != string_type::npos)
- m_pathname += source.c_str() + pos;
+ if (!new_extension.empty())
+ {
+ // append new_extension, adding the dot if necessary
+ if (new_extension.m_pathname[0] != dot)
+ m_pathname.push_back(dot);
+ m_pathname.append(new_extension.m_pathname);
+ }
return *this;
}
@@ -318,7 +358,7 @@ namespace filesystem3
return (m_pathname.size()
&& pos
&& is_separator(m_pathname[pos])
- && is_non_root_separator(m_pathname, pos))
+ && !is_root_separator(m_pathname, pos))
? dot_path
: path(m_pathname.c_str() + pos);
}
@@ -410,7 +450,7 @@ namespace filesystem3
return *this;
}
-} // namespace filesystem3
+} // namespace filesystem
} // namespace boost
//--------------------------------------------------------------------------------------//
@@ -422,25 +462,33 @@ namespace filesystem3
namespace
{
- // is_non_root_separator -------------------------------------------------//
+ // is_root_separator ---------------------------------------------------------------//
- bool is_non_root_separator(const string_type & str, size_type pos)
+ bool is_root_separator(const string_type & str, size_type pos)
// pos is position of the separator
{
- BOOST_ASSERT(!str.empty() && is_separator(str[pos])
- && "precondition violation");
+ BOOST_ASSERT_MSG(!str.empty() && is_separator(str[pos]),
+ "precondition violation");
// subsequent logic expects pos to be for leftmost slash of a set
while (pos > 0 && is_separator(str[pos-1]))
--pos;
- return pos != 0
- && (pos <= 2 || !is_separator(str[1])
- || str.find_first_of(separators, 2) != pos)
-# ifdef BOOST_WINDOWS_API
- && (pos !=2 || str[1] != colon)
-# endif
- ;
+ // "/" [...]
+ if (pos == 0)
+ return true;
+
+# ifdef BOOST_WINDOWS_API
+ // "c:/" [...]
+ if (pos == 2 && is_letter(str[0]) && str[1] == colon)
+ return true;
+# endif
+
+ // "//" name "/"
+ if (pos < 3 || !is_separator(str[0]) || !is_separator(str[1]))
+ return false;
+
+ return str.find_first_of(separators, 2) == pos;
}
// filename_pos --------------------------------------------------------------------//
@@ -490,6 +538,19 @@ namespace
&& is_separator(path[0])
&& is_separator(path[1])) return string_type::npos;
+# ifdef BOOST_WINDOWS_API
+ // case "\\?\"
+ if (size > 4
+ && is_separator(path[0])
+ && is_separator(path[1])
+ && path[2] == questionmark
+ && is_separator(path[3]))
+ {
+ string_type::size_type pos(path.find_first_of(separators, 4));
+ return pos < size ? pos : string_type::npos;
+ }
+# endif
+
// case "//net {/}"
if (size > 3
&& is_separator(path[0])
@@ -572,7 +633,32 @@ namespace
return;
}
-} // unnammed namespace
+} // unnamed namespace
+
+
+namespace boost
+{
+namespace filesystem
+{
+ namespace detail
+ {
+ BOOST_FILESYSTEM_DECL
+ int lex_compare(path::iterator first1, path::iterator last1,
+ path::iterator first2, path::iterator last2)
+ {
+ for (; first1 != last1 && first2 != last2;)
+ {
+ if (first1->native() < first2->native()) return -1;
+ if (first2->native() < first1->native()) return 1;
+ BOOST_ASSERT(first2->native() == first1->native());
+ ++first1;
+ ++first2;
+ }
+ if (first1 == last1 && first2 == last2)
+ return 0;
+ return first1 == last1 ? -1 : 1;
+ }
+ }
//--------------------------------------------------------------------------------------//
// //
@@ -580,11 +666,6 @@ namespace
// //
//--------------------------------------------------------------------------------------//
-namespace boost
-{
-namespace filesystem3
-{
-
path::iterator path::begin() const
{
iterator itr;
@@ -607,15 +688,17 @@ namespace filesystem3
void path::m_path_iterator_increment(path::iterator & it)
{
- BOOST_ASSERT(it.m_pos < it.m_path_ptr->m_pathname.size() && "path::basic_iterator increment past end()");
+ BOOST_ASSERT_MSG(it.m_pos < it.m_path_ptr->m_pathname.size(),
+ "path::basic_iterator increment past end()");
- // increment to position past current element
+ // increment to position past current element; if current element is implicit dot,
+ // this will cause it.m_pos to represent the end iterator
it.m_pos += it.m_element.m_pathname.size();
- // if end reached, create end basic_iterator
+ // if the end is reached, we are done
if (it.m_pos == it.m_path_ptr->m_pathname.size())
{
- it.m_element.clear();
+ it.m_element.clear(); // aids debugging, may release unneeded memory
return;
}
@@ -636,18 +719,18 @@ namespace filesystem3
# endif
)
{
- it.m_element.m_pathname = separator;
+ it.m_element.m_pathname = separator; // generic format; see docs
return;
}
- // bypass separators
+ // skip separators until it.m_pos points to the start of the next element
while (it.m_pos != it.m_path_ptr->m_pathname.size()
&& is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
{ ++it.m_pos; }
// detect trailing separator, and treat it as ".", per POSIX spec
if (it.m_pos == it.m_path_ptr->m_pathname.size()
- && is_non_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1))
+ && !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1))
{
--it.m_pos;
it.m_element = dot_path;
@@ -655,15 +738,16 @@ namespace filesystem3
}
}
- // get next element
+ // get m_element
size_type end_pos(it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos));
- if (end_pos == string_type::npos) end_pos = it.m_path_ptr->m_pathname.size();
+ if (end_pos == string_type::npos)
+ end_pos = it.m_path_ptr->m_pathname.size();
it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
}
void path::m_path_iterator_decrement(path::iterator & it)
{
- BOOST_ASSERT(it.m_pos && "path::iterator decrement past begin()");
+ BOOST_ASSERT_MSG(it.m_pos, "path::iterator decrement past begin()");
size_type end_pos(it.m_pos);
@@ -671,7 +755,7 @@ namespace filesystem3
if (it.m_pos == it.m_path_ptr->m_pathname.size()
&& it.m_path_ptr->m_pathname.size() > 1
&& is_separator(it.m_path_ptr->m_pathname[it.m_pos-1])
- && is_non_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1)
+ && !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1)
)
{
--it.m_pos;
@@ -692,11 +776,11 @@ namespace filesystem3
it.m_pos = filename_pos(it.m_path_ptr->m_pathname, end_pos);
it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
- if (it.m_element.m_pathname == preferred_separator_string)
- it.m_element.m_pathname = separator_string; // needed for Windows, harmless on POSIX
+ if (it.m_element.m_pathname == preferred_separator_string) // needed for Windows, harmless on POSIX
+ it.m_element.m_pathname = separator_string; // generic format; see docs
}
-} // namespace filesystem3
+} // namespace filesystem
} // namespace boost
//--------------------------------------------------------------------------------------//
@@ -712,51 +796,80 @@ namespace
// locale helpers //
//------------------------------------------------------------------------------------//
- // std::locale construction can throw (if LC_MESSAGES is wrong, for example),
- // so a static at function scope is used to ensure that exceptions can be
- // caught. (A previous version was at namespace scope, so initialization
- // occurred before main(), preventing exceptions from being caught.)
+#if defined(BOOST_WINDOWS_API) && defined(BOOST_FILESYSTEM_STATIC_LINK)
- std::locale default_locale()
+ inline std::locale default_locale()
{
-# ifdef BOOST_WINDOWS_API
std::locale global_loc = std::locale();
std::locale loc(global_loc, new windows_file_codecvt);
return loc;
-
-# elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
- // "All BSD system functions expect their string parameters to be in UTF-8 encoding
- // and nothing else." http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html
- //
- // "The kernel will reject any filename that is not a valid UTF-8 string, and it will
- // even be normalized (to Unicode NFD) before stored on disk, at least when using HFS.
- // The right way to deal with it would be to always convert the filename to UTF-8
- // before trying to open/create a file." http://lists.apple.com/archives/unix-porting/2007/Sep/msg00023.html
- //
- // "How a file name looks at the API level depends on the API. Current Carbon APIs
- // handle file names as an array of UTF-16 characters; POSIX ones handle them as an
- // array of UTF-8, which is why UTF-8 works well in Terminal. How it's stored on disk
- // depends on the disk format; HFS+ uses UTF-16, but that's not important in most
- // cases." http://lists.apple.com/archives/applescript-users/2002/Sep/msg00319.html
- //
- // Many thanks to Peter Dimov for digging out the above references!
- std::locale global_loc = std::locale();
- std::locale loc(global_loc, new boost::filesystem::detail::utf8_codecvt_facet);
- return loc;
-
-# else
- // ISO C calls this "the locale-specific native environment":
- return std::locale("");
-
-# endif
}
- std::locale & path_locale()
+ inline std::locale& path_locale()
{
static std::locale loc(default_locale());
return loc;
}
+ inline const path::codecvt_type*& codecvt_facet_ptr()
+ {
+ static const std::codecvt<wchar_t, char, std::mbstate_t>*
+ facet(
+ &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ (path_locale()));
+ return facet;
+ }
+
+#elif defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_STATIC_LINK)
+
+ std::locale path_locale(std::locale(), new windows_file_codecvt);
+
+ const std::codecvt<wchar_t, char, std::mbstate_t>*
+ codecvt_facet_ptr(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ (path_locale));
+
+#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
+
+ // "All BSD system functions expect their string parameters to be in UTF-8 encoding
+ // and nothing else." See
+ // http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html
+ //
+ // "The kernel will reject any filename that is not a valid UTF-8 string, and it will
+ // even be normalized (to Unicode NFD) before stored on disk, at least when using HFS.
+ // The right way to deal with it would be to always convert the filename to UTF-8
+ // before trying to open/create a file." See
+ // http://lists.apple.com/archives/unix-porting/2007/Sep/msg00023.html
+ //
+ // "How a file name looks at the API level depends on the API. Current Carbon APIs
+ // handle file names as an array of UTF-16 characters; POSIX ones handle them as an
+ // array of UTF-8, which is why UTF-8 works well in Terminal. How it's stored on disk
+ // depends on the disk format; HFS+ uses UTF-16, but that's not important in most
+ // cases." See
+ // http://lists.apple.com/archives/applescript-users/2002/Sep/msg00319.html
+ //
+ // Many thanks to Peter Dimov for digging out the above references!
+
+ std::locale path_locale(std::locale(),
+ new boost::filesystem::detail::utf8_codecvt_facet);
+
+ const std::codecvt<wchar_t, char, std::mbstate_t>*
+ codecvt_facet_ptr(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
+ (path_locale));
+
+#else // Other POSIX
+
+ // ISO C calls std::locale("") "the locale-specific native environment", and this
+ // locale is the default for many POSIX-based operating systems such as Linux.
+
+ // std::locale("") construction can throw (if environmental variables LC_MESSAGES or
+ // or LANG are wrong, for example), so lazy initialization is used to ensure
+ // that exceptions occur after main() starts and so can be caught.
+
+ std::locale path_locale; // initialized by path::codecvt() below
+ const std::codecvt<wchar_t, char, std::mbstate_t>* codecvt_facet_ptr; // ditto
+
+# endif
+
} // unnamed namespace
//--------------------------------------------------------------------------------------//
@@ -765,29 +878,52 @@ namespace
namespace boost
{
-namespace filesystem3
+namespace filesystem
{
- const path::codecvt_type *&
- path::wchar_t_codecvt_facet()
+#if defined(BOOST_WINDOWS_API) && defined(BOOST_FILESYSTEM_STATIC_LINK)
+
+ const path::codecvt_type& path::codecvt()
{
- static const std::codecvt<wchar_t, char, std::mbstate_t> *
- facet(
- &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
- (path_locale()));
- return facet;
+ BOOST_ASSERT_MSG(codecvt_facet_ptr(), "codecvt_facet_ptr() facet hasn't been properly initialized");
+ return *codecvt_facet_ptr();
}
std::locale path::imbue(const std::locale & loc)
{
std::locale temp(path_locale());
path_locale() = loc;
- wchar_t_codecvt_facet() = &std::use_facet
- <std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale());
+ codecvt_facet_ptr() =
+ &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale());
return temp;
}
-} // namespace filesystem3
-} // namespace boost
+#else
+
+ const path::codecvt_type& path::codecvt()
+ {
+# if defined(BOOST_POSIX_API) && \
+ !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
+ // A local static initialized by calling path::imbue ensures that std::locale(""),
+ // which may throw, is called only if path_locale and condecvt_facet will actually
+ // be used. Thus misconfigured environmental variables will only cause an
+ // exception if a valid std::locale("") is actually needed.
+ static std::locale posix_lazy_initialization(path::imbue(std::locale("")));
+# endif
+ return *codecvt_facet_ptr;
+ }
-#endif // no wide character support
+ std::locale path::imbue(const std::locale& loc)
+ {
+ std::locale temp(path_locale);
+ path_locale = loc;
+ codecvt_facet_ptr =
+ &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(path_locale);
+ return temp;
+ }
+
+
+#endif
+
+} // namespace filesystem
+} // namespace boost
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/path_traits.cpp b/3rdParty/Boost/src/libs/filesystem/src/path_traits.cpp
index 6606437..06ac798 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/path_traits.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/path_traits.cpp
@@ -9,13 +9,6 @@
//--------------------------------------------------------------------------------------//
-#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
-
// define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_FILESYSTEM_SOURCE
@@ -24,16 +17,16 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
-#include <boost/filesystem/v3/config.hpp>
-#include <boost/filesystem/v3/path_traits.hpp>
+#include <boost/filesystem/config.hpp>
+#include <boost/filesystem/path_traits.hpp>
#include <boost/system/system_error.hpp>
#include <boost/scoped_array.hpp>
#include <locale> // for codecvt_base::result
#include <cstring> // for strlen
#include <cwchar> // for wcslen
-namespace pt = boost::filesystem3::path_traits;
-namespace fs = boost::filesystem3;
+namespace pt = boost::filesystem::path_traits;
+namespace fs = boost::filesystem;
namespace bs = boost::system;
//--------------------------------------------------------------------------------------//
@@ -130,7 +123,7 @@ namespace {
// path_traits //
//--------------------------------------------------------------------------------------//
-namespace boost { namespace filesystem3 { namespace path_traits {
+namespace boost { namespace filesystem { namespace path_traits {
//--------------------------------------------------------------------------------------//
// convert const char* to wstring //
@@ -204,6 +197,4 @@ namespace boost { namespace filesystem3 { namespace path_traits {
convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
}
}
-}}} // namespace boost::filesystem3::path_traits
-
-#endif // no wide character support
+}}} // namespace boost::filesystem::path_traits
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/portability.cpp b/3rdParty/Boost/src/libs/filesystem/src/portability.cpp
index 31e0176..b1a1352 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/portability.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/portability.cpp
@@ -9,13 +9,6 @@
//--------------------------------------------------------------------------------------//
-#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
-
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_FILESYSTEM_SOURCE
@@ -24,10 +17,10 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
-#include <boost/filesystem/v3/config.hpp>
-#include <boost/filesystem/v3/path.hpp>
+#include <boost/filesystem/config.hpp>
+#include <boost/filesystem/path.hpp>
-namespace fs = boost::filesystem3;
+namespace fs = boost::filesystem;
#include <cstring> // SGI MIPSpro compilers need this
@@ -54,7 +47,7 @@ namespace
namespace boost
{
- namespace filesystem3
+ namespace filesystem
{
// name_check functions ----------------------------------------------//
@@ -122,7 +115,5 @@ namespace boost
;
}
- } // namespace filesystem3
+ } // namespace filesystem
} // namespace boost
-
-#endif // no wide character support
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/unique_path.cpp b/3rdParty/Boost/src/libs/filesystem/src/unique_path.cpp
index 1569b32..c25c315 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/unique_path.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/unique_path.cpp
@@ -1,4 +1,4 @@
-// filesystem system_crypt_random.cpp ------------------------------------------------//
+// filesystem unique_path.cpp --------------------------------------------------------//
// Copyright Beman Dawes 2010
@@ -9,13 +9,6 @@
//--------------------------------------------------------------------------------------//
-#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
-
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_FILESYSTEM_SOURCE
@@ -24,7 +17,7 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
-#include <boost/filesystem/v3/operations.hpp>
+#include <boost/filesystem/operations.hpp>
# ifdef BOOST_POSIX_API
# include <fcntl.h>
@@ -112,7 +105,7 @@ void system_crypt_random(void* buf, std::size_t len, boost::system::error_code*
} // unnamed namespace
-namespace boost { namespace filesystem3 { namespace detail {
+namespace boost { namespace filesystem { namespace detail {
BOOST_FILESYSTEM_DECL
path unique_path(const path& model, system::error_code* ec)
@@ -147,5 +140,3 @@ path unique_path(const path& model, system::error_code* ec)
}
}}}
-
-#endif // no wide character support
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/windows_file_codecvt.cpp b/3rdParty/Boost/src/libs/filesystem/src/windows_file_codecvt.cpp
index ae9f9f2..998db60 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/windows_file_codecvt.cpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/windows_file_codecvt.cpp
@@ -9,13 +9,6 @@
//--------------------------------------------------------------------------------------//
-#include <boost/config.hpp>
-#if !defined( BOOST_NO_STD_WSTRING )
-// Boost.Filesystem V3 and later requires std::wstring support.
-// During the transition to V3, libraries are compiled with both V2 and V3 sources.
-// On old compilers that don't support V3 anyhow, we just skip everything so the compile
-// will succeed and the library can be built.
-
// define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_FILESYSTEM_SOURCE
@@ -24,7 +17,7 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif
-#include <boost/filesystem/v3/config.hpp>
+#include <boost/filesystem/config.hpp>
#include <cwchar> // for mbstate_t
#ifdef BOOST_WINDOWS_API
@@ -43,7 +36,7 @@
const char* from, const char* from_end, const char*& from_next,
wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
{
- UINT codepage = AreFileApisANSI() ? CP_THREAD_ACP : CP_OEMCP;
+ UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
int count;
if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from,
@@ -63,7 +56,7 @@
const wchar_t* from, const wchar_t* from_end, const wchar_t* & from_next,
char* to, char* to_end, char* & to_next) const
{
- UINT codepage = AreFileApisANSI() ? CP_THREAD_ACP : CP_OEMCP;
+ UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
int count;
if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from,
@@ -80,4 +73,3 @@
# endif // BOOST_WINDOWS_API
-#endif // no wide character support
diff --git a/3rdParty/Boost/src/libs/filesystem/v3/src/windows_file_codecvt.hpp b/3rdParty/Boost/src/libs/filesystem/src/windows_file_codecvt.hpp
index d845d37..52deab1 100644
--- a/3rdParty/Boost/src/libs/filesystem/v3/src/windows_file_codecvt.hpp
+++ b/3rdParty/Boost/src/libs/filesystem/src/windows_file_codecvt.hpp
@@ -10,7 +10,7 @@
#ifndef BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP
#define BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP
-#include <boost/filesystem/v3/config.hpp>
+#include <boost/filesystem/config.hpp>
#include <locale>
//------------------------------------------------------------------------------------//
diff --git a/3rdParty/Boost/src/libs/filesystem/v2/src/v2_operations.cpp b/3rdParty/Boost/src/libs/filesystem/v2/src/v2_operations.cpp
deleted file mode 100644
index f29153c..0000000
--- a/3rdParty/Boost/src/libs/filesystem/v2/src/v2_operations.cpp
+++ /dev/null
@@ -1,1372 +0,0 @@
-// operations.cpp ----------------------------------------------------------//
-
-// Copyright 2002-2005 Beman Dawes
-// Copyright 2001 Dietmar Kuehl
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
-// at http://www.boost.org/LICENSE_1_0.txt)
-
-// See library home page at http://www.boost.org/libs/filesystem
-
-//----------------------------------------------------------------------------//
-
-// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
-// the library is being built (possibly exporting rather than importing code)
-#define BOOST_FILESYSTEM_SOURCE
-
-#ifndef BOOST_SYSTEM_NO_DEPRECATED
-# define BOOST_SYSTEM_NO_DEPRECATED
-#endif
-
-#define _POSIX_PTHREAD_SEMANTICS // Sun readdir_r() needs this
-
-#if !(defined(__HP_aCC) && defined(_ILP32) && \
- !defined(_STATVFS_ACPP_PROBLEMS_FIXED))
-#define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect,
-#endif
-#define __USE_FILE_OFFSET64 // but that is harmless on Windows and on POSIX
- // 64-bit systems or on 32-bit systems which don't have files larger
- // than can be represented by a traditional POSIX/UNIX off_t type.
- // OTOH, defining them should kick in 64-bit off_t's (and thus
- // st_size) on 32-bit systems that provide the Large File
- // Support (LFS) interface, such as Linux, Solaris, and IRIX.
- // The defines are given before any headers are included to
- // ensure that they are available to all included headers.
- // That is required at least on Solaris, and possibly on other
- // systems as well.
-
-// for some compilers (CodeWarrior, for example), windows.h
-// is getting included by some other boost header, so do this early:
-#if !defined(_WIN32_WINNT)
-#define _WIN32_WINNT 0x0500 // Default to Windows 2K or later
-#endif
-
-
-#include <boost/filesystem/v2/operations.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/assert.hpp>
-#include <boost/detail/workaround.hpp>
-#include <cstdlib> // for malloc, free
-
-namespace fs = boost::filesystem2;
-using boost::system::error_code;
-using boost::system::system_category;
-
-# if defined(BOOST_WINDOWS_API)
-# include <windows.h>
-# include <ctime> // for time_t
-
-# else // BOOST_POSIX_API
-# include <sys/types.h>
-# if !defined(__APPLE__) && !defined(__OpenBSD__)
-# include <sys/statvfs.h>
-# define BOOST_STATVFS statvfs
-# define BOOST_STATVFS_F_FRSIZE vfs.f_frsize
-# else
-#ifdef __OpenBSD__
-# include <sys/param.h>
-#endif
-# include <sys/mount.h>
-# define BOOST_STATVFS statfs
-# define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>( vfs.f_bsize )
-# endif
-# include <dirent.h>
-# include <unistd.h>
-# include <fcntl.h>
-# include <utime.h>
-# include "limits.h"
-# endif
-
-// BOOST_FILESYSTEM_STATUS_CACHE enables file_status cache in
-// dir_itr_increment. The config tests are placed here because some of the
-// macros being tested come from dirent.h.
-//
-// TODO: find out what macros indicate dirent::d_type present in more libraries
-# if defined(BOOST_WINDOWS_API) \
- || (defined(_DIRENT_HAVE_D_TYPE) /* defined by GNU C library if d_type present */ \
- && !(defined(__SUNPRO_CC) && !defined(__sun))) // _DIRENT_HAVE_D_TYPE wrong for Sun compiler on Linux
-# define BOOST_FILESYSTEM_STATUS_CACHE
-# endif
-
-#include <sys/stat.h> // even on Windows some functions use stat()
-#include <string>
-#include <cstring>
-#include <cstdio> // for remove, rename
-#include <cerrno>
-// #include <iostream> // for debugging only; comment out when not in use
-
-#ifdef BOOST_NO_STDC_NAMESPACE
-namespace std { using ::strcmp; using ::remove; using ::rename; }
-#endif
-
-// helpers -----------------------------------------------------------------//
-
-namespace
-{
- const error_code ok;
-
- bool is_empty_directory( const std::string & dir_path )
- {
- static const fs::directory_iterator end_itr;
- return fs::directory_iterator(fs::path(dir_path)) == end_itr;
- }
-
-#ifdef BOOST_WINDOWS_API
-
-// For Windows, the xxxA form of various function names is used to avoid
-// inadvertently getting wide forms of the functions. (The undecorated
-// forms are actually macros, so can misfire if the user has various
-// other macros defined. There was a bug report of this happening.)
-
- inline DWORD get_file_attributes( const char * ph )
- { return ::GetFileAttributesA( ph ); }
-
-# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
-
- inline DWORD get_file_attributes( const wchar_t * ph )
- { return ::GetFileAttributesW( ph ); }
-
- bool is_empty_directory( const std::wstring & dir_path )
- {
- static const fs::wdirectory_iterator wend_itr;
- return fs::wdirectory_iterator(fs::wpath(dir_path)) == wend_itr;
- }
-
- inline BOOL get_file_attributes_ex( const wchar_t * ph,
- WIN32_FILE_ATTRIBUTE_DATA & fad )
- { return ::GetFileAttributesExW( ph, ::GetFileExInfoStandard, &fad ); }
-
- HANDLE create_file( const wchar_t * ph, DWORD dwDesiredAccess,
- DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
- HANDLE hTemplateFile )
- {
- return ::CreateFileW( ph, dwDesiredAccess, dwShareMode,
- lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
- hTemplateFile );
- }
-
- inline DWORD get_current_directory( DWORD sz, wchar_t * buf )
- { return ::GetCurrentDirectoryW( sz, buf ); }
-
- inline bool set_current_directory( const wchar_t * buf )
- { return ::SetCurrentDirectoryW( buf ) != 0 ; }
-
- inline bool get_free_disk_space( const std::wstring & ph,
- PULARGE_INTEGER avail, PULARGE_INTEGER total, PULARGE_INTEGER free )
- { return ::GetDiskFreeSpaceExW( ph.c_str(), avail, total, free ) != 0; }
-
- inline std::size_t get_full_path_name(
- const std::wstring & ph, std::size_t len, wchar_t * buf, wchar_t ** p )
- {
- return static_cast<std::size_t>(
- ::GetFullPathNameW( ph.c_str(),
- static_cast<DWORD>(len), buf, p ));
- }
-
- inline bool remove_directory( const std::wstring & ph )
- { return ::RemoveDirectoryW( ph.c_str() ) != 0; }
-
- inline bool delete_file( const std::wstring & ph )
- { return ::DeleteFileW( ph.c_str() ) != 0; }
-
- inline bool create_directory( const std::wstring & dir )
- { return ::CreateDirectoryW( dir.c_str(), 0 ) != 0; }
-
-#if _WIN32_WINNT >= 0x500
- inline bool create_hard_link( const std::wstring & to_ph,
- const std::wstring & from_ph )
- { return ::CreateHardLinkW( from_ph.c_str(), to_ph.c_str(), 0 ) != 0; }
-#endif
-
-# endif // ifndef BOOST_FILESYSTEM2_NARROW_ONLY
-
- template< class String >
- fs::file_status status_template( const String & ph, error_code & ec )
- {
- DWORD attr( get_file_attributes( ph.c_str() ) );
- if ( attr == 0xFFFFFFFF )
- {
- ec = error_code( ::GetLastError(), system_category() );
- if ((ec.value() == ERROR_FILE_NOT_FOUND)
- || (ec.value() == ERROR_PATH_NOT_FOUND)
- || (ec.value() == ERROR_INVALID_NAME) // "tools/jam/src/:sys:stat.h", "//foo"
- || (ec.value() == ERROR_INVALID_DRIVE) // USB card reader with no card inserted
- || (ec.value() == ERROR_NOT_READY) // CD/DVD drive with no disc inserted
- || (ec.value() == ERROR_INVALID_PARAMETER) // ":sys:stat.h"
- || (ec.value() == ERROR_BAD_PATHNAME) // "//nosuch" on Win64
- || (ec.value() == ERROR_BAD_NETPATH)) // "//nosuch" on Win32
- {
- ec = ok; // these are not considered errors;
- // the status is considered not found
- return fs::file_status( fs::file_not_found );
- }
- else if ((ec.value() == ERROR_SHARING_VIOLATION))
- {
- ec = ok; // these are not considered errors;
- // the file exists but the type is not known
- return fs::file_status( fs::type_unknown );
- }
- return fs::file_status( fs::status_unknown );
- }
- ec = ok;;
- return (attr & FILE_ATTRIBUTE_DIRECTORY)
- ? fs::file_status( fs::directory_file )
- : fs::file_status( fs::regular_file );
- }
-
- BOOL get_file_attributes_ex( const char * ph,
- WIN32_FILE_ATTRIBUTE_DATA & fad )
- { return ::GetFileAttributesExA( ph, ::GetFileExInfoStandard, &fad ); }
-
- template< class String >
- boost::filesystem2::detail::query_pair
- is_empty_template( const String & ph )
- {
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if ( get_file_attributes_ex( ph.c_str(), fad ) == 0 )
- return std::make_pair( error_code( ::GetLastError(), system_category() ), false );
- return std::make_pair( ok,
- ( fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- ? is_empty_directory( ph )
- :( !fad.nFileSizeHigh && !fad.nFileSizeLow ) );
- }
-
- HANDLE create_file( const char * ph, DWORD dwDesiredAccess,
- DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
- HANDLE hTemplateFile )
- {
- return ::CreateFileA( ph, dwDesiredAccess, dwShareMode,
- lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
- hTemplateFile );
- }
-
- // Thanks to Jeremy Maitin-Shepard for much help and for permission to
- // base the equivalent() implementation on portions of his
- // file-equivalence-win32.cpp experimental code.
- struct handle_wrapper
- {
- HANDLE handle;
- handle_wrapper( HANDLE h )
- : handle(h) {}
- ~handle_wrapper()
- {
- if ( handle != INVALID_HANDLE_VALUE )
- ::CloseHandle(handle);
- }
- };
-
- template< class String >
- boost::filesystem2::detail::query_pair
- equivalent_template( const String & ph1, const String & ph2 )
- {
- // Note well: Physical location on external media is part of the
- // equivalence criteria. If there are no open handles, physical location
- // can change due to defragmentation or other relocations. Thus handles
- // must be held open until location information for both paths has
- // been retrieved.
- handle_wrapper p1(
- create_file(
- ph1.c_str(),
- 0,
- FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
- 0,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- 0 ) );
- int error1(0); // save error code in case we have to throw
- if ( p1.handle == INVALID_HANDLE_VALUE )
- error1 = ::GetLastError();
- handle_wrapper p2(
- create_file(
- ph2.c_str(),
- 0,
- FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
- 0,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- 0 ) );
- if ( p1.handle == INVALID_HANDLE_VALUE
- || p2.handle == INVALID_HANDLE_VALUE )
- {
- if ( p1.handle != INVALID_HANDLE_VALUE
- || p2.handle != INVALID_HANDLE_VALUE )
- { return std::make_pair( ok, false ); }
- BOOST_ASSERT( p1.handle == INVALID_HANDLE_VALUE
- && p2.handle == INVALID_HANDLE_VALUE );
- { return std::make_pair( error_code( error1, system_category()), false ); }
- }
- // at this point, both handles are known to be valid
- BY_HANDLE_FILE_INFORMATION info1, info2;
- if ( !::GetFileInformationByHandle( p1.handle, &info1 ) )
- { return std::make_pair( error_code( ::GetLastError(), system_category() ), false ); }
- if ( !::GetFileInformationByHandle( p2.handle, &info2 ) )
- { return std::make_pair( error_code( ::GetLastError(), system_category() ), false ); }
- // In theory, volume serial numbers are sufficient to distinguish between
- // devices, but in practice VSN's are sometimes duplicated, so last write
- // time and file size are also checked.
- return std::make_pair( ok,
- info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber
- && info1.nFileIndexHigh == info2.nFileIndexHigh
- && info1.nFileIndexLow == info2.nFileIndexLow
- && info1.nFileSizeHigh == info2.nFileSizeHigh
- && info1.nFileSizeLow == info2.nFileSizeLow
- && info1.ftLastWriteTime.dwLowDateTime
- == info2.ftLastWriteTime.dwLowDateTime
- && info1.ftLastWriteTime.dwHighDateTime
- == info2.ftLastWriteTime.dwHighDateTime );
- }
-
- template< class String >
- boost::filesystem2::detail::uintmax_pair
- file_size_template( const String & ph )
- {
- WIN32_FILE_ATTRIBUTE_DATA fad;
- // by now, intmax_t is 64-bits on all Windows compilers
- if ( get_file_attributes_ex( ph.c_str(), fad ) == 0 )
- return std::make_pair( error_code( ::GetLastError(), system_category() ), 0 );
- if ( (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) !=0 )
- return std::make_pair( error_code( ERROR_FILE_NOT_FOUND, system_category()), 0 );
- return std::make_pair( ok,
- (static_cast<boost::uintmax_t>(fad.nFileSizeHigh)
- << (sizeof(fad.nFileSizeLow)*8))
- + fad.nFileSizeLow );
- }
-
- inline bool get_free_disk_space( const std::string & ph,
- PULARGE_INTEGER avail, PULARGE_INTEGER total, PULARGE_INTEGER free )
- { return ::GetDiskFreeSpaceExA( ph.c_str(), avail, total, free ) != 0; }
-
- template< class String >
- boost::filesystem2::detail::space_pair
- space_template( String & ph )
- {
- ULARGE_INTEGER avail, total, free;
- boost::filesystem2::detail::space_pair result;
- if ( get_free_disk_space( ph, &avail, &total, &free ) )
- {
- result.first = ok;
- result.second.capacity
- = (static_cast<boost::uintmax_t>(total.HighPart) << 32)
- + total.LowPart;
- result.second.free
- = (static_cast<boost::uintmax_t>(free.HighPart) << 32)
- + free.LowPart;
- result.second.available
- = (static_cast<boost::uintmax_t>(avail.HighPart) << 32)
- + avail.LowPart;
- }
- else
- {
- result.first = error_code( ::GetLastError(), system_category() );
- result.second.capacity = result.second.free
- = result.second.available = 0;
- }
- return result;
- }
-
- inline DWORD get_current_directory( DWORD sz, char * buf )
- { return ::GetCurrentDirectoryA( sz, buf ); }
-
- template< class String >
- error_code
- get_current_path_template( String & ph )
- {
- DWORD sz;
- if ( (sz = get_current_directory( 0,
- static_cast<typename String::value_type*>(0) )) == 0 )
- { sz = 1; }
- typedef typename String::value_type value_type;
- boost::scoped_array<value_type> buf( new value_type[sz] );
- if ( get_current_directory( sz, buf.get() ) == 0 )
- return error_code( ::GetLastError(), system_category() );
- ph = buf.get();
- return ok;
- }
-
- inline bool set_current_directory( const char * buf )
- { return ::SetCurrentDirectoryA( buf ) != 0; }
-
- template< class String >
- error_code
- set_current_path_template( const String & ph )
- {
- return error_code( set_current_directory( ph.c_str() )
- ? 0 : ::GetLastError(), system_category() );
- }
-
- inline std::size_t get_full_path_name(
- const std::string & ph, std::size_t len, char * buf, char ** p )
- {
- return static_cast<std::size_t>(
- ::GetFullPathNameA( ph.c_str(),
- static_cast<DWORD>(len), buf, p ));
- }
-
- const std::size_t buf_size( 128 );
-
- template<class String>
- error_code
- get_full_path_name_template( const String & ph, String & target )
- {
- typename String::value_type buf[buf_size];
- typename String::value_type * pfn;
- std::size_t len = get_full_path_name( ph,
- buf_size , buf, &pfn );
- if ( len == 0 ) return error_code( ::GetLastError(), system_category() );
- if ( len > buf_size )
- {
- typedef typename String::value_type value_type;
- boost::scoped_array<value_type> big_buf( new value_type[len] );
- if ( (len=get_full_path_name( ph, len , big_buf.get(), &pfn ))
- == 0 ) return error_code( ::GetLastError(), system_category() );
- big_buf[len] = '\0';
- target = big_buf.get();
- return ok;
- }
- buf[len] = '\0';
- target = buf;
- return ok;
- }
-
- template<class String>
- error_code
- get_file_write_time( const String & ph, FILETIME & last_write_time )
- {
- handle_wrapper hw(
- create_file( ph.c_str(), 0,
- FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
- OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) );
- if ( hw.handle == INVALID_HANDLE_VALUE )
- return error_code( ::GetLastError(), system_category() );
- return error_code( ::GetFileTime( hw.handle, 0, 0, &last_write_time ) != 0
- ? 0 : ::GetLastError(), system_category() );
- }
-
- template<class String>
- error_code
- set_file_write_time( const String & ph, const FILETIME & last_write_time )
- {
- handle_wrapper hw(
- create_file( ph.c_str(), FILE_WRITE_ATTRIBUTES,
- FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
- OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) );
- if ( hw.handle == INVALID_HANDLE_VALUE )
- return error_code( ::GetLastError(), system_category() );
- return error_code( ::SetFileTime( hw.handle, 0, 0, &last_write_time ) != 0
- ? 0 : ::GetLastError(), system_category() );
- }
-
- // these constants come from inspecting some Microsoft sample code
- std::time_t to_time_t( const FILETIME & ft )
- {
- __int64 t = (static_cast<__int64>( ft.dwHighDateTime ) << 32)
- + ft.dwLowDateTime;
-# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // > VC++ 7.0
- t -= 116444736000000000LL;
-# else
- t -= 116444736000000000;
-# endif
- t /= 10000000;
- return static_cast<std::time_t>( t );
- }
-
- void to_FILETIME( std::time_t t, FILETIME & ft )
- {
- __int64 temp = t;
- temp *= 10000000;
-# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // > VC++ 7.0
- temp += 116444736000000000LL;
-# else
- temp += 116444736000000000;
-# endif
- ft.dwLowDateTime = static_cast<DWORD>( temp );
- ft.dwHighDateTime = static_cast<DWORD>( temp >> 32 );
- }
-
- template<class String>
- boost::filesystem2::detail::time_pair
- last_write_time_template( const String & ph )
- {
- FILETIME lwt;
- error_code ec(
- get_file_write_time( ph, lwt ) );
- return std::make_pair( ec, to_time_t( lwt ) );
- }
-
- template<class String>
- error_code
- last_write_time_template( const String & ph, const std::time_t new_time )
- {
- FILETIME lwt;
- to_FILETIME( new_time, lwt );
- return set_file_write_time( ph, lwt );
- }
-
- bool remove_directory( const std::string & ph )
- { return ::RemoveDirectoryA( ph.c_str() ) != 0; }
-
- bool delete_file( const std::string & ph )
- { return ::DeleteFileA( ph.c_str() ) != 0; }
-
- template<class String>
- error_code
- remove_template( const String & ph )
- {
- // TODO: test this code in the presence of Vista symlinks,
- // including dangling, self-referal, and cyclic symlinks
- error_code ec;
- fs::file_status sf( fs::detail::status_api( ph, ec ) );
- if ( ec )
- return ec;
- if ( sf.type() == fs::file_not_found )
- return ok;
- if ( fs::is_directory( sf ) )
- {
- if ( !remove_directory( ph ) )
- return error_code(::GetLastError(), system_category());
- }
- else
- {
- if ( !delete_file( ph ) ) return error_code(::GetLastError(), system_category());
- }
- return ok;
- }
-
- inline bool create_directory( const std::string & dir )
- { return ::CreateDirectoryA( dir.c_str(), 0 ) != 0; }
-
- template<class String>
- boost::filesystem2::detail::query_pair
- create_directory_template( const String & dir_ph )
- {
- error_code error, dummy;
- if ( create_directory( dir_ph ) ) return std::make_pair( error, true );
- error = error_code( ::GetLastError(), system_category() );
- // an error here may simply mean the postcondition is already met
- if ( error.value() == ERROR_ALREADY_EXISTS
- && fs::is_directory( fs::detail::status_api( dir_ph, dummy ) ) )
- return std::make_pair( ok, false );
- return std::make_pair( error, false );
- }
-
-#if _WIN32_WINNT >= 0x500
- inline bool create_hard_link( const std::string & to_ph,
- const std::string & from_ph )
- { return ::CreateHardLinkA( from_ph.c_str(), to_ph.c_str(), 0 ) != 0; }
-#endif
-
-#if _WIN32_WINNT >= 0x500
- template<class String>
- error_code
- create_hard_link_template( const String & to_ph,
- const String & from_ph )
- {
- return error_code( create_hard_link( to_ph.c_str(), from_ph.c_str() )
- ? 0 : ::GetLastError(), system_category() );
- }
-#endif
-
-#else // BOOST_POSIX_API
-
- int posix_remove( const char * p )
- {
-# if defined(__QNXNTO__) || (defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)))
- // Some Metrowerks C library versions fail on directories because of a
- // known Metrowerks coding error in ::remove. Workaround is to call
- // rmdir() or unlink() as indicated.
- // Same bug also reported for QNX, with the same fix.
- int err = ::unlink( p );
- if ( err == 0 || errno != EPERM )
- return err;
- return ::rmdir( p );
-# else
- return std::remove( p );
-# endif
- }
-
-#endif
-} // unnamed namespace
-
-namespace boost
-{
- namespace filesystem2
- {
- namespace detail
- {
- BOOST_FILESYSTEM_DECL system::error_code throws;
-
-// free functions ----------------------------------------------------------//
-
- BOOST_FILESYSTEM_DECL error_code not_found_error()
- {
-# ifdef BOOST_WINDOWS_API
- return error_code(ERROR_PATH_NOT_FOUND, system_category());
-# else
- return error_code(ENOENT, system_category());
-# endif
- }
-
- BOOST_FILESYSTEM_DECL bool possible_large_file_size_support()
- {
-# ifdef BOOST_POSIX_API
- struct stat lcl_stat;
- return sizeof( lcl_stat.st_size ) > 4;
-# else
- return true;
-# endif
- }
-
-# ifdef BOOST_WINDOWS_API
-
- BOOST_FILESYSTEM_DECL fs::file_status
- status_api( const std::string & ph, error_code & ec )
- { return status_template( ph, ec ); }
-
-# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
-
- BOOST_FILESYSTEM_DECL fs::file_status
- status_api( const std::wstring & ph, error_code & ec )
- { return status_template( ph, ec ); }
-
- BOOST_FILESYSTEM_DECL bool symbolic_link_exists_api( const std::wstring & )
- { return false; }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::query_pair is_empty_api( const std::wstring & ph )
- { return is_empty_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::query_pair
- equivalent_api( const std::wstring & ph1, const std::wstring & ph2 )
- { return equivalent_template( ph1, ph2 ); }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::uintmax_pair file_size_api( const std::wstring & ph )
- { return file_size_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::space_pair space_api( const std::wstring & ph )
- { return space_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- error_code
- get_current_path_api( std::wstring & ph )
- { return get_current_path_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- error_code
- set_current_path_api( const std::wstring & ph )
- { return set_current_path_template( ph ); }
-
- BOOST_FILESYSTEM_DECL error_code
- get_full_path_name_api( const std::wstring & ph, std::wstring & target )
- { return get_full_path_name_template( ph, target ); }
-
- BOOST_FILESYSTEM_DECL time_pair
- last_write_time_api( const std::wstring & ph )
- { return last_write_time_template( ph ); }
-
- BOOST_FILESYSTEM_DECL error_code
- last_write_time_api( const std::wstring & ph, std::time_t new_value )
- { return last_write_time_template( ph, new_value ); }
-
- BOOST_FILESYSTEM_DECL fs::detail::query_pair
- create_directory_api( const std::wstring & ph )
- { return create_directory_template( ph ); }
-
-#if _WIN32_WINNT >= 0x500
- BOOST_FILESYSTEM_DECL error_code
- create_hard_link_api( const std::wstring & to_ph,
- const std::wstring & from_ph )
- { return create_hard_link_template( to_ph, from_ph ); }
-#endif
-
- BOOST_FILESYSTEM_DECL error_code
- create_symlink_api( const std::wstring & /*to_ph*/,
- const std::wstring & /*from_ph*/ )
- { return error_code( ERROR_NOT_SUPPORTED, system_category() ); }
-
- BOOST_FILESYSTEM_DECL error_code
- remove_api( const std::wstring & ph ) { return remove_template( ph ); }
-
- BOOST_FILESYSTEM_DECL error_code
- rename_api( const std::wstring & from, const std::wstring & to )
- {
- return error_code( ::MoveFileW( from.c_str(), to.c_str() )
- ? 0 : ::GetLastError(), system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- copy_file_api( const std::wstring & from, const std::wstring & to, bool fail_if_exists )
- {
- return error_code( ::CopyFileW( from.c_str(), to.c_str(), fail_if_exists )
- ? 0 : ::GetLastError(), system_category() );
- }
-
- BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph,
- std::ios_base::openmode mode ) // true if succeeds
- {
- DWORD access(
- ((mode & std::ios_base::in) == 0 ? 0 : GENERIC_READ)
- | ((mode & std::ios_base::out) == 0 ? 0 : GENERIC_WRITE) );
-
- DWORD disposition(0); // see 27.8.1.3 Table 92
- if ( (mode&~std::ios_base::binary)
- == (std::ios_base::out|std::ios_base::app) )
- disposition = OPEN_ALWAYS;
- else if ( (mode&~(std::ios_base::binary|std::ios_base::out))
- == std::ios_base::in ) disposition = OPEN_EXISTING;
- else if ( ((mode&~(std::ios_base::binary|std::ios_base::trunc))
- == std::ios_base::out )
- || ((mode&~std::ios_base::binary)
- == (std::ios_base::in|std::ios_base::out|std::ios_base::trunc)) )
- disposition = CREATE_ALWAYS;
- else BOOST_ASSERT( 0 && "invalid mode argument" );
-
- HANDLE handle ( ::CreateFileW( ph.c_str(), access,
- FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
- disposition, (mode &std::ios_base::out) != 0
- ? FILE_ATTRIBUTE_ARCHIVE : FILE_ATTRIBUTE_NORMAL, 0 ) );
- if ( handle == INVALID_HANDLE_VALUE ) return false;
- ::CloseHandle( handle );
- return true;
- }
-
- BOOST_FILESYSTEM_DECL std::string narrow_path_api(
- const std::wstring & ph ) // return is empty if fails
- {
- std::string narrow_short_form;
- std::wstring short_form;
- for ( DWORD buf_sz( static_cast<DWORD>( ph.size()+1 ));; )
- {
- boost::scoped_array<wchar_t> buf( new wchar_t[buf_sz] );
- DWORD sz( ::GetShortPathNameW( ph.c_str(), buf.get(), buf_sz ) );
- if ( sz == 0 ) return narrow_short_form;
- if ( sz <= buf_sz )
- {
- short_form += buf.get();
- break;
- }
- buf_sz = sz + 1;
- }
- // contributed by Takeshi Mouri:
- int narrow_sz( ::WideCharToMultiByte( CP_ACP, 0,
- short_form.c_str(), static_cast<int>(short_form.size()), 0, 0, 0, 0 ) );
- boost::scoped_array<char> narrow_buf( new char[narrow_sz] );
- ::WideCharToMultiByte( CP_ACP, 0,
- short_form.c_str(), static_cast<int>(short_form.size()),
- narrow_buf.get(), narrow_sz, 0, 0 );
- narrow_short_form.assign(narrow_buf.get(), narrow_sz);
-
- return narrow_short_form;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_first( void *& handle, const std::wstring & dir,
- std::wstring & target, file_status & sf, file_status & symlink_sf )
- {
- // use a form of search Sebastian Martel reports will work with Win98
- std::wstring dirpath( dir );
- dirpath += (dirpath.empty()
- || dirpath[dirpath.size()-1] != L'\\') ? L"\\*" : L"*";
-
- WIN32_FIND_DATAW data;
- if ( (handle = ::FindFirstFileW( dirpath.c_str(), &data ))
- == INVALID_HANDLE_VALUE )
- {
- handle = 0;
- return error_code( ::GetLastError() == ERROR_FILE_NOT_FOUND
- ? 0 : ::GetLastError(), system_category() );
- }
- target = data.cFileName;
- if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- { sf.type( directory_file ); symlink_sf.type( directory_file ); }
- else { sf.type( regular_file ); symlink_sf.type( regular_file ); }
- return ok;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_increment( void *& handle, std::wstring & target,
- file_status & sf, file_status & symlink_sf )
- {
- WIN32_FIND_DATAW data;
- if ( ::FindNextFileW( handle, &data ) == 0 ) // fails
- {
- int error = ::GetLastError();
- dir_itr_close( handle );
- return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, system_category() );
- }
- target = data.cFileName;
- if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- { sf.type( directory_file ); symlink_sf.type( directory_file ); }
- else { sf.type( regular_file ); symlink_sf.type( regular_file ); }
- return ok;
- }
-
-# endif // ifndef BOOST_FILESYSTEM2_NARROW_ONLY
-
- // suggested by Walter Landry
- BOOST_FILESYSTEM_DECL bool symbolic_link_exists_api( const std::string & )
- { return false; }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::query_pair is_empty_api( const std::string & ph )
- { return is_empty_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::query_pair
- equivalent_api( const std::string & ph1, const std::string & ph2 )
- { return equivalent_template( ph1, ph2 ); }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::uintmax_pair file_size_api( const std::string & ph )
- { return file_size_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- fs::detail::space_pair space_api( const std::string & ph )
- { return space_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- error_code
- get_current_path_api( std::string & ph )
- { return get_current_path_template( ph ); }
-
- BOOST_FILESYSTEM_DECL
- error_code
- set_current_path_api( const std::string & ph )
- { return set_current_path_template( ph ); }
-
- BOOST_FILESYSTEM_DECL error_code
- get_full_path_name_api( const std::string & ph, std::string & target )
- { return get_full_path_name_template( ph, target ); }
-
- BOOST_FILESYSTEM_DECL time_pair
- last_write_time_api( const std::string & ph )
- { return last_write_time_template( ph ); }
-
- BOOST_FILESYSTEM_DECL error_code
- last_write_time_api( const std::string & ph, std::time_t new_value )
- { return last_write_time_template( ph, new_value ); }
-
- BOOST_FILESYSTEM_DECL fs::detail::query_pair
- create_directory_api( const std::string & ph )
- { return create_directory_template( ph ); }
-
-#if _WIN32_WINNT >= 0x500
- BOOST_FILESYSTEM_DECL error_code
- create_hard_link_api( const std::string & to_ph,
- const std::string & from_ph )
- {
- return create_hard_link_template( to_ph, from_ph );
- }
-#endif
-
- BOOST_FILESYSTEM_DECL error_code
- create_symlink_api( const std::string & /*to_ph*/,
- const std::string & /*from_ph*/ )
- { return error_code( ERROR_NOT_SUPPORTED, system_category() ); }
-
- BOOST_FILESYSTEM_DECL error_code
- remove_api( const std::string & ph ) { return remove_template( ph ); }
-
- BOOST_FILESYSTEM_DECL error_code
- rename_api( const std::string & from, const std::string & to )
- {
- return error_code( ::MoveFileA( from.c_str(), to.c_str() )
- ? 0 : ::GetLastError(), system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- copy_file_api( const std::string & from, const std::string & to, bool fail_if_exists )
- {
- return error_code( ::CopyFileA( from.c_str(), to.c_str(), fail_if_exists )
- ? 0 : ::GetLastError(), system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_first( void *& handle, const std::string & dir,
- std::string & target, file_status & sf, file_status & symlink_sf )
- // Note: an empty root directory has no "." or ".." entries, so this
- // causes a ERROR_FILE_NOT_FOUND error which we do not considered an
- // error. It is treated as eof instead.
- {
- // use a form of search Sebastian Martel reports will work with Win98
- std::string dirpath( dir );
- dirpath += (dirpath.empty()
- || (dirpath[dirpath.size()-1] != '\\'
- && dirpath[dirpath.size()-1] != ':')) ? "\\*" : "*";
-
- WIN32_FIND_DATAA data;
- if ( (handle = ::FindFirstFileA( dirpath.c_str(), &data ))
- == INVALID_HANDLE_VALUE )
- {
- handle = 0;
- return error_code( (::GetLastError() == ERROR_FILE_NOT_FOUND
- // Windows Mobile returns ERROR_NO_MORE_FILES; see ticket #3551
- || ::GetLastError() == ERROR_NO_MORE_FILES)
- ? 0 : ::GetLastError(), system_category() );
- }
- target = data.cFileName;
- if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- { sf.type( directory_file ); symlink_sf.type( directory_file ); }
- else { sf.type( regular_file ); symlink_sf.type( regular_file ); }
- return ok;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_close( void *& handle )
- {
- if ( handle != 0 )
- {
- bool ok = ::FindClose( handle ) != 0;
- handle = 0;
- return error_code( ok ? 0 : ::GetLastError(), system_category() );
- }
- return ok;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_increment( void *& handle, std::string & target,
- file_status & sf, file_status & symlink_sf )
- {
- WIN32_FIND_DATAA data;
- if ( ::FindNextFileA( handle, &data ) == 0 ) // fails
- {
- int error = ::GetLastError();
- dir_itr_close( handle );
- return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, system_category() );
- }
- target = data.cFileName;
- if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
- { sf.type( directory_file ); symlink_sf.type( directory_file ); }
- else { sf.type( regular_file ); symlink_sf.type( regular_file ); }
- return ok;
- }
-
-# else // BOOST_POSIX_API
-
- BOOST_FILESYSTEM_DECL fs::file_status
- status_api( const std::string & ph, error_code & ec )
- {
- struct stat path_stat;
- if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- {
- if ( errno == ENOENT || errno == ENOTDIR )
- {
- ec = ok;
- return fs::file_status( fs::file_not_found );
- }
- ec = error_code( errno, system_category() );
- return fs::file_status( fs::status_unknown );
- }
- ec = ok;
- if ( S_ISDIR( path_stat.st_mode ) )
- return fs::file_status( fs::directory_file );
- if ( S_ISREG( path_stat.st_mode ) )
- return fs::file_status( fs::regular_file );
- if ( S_ISBLK( path_stat.st_mode ) )
- return fs::file_status( fs::block_file );
- if ( S_ISCHR( path_stat.st_mode ) )
- return fs::file_status( fs::character_file );
- if ( S_ISFIFO( path_stat.st_mode ) )
- return fs::file_status( fs::fifo_file );
- if ( S_ISSOCK( path_stat.st_mode ) )
- return fs::file_status( fs::socket_file );
- return fs::file_status( fs::type_unknown );
- }
-
- BOOST_FILESYSTEM_DECL fs::file_status
- symlink_status_api( const std::string & ph, error_code & ec )
- {
- struct stat path_stat;
- if ( ::lstat( ph.c_str(), &path_stat ) != 0 )
- {
- if ( errno == ENOENT || errno == ENOTDIR )
- {
- ec = ok;
- return fs::file_status( fs::file_not_found );
- }
- ec = error_code( errno, system_category() );
- return fs::file_status( fs::status_unknown );
- }
- ec = ok;
- if ( S_ISREG( path_stat.st_mode ) )
- return fs::file_status( fs::regular_file );
- if ( S_ISDIR( path_stat.st_mode ) )
- return fs::file_status( fs::directory_file );
- if ( S_ISLNK( path_stat.st_mode ) )
- return fs::file_status( fs::symlink_file );
- if ( S_ISBLK( path_stat.st_mode ) )
- return fs::file_status( fs::block_file );
- if ( S_ISCHR( path_stat.st_mode ) )
- return fs::file_status( fs::character_file );
- if ( S_ISFIFO( path_stat.st_mode ) )
- return fs::file_status( fs::fifo_file );
- if ( S_ISSOCK( path_stat.st_mode ) )
- return fs::file_status( fs::socket_file );
- return fs::file_status( fs::type_unknown );
- }
-
- // suggested by Walter Landry
- BOOST_FILESYSTEM_DECL bool
- symbolic_link_exists_api( const std::string & ph )
- {
- struct stat path_stat;
- return ::lstat( ph.c_str(), &path_stat ) == 0
- && S_ISLNK( path_stat.st_mode );
- }
-
- BOOST_FILESYSTEM_DECL query_pair
- is_empty_api( const std::string & ph )
- {
- struct stat path_stat;
- if ( (::stat( ph.c_str(), &path_stat )) != 0 )
- return std::make_pair( error_code( errno, system_category() ), false );
- return std::make_pair( ok, S_ISDIR( path_stat.st_mode )
- ? is_empty_directory( ph )
- : path_stat.st_size == 0 );
- }
-
- BOOST_FILESYSTEM_DECL query_pair
- equivalent_api( const std::string & ph1, const std::string & ph2 )
- {
- struct stat s2;
- int e2( ::stat( ph2.c_str(), &s2 ) );
- struct stat s1;
- int e1( ::stat( ph1.c_str(), &s1 ) );
- if ( e1 != 0 || e2 != 0 )
- return std::make_pair( error_code( e1 != 0 && e2 != 0 ? errno : 0, system_category() ), false );
- // at this point, both stats are known to be valid
- return std::make_pair( ok,
- s1.st_dev == s2.st_dev
- && s1.st_ino == s2.st_ino
- // According to the POSIX stat specs, "The st_ino and st_dev fields
- // taken together uniquely identify the file within the system."
- // Just to be sure, size and mod time are also checked.
- && s1.st_size == s2.st_size
- && s1.st_mtime == s2.st_mtime );
- }
-
- BOOST_FILESYSTEM_DECL uintmax_pair
- file_size_api( const std::string & ph )
- {
- struct stat path_stat;
- if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- return std::make_pair( error_code( errno, system_category() ), 0 );
- if ( !S_ISREG( path_stat.st_mode ) )
- return std::make_pair( error_code( EPERM, system_category() ), 0 );
- return std::make_pair( ok,
- static_cast<boost::uintmax_t>(path_stat.st_size) );
- }
-
- BOOST_FILESYSTEM_DECL space_pair
- space_api( const std::string & ph )
- {
- struct BOOST_STATVFS vfs;
- space_pair result;
- if ( ::BOOST_STATVFS( ph.c_str(), &vfs ) != 0 )
- {
- result.first = error_code( errno, system_category() );
- result.second.capacity = result.second.free
- = result.second.available = 0;
- }
- else
- {
- result.first = ok;
- result.second.capacity
- = static_cast<boost::uintmax_t>(vfs.f_blocks) * BOOST_STATVFS_F_FRSIZE;
- result.second.free
- = static_cast<boost::uintmax_t>(vfs.f_bfree) * BOOST_STATVFS_F_FRSIZE;
- result.second.available
- = static_cast<boost::uintmax_t>(vfs.f_bavail) * BOOST_STATVFS_F_FRSIZE;
- }
- return result;
- }
-
- BOOST_FILESYSTEM_DECL time_pair
- last_write_time_api( const std::string & ph )
- {
- struct stat path_stat;
- if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- return std::make_pair( error_code( errno, system_category() ), 0 );
- return std::make_pair( ok, path_stat.st_mtime );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- last_write_time_api( const std::string & ph, std::time_t new_value )
- {
- struct stat path_stat;
- if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- return error_code( errno, system_category() );
- ::utimbuf buf;
- buf.actime = path_stat.st_atime; // utime() updates access time too:-(
- buf.modtime = new_value;
- return error_code( ::utime( ph.c_str(), &buf ) != 0 ? errno : 0, system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- get_current_path_api( std::string & ph )
- {
- for ( long path_max = 32;; path_max *=2 ) // loop 'til buffer large enough
- {
- boost::scoped_array<char>
- buf( new char[static_cast<std::size_t>(path_max)] );
- if ( ::getcwd( buf.get(), static_cast<std::size_t>(path_max) ) == 0 )
- {
- if ( errno != ERANGE
- // bug in some versions of the Metrowerks C lib on the Mac: wrong errno set
-# if defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
- && errno != 0
-# endif
- ) return error_code( errno, system_category() );
- }
- else
- {
- ph = buf.get();
- break;
- }
- }
- return ok;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- set_current_path_api( const std::string & ph )
- {
- return error_code( ::chdir( ph.c_str() )
- ? errno : 0, system_category() );
- }
-
- BOOST_FILESYSTEM_DECL fs::detail::query_pair
- create_directory_api( const std::string & ph )
- {
- if ( ::mkdir( ph.c_str(), S_IRWXU|S_IRWXG|S_IRWXO ) == 0 )
- { return std::make_pair( ok, true ); }
- int ec=errno;
- error_code dummy;
- if ( ec != EEXIST
- || !fs::is_directory( status_api( ph, dummy ) ) )
- { return std::make_pair( error_code( ec, system_category() ), false ); }
- return std::make_pair( ok, false );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- create_hard_link_api( const std::string & to_ph,
- const std::string & from_ph )
- {
- return error_code( ::link( to_ph.c_str(), from_ph.c_str() ) == 0
- ? 0 : errno, system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- create_symlink_api( const std::string & to_ph,
- const std::string & from_ph )
- {
- return error_code( ::symlink( to_ph.c_str(), from_ph.c_str() ) == 0
- ? 0 : errno, system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- remove_api( const std::string & ph )
- {
- if ( posix_remove( ph.c_str() ) == 0 )
- return ok;
- int error = errno;
- // POSIX says "If the directory is not an empty directory, rmdir()
- // shall fail and set errno to EEXIST or ENOTEMPTY."
- // Linux uses ENOTEMPTY, Solaris uses EEXIST.
- if ( error == EEXIST ) error = ENOTEMPTY;
-
- error_code ec;
-
- // ignore errors if post-condition satisfied
- return status_api(ph, ec).type() == file_not_found
- ? ok : error_code( error, system_category() ) ;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- rename_api( const std::string & from, const std::string & to )
- {
- // POSIX is too permissive so must check
- error_code dummy;
- if ( fs::exists( status_api( to, dummy ) ) )
- return error_code( EEXIST, system_category() );
- return error_code( std::rename( from.c_str(), to.c_str() ) != 0
- ? errno : 0, system_category() );
- }
-
- BOOST_FILESYSTEM_DECL error_code
- copy_file_api( const std::string & from_file_ph,
- const std::string & to_file_ph, bool fail_if_exists )
- {
- const std::size_t buf_sz = 32768;
- boost::scoped_array<char> buf( new char [buf_sz] );
- int infile=-1, outfile=-1; // -1 means not open
-
- // bug fixed: code previously did a stat() on the from_file first, but that
- // introduced a gratuitous race condition; the stat() is now done after the open()
-
- if ( (infile = ::open( from_file_ph.c_str(), O_RDONLY )) < 0 )
- { return error_code( errno, system_category() ); }
-
- struct stat from_stat;
- if ( ::stat( from_file_ph.c_str(), &from_stat ) != 0 )
- { return error_code( errno, system_category() ); }
-
- int oflag = O_CREAT | O_WRONLY | O_TRUNC;
- if ( fail_if_exists )
- oflag |= O_EXCL;
- if ( (outfile = ::open( to_file_ph.c_str(), oflag, from_stat.st_mode )) < 0 )
- {
- int open_errno = errno;
- BOOST_ASSERT( infile >= 0 );
- ::close( infile );
- return error_code( open_errno, system_category() );
- }
-
- ssize_t sz, sz_read=1, sz_write;
- while ( sz_read > 0
- && (sz_read = ::read( infile, buf.get(), buf_sz )) > 0 )
- {
- // Allow for partial writes - see Advanced Unix Programming (2nd Ed.),
- // Marc Rochkind, Addison-Wesley, 2004, page 94
- sz_write = 0;
- do
- {
- if ( (sz = ::write( outfile, buf.get() + sz_write,
- sz_read - sz_write )) < 0 )
- {
- sz_read = sz; // cause read loop termination
- break; // and error to be thrown after closes
- }
- sz_write += sz;
- } while ( sz_write < sz_read );
- }
-
- if ( ::close( infile) < 0 ) sz_read = -1;
- if ( ::close( outfile) < 0 ) sz_read = -1;
-
- return error_code( sz_read < 0 ? errno : 0, system_category() );
- }
-
- // this code is based on Stevens and Rago, Advanced Programming in the
- // UNIX envirnment, 2nd Ed., ISBN 0-201-43307-9, page 49
- error_code path_max( std::size_t & result )
- {
-# ifdef PATH_MAX
- static std::size_t max = PATH_MAX;
-# else
- static std::size_t max = 0;
-# endif
- if ( max == 0 )
- {
- errno = 0;
- long tmp = ::pathconf( "/", _PC_NAME_MAX );
- if ( tmp < 0 )
- {
- if ( errno == 0 ) // indeterminate
- max = 4096; // guess
- else return error_code( errno, system_category() );
- }
- else max = static_cast<std::size_t>( tmp + 1 ); // relative root
- }
- result = max;
- return ok;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_first( void *& handle, void *& buffer,
- const std::string & dir, std::string & target,
- file_status &, file_status & )
- {
- if ( (handle = ::opendir( dir.c_str() )) == 0 )
- return error_code( errno, system_category() );
- target = std::string( "." ); // string was static but caused trouble
- // when iteration called from dtor, after
- // static had already been destroyed
- std::size_t path_size (0); // initialization quiets gcc warning
- error_code ec = path_max( path_size );
- if ( ec ) return ec;
- dirent de;
- buffer = std::malloc( (sizeof(dirent) - sizeof(de.d_name))
- + path_size + 1 ); // + 1 for "/0"
- return ok;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_close( void *& handle, void*& buffer )
- {
- std::free( buffer );
- buffer = 0;
- if ( handle == 0 ) return ok;
- DIR * h( static_cast<DIR*>(handle) );
- handle = 0;
- return error_code( ::closedir( h ) == 0 ? 0 : errno, system_category() );
- }
-
- // warning: the only dirent member updated is d_name
- inline int readdir_r_simulator( DIR * dirp, struct dirent * entry,
- struct dirent ** result ) // *result set to 0 on end of directory
- {
- errno = 0;
-
- # if !defined(__CYGWIN__) \
- && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
- && defined(_SC_THREAD_SAFE_FUNCTIONS) \
- && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0) \
- && (!defined(__hpux) || defined(_REENTRANT)) \
- && (!defined(_AIX) || defined(__THREAD_SAFE))
- if ( ::sysconf( _SC_THREAD_SAFE_FUNCTIONS ) >= 0 )
- { return ::readdir_r( dirp, entry, result ); }
- # endif
-
- struct dirent * p;
- *result = 0;
- if ( (p = ::readdir( dirp )) == 0 )
- return errno;
- std::strcpy( entry->d_name, p->d_name );
- *result = entry;
- return 0;
- }
-
- BOOST_FILESYSTEM_DECL error_code
- dir_itr_increment( void *& handle, void *& buffer,
- std::string & target, file_status & sf, file_status & symlink_sf )
- {
- BOOST_ASSERT( buffer != 0 );
- dirent * entry( static_cast<dirent *>(buffer) );
- dirent * result;
- int return_code;
- if ( (return_code = readdir_r_simulator( static_cast<DIR*>(handle),
- entry, &result )) != 0 ) return error_code( errno, system_category() );
- if ( result == 0 ) return dir_itr_close( handle, buffer );
- target = entry->d_name;
-# ifdef BOOST_FILESYSTEM_STATUS_CACHE
- if ( entry->d_type == DT_UNKNOWN ) // filesystem does not supply d_type value
- {
- sf = symlink_sf = fs::file_status(fs::status_unknown);
- }
- else // filesystem supplies d_type value
- {
- if ( entry->d_type == DT_DIR )
- sf = symlink_sf = fs::file_status( fs::directory_file );
- else if ( entry->d_type == DT_REG )
- sf = symlink_sf = fs::file_status( fs::regular_file );
- else if ( entry->d_type == DT_LNK )
- {
- sf = fs::file_status( fs::status_unknown );
- symlink_sf = fs::file_status( fs::symlink_file );
- }
- else sf = symlink_sf = fs::file_status( fs::status_unknown );
- }
-# else
- sf = symlink_sf = fs::file_status( fs::status_unknown );
-# endif
- return ok;
- }
-
-# endif
- } // namespace detail
- } // namespace filesystem2
-} // namespace boost
diff --git a/3rdParty/Boost/src/libs/filesystem/v2/src/v2_path.cpp b/3rdParty/Boost/src/libs/filesystem/v2/src/v2_path.cpp
deleted file mode 100644
index 16f6583..0000000
--- a/3rdParty/Boost/src/libs/filesystem/v2/src/v2_path.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-// path.cpp ----------------------------------------------------------------//
-
-// Copyright 2005 Beman Dawes
-
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-// See library home page at http://www.boost.org/libs/filesystem
-
-//----------------------------------------------------------------------------//
-
-// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
-// the library is being built (possibly exporting rather than importing code)
-#define BOOST_FILESYSTEM_SOURCE
-
-#ifndef BOOST_SYSTEM_NO_DEPRECATED
-# define BOOST_SYSTEM_NO_DEPRECATED
-#endif
-
-#include <boost/filesystem/v2/config.hpp>
-
-#ifndef BOOST_FILESYSTEM2_NARROW_ONLY
-
-#include <boost/filesystem/v2/path.hpp>
-#include <boost/scoped_array.hpp>
-
-#include <locale>
-#include <boost/cerrno.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <cwchar> // for std::mbstate_t
-
-#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-# include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
-#endif
-
-
-namespace
-{
- // std::locale construction can throw (if LC_MESSAGES is wrong, for example),
- // so a static at function scope is used to ensure that exceptions can be
- // caught. (A previous version was at namespace scope, so initialization
- // occurred before main(), preventing exceptions from being caught.)
- std::locale & loc()
- {
-#if !defined(macintosh) && !defined(__APPLE__) && !defined(__APPLE_CC__)
- // ISO C calls this "the locale-specific native environment":
- static std::locale lc("");
-#else // Mac OS
- // "All BSD system functions expect their string parameters to be in UTF-8 encoding
- // and nothing else."
- // See http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html
- std::locale global_loc = std::locale(); // Mac OS doesn't support locale("")
- static std::locale lc(global_loc,
- new boost::filesystem::detail::utf8_codecvt_facet);
-#endif
- return lc;
- }
-
- const std::codecvt<wchar_t, char, std::mbstate_t> *&
- converter()
- {
- static const std::codecvt<wchar_t, char, std::mbstate_t> *
- cvtr(
- &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
- ( loc() ) );
- return cvtr;
- }
-
- bool locked(false);
-} // unnamed namespace
-
-namespace boost
-{
- namespace filesystem2
- {
- bool wpath_traits::imbue( const std::locale & new_loc, const std::nothrow_t & )
- {
- if ( locked ) return false;
- locked = true;
- loc() = new_loc;
- converter() = &std::use_facet
- <std::codecvt<wchar_t, char, std::mbstate_t> >( loc() );
- return true;
- }
-
- void wpath_traits::imbue( const std::locale & new_loc )
- {
- if ( locked ) BOOST_FILESYSTEM_THROW(
- wfilesystem_error(
- "boost::filesystem::wpath_traits::imbue() after lockdown",
- make_error_code( system::errc::not_supported ) ) );
- imbue( new_loc, std::nothrow );
- }
-
- //namespace detail
- //{
- // BOOST_FILESYSTEM_DECL
- // const char * what( const char * sys_err_what,
- // const path & path1, const path & path2, std::string & target)
- // {
- // try
- // {
- // if ( target.empty() )
- // {
- // target = sys_err_what;
- // if ( !path1.empty() )
- // {
- // target += ": \"";
- // target += path1.file_string();
- // target += "\"";
- // }
- // if ( !path2.empty() )
- // {
- // target += ", \"";
- // target += path2.file_string();
- // target += "\"";
- // }
- // }
- // return target.c_str();
- // }
- // catch (...)
- // {
- // return sys_err_what;
- // }
- // }
- //}
-
-# ifdef BOOST_POSIX_API
-
-// Because this is POSIX only code, we don't have to worry about ABI issues
-// described in http://www.boost.org/more/separate_compilation.html
-
- wpath_traits::external_string_type
- wpath_traits::to_external( const wpath & ph,
- const internal_string_type & src )
- {
- locked = true;
- std::size_t work_size( converter()->max_length() * (src.size()+1) );
- boost::scoped_array<char> work( new char[ work_size ] );
- std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const internal_string_type::value_type * from_next;
- external_string_type::value_type * to_next;
- if ( converter()->out(
- state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
- work.get()+work_size, to_next ) != std::codecvt_base::ok )
- BOOST_FILESYSTEM_THROW( boost::filesystem::wfilesystem_error(
- "boost::filesystem::wpath::to_external conversion error",
- ph, system::error_code( system::errc::invalid_argument, system::system_category() ) ) );
- *to_next = '\0';
- return external_string_type( work.get() );
- }
-
- wpath_traits::internal_string_type
- wpath_traits::to_internal( const external_string_type & src )
- {
- locked = true;
- std::size_t work_size( src.size()+1 );
- boost::scoped_array<wchar_t> work( new wchar_t[ work_size ] );
- std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
- const external_string_type::value_type * from_next;
- internal_string_type::value_type * to_next;
- if ( converter()->in(
- state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
- work.get()+work_size, to_next ) != std::codecvt_base::ok )
- BOOST_FILESYSTEM_THROW( boost::filesystem::wfilesystem_error(
- "boost::filesystem::wpath::to_internal conversion error",
- system::error_code( system::errc::invalid_argument, system::system_category() ) ) );
- *to_next = L'\0';
- return internal_string_type( work.get() );
- }
-# endif // BOOST_POSIX_API
-
- } // namespace filesystem2
-} // namespace boost
-
-#endif // ifndef BOOST_FILESYSTEM2_NARROW_ONLY
diff --git a/3rdParty/Boost/src/libs/filesystem/v2/src/v2_portability.cpp b/3rdParty/Boost/src/libs/filesystem/v2/src/v2_portability.cpp
deleted file mode 100644
index 4d27543..0000000
--- a/3rdParty/Boost/src/libs/filesystem/v2/src/v2_portability.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-// portability.cpp ---------------------------------------------------------//
-
-// Copyright 2002-2005 Beman Dawes
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
-// at http://www.boost.org/LICENSE_1_0.txt)
-
-// See library home page at http://www.boost.org/libs/filesystem
-
-//----------------------------------------------------------------------------//
-
-// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
-// the library is being built (possibly exporting rather than importing code)
-#define BOOST_FILESYSTEM_SOURCE
-
-#ifndef BOOST_SYSTEM_NO_DEPRECATED
-# define BOOST_SYSTEM_NO_DEPRECATED
-#endif
-
-#include <boost/filesystem/v2/config.hpp>
-#include <boost/filesystem/v2/path.hpp>
-
-namespace fs = boost::filesystem2;
-
-#include <cstring> // SGI MIPSpro compilers need this
-
-# ifdef BOOST_NO_STDC_NAMESPACE
- namespace std { using ::strerror; }
-# endif
-
-//----------------------------------------------------------------------------//
-
-namespace
-{
- const char invalid_chars[] =
- "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
- "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
- "<>:\"/\\|";
- // note that the terminating '\0' is part of the string - thus the size below
- // is sizeof(invalid_chars) rather than sizeof(invalid_chars)-1. I
- const std::string windows_invalid_chars( invalid_chars, sizeof(invalid_chars) );
-
- const std::string valid_posix(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-" );
-
-} // unnamed namespace
-
-namespace boost
-{
- namespace filesystem2
- {
-
- // name_check functions ----------------------------------------------//
-
-# ifdef BOOST_WINDOWS
- BOOST_FILESYSTEM_DECL bool native( const std::string & name )
- {
- return windows_name( name );
- }
-# else
- BOOST_FILESYSTEM_DECL bool native( const std::string & name )
- {
- return name.size() != 0
- && name[0] != ' '
- && name.find('/') == std::string::npos;
- }
-# endif
-
- BOOST_FILESYSTEM_DECL bool portable_posix_name( const std::string & name )
- {
- return name.size() != 0
- && name.find_first_not_of( valid_posix ) == std::string::npos;
- }
-
- BOOST_FILESYSTEM_DECL bool windows_name( const std::string & name )
- {
- return name.size() != 0
- && name[0] != ' '
- && name.find_first_of( windows_invalid_chars ) == std::string::npos
- && *(name.end()-1) != ' '
- && (*(name.end()-1) != '.'
- || name.length() == 1 || name == "..");
- }
-
- BOOST_FILESYSTEM_DECL bool portable_name( const std::string & name )
- {
- return
- name.size() != 0
- && ( name == "."
- || name == ".."
- || (windows_name( name )
- && portable_posix_name( name )
- && name[0] != '.' && name[0] != '-'));
- }
-
- BOOST_FILESYSTEM_DECL bool portable_directory_name( const std::string & name )
- {
- return
- name == "."
- || name == ".."
- || (portable_name( name )
- && name.find('.') == std::string::npos);
- }
-
- BOOST_FILESYSTEM_DECL bool portable_file_name( const std::string & name )
- {
- std::string::size_type pos;
- return
- portable_name( name )
- && name != "."
- && name != ".."
- && ( (pos = name.find( '.' )) == std::string::npos
- || (name.find( '.', pos+1 ) == std::string::npos
- && (pos + 5) > name.length() ))
- ;
- }
-
- } // namespace filesystem2
-} // namespace boost
diff --git a/3rdParty/Boost/src/libs/program_options/src/cmdline.cpp b/3rdParty/Boost/src/libs/program_options/src/cmdline.cpp
index be31385..cd9a5fe 100644
--- a/3rdParty/Boost/src/libs/program_options/src/cmdline.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/cmdline.cpp
@@ -34,64 +34,43 @@ namespace boost { namespace program_options {
using namespace std;
using namespace boost::program_options::command_line_style;
- invalid_syntax::
- invalid_syntax(const string& tokens, kind_t kind)
- : error(error_message(kind).append(" in '").append(tokens).append("'"))
- , m_tokens(tokens)
- , m_kind(kind)
- {}
string
- invalid_syntax::error_message(kind_t kind)
+ invalid_syntax::get_template(kind_t kind)
{
// Initially, store the message in 'const char*' variable,
// to avoid conversion to string in all cases.
const char* msg;
switch(kind)
{
+ case empty_adjacent_parameter:
+ msg = "the argument for option '%canonical_option%' should follow immediately after the equal sign";
+ break;
+ case missing_parameter:
+ msg = "the required argument for option '%canonical_option%' is missing";
+ break;
+ case unrecognized_line:
+ msg = "the options configuration file contains an invalid line '%invalid_line%'";
+ break;
+ // none of the following are currently used:
case long_not_allowed:
- msg = "long options are not allowed";
+ msg = "the unabbreviated option '%canonical_option%' is not valid";
break;
case long_adjacent_not_allowed:
- msg = "parameters adjacent to long options not allowed";
+ msg = "the unabbreviated option '%canonical_option%' does not take any arguments";
break;
case short_adjacent_not_allowed:
- msg = "parameters adjust to short options are not allowed";
- break;
- case empty_adjacent_parameter:
- msg = "adjacent parameter is empty";
- break;
- case missing_parameter:
- msg = "required parameter is missing";
+ msg = "the abbreviated option '%canonical_option%' does not take any arguments";
break;
case extra_parameter:
- msg = "extra parameter";
- break;
- case unrecognized_line:
- msg = "unrecognized line";
+ msg = "option '%canonical_option%' does not take any arguments";
break;
default:
- msg = "unknown error";
+ msg = "unknown command line syntax error for '%s'";
}
return msg;
}
- invalid_syntax::kind_t
- invalid_syntax::kind() const
- {
- return m_kind;
- }
-
- const string&
- invalid_syntax::tokens() const
- {
- return m_tokens;
- }
-
- invalid_command_line_syntax::
- invalid_command_line_syntax(const string& tokens, kind_t kind)
- : invalid_syntax(tokens, kind)
- {}
}}
@@ -156,15 +135,26 @@ namespace boost { namespace program_options { namespace detail {
const char* error = 0;
if (allow_some_long &&
!(style & long_allow_adjacent) && !(style & long_allow_next))
- error = "style disallows parameters for long options";
+ error = "boost::program_options misconfiguration: "
+ "choose one or other of 'command_line_style::long_allow_next' "
+ "(whitespace separated arguments) or "
+ "'command_line_style::long_allow_adjacent' ('=' separated arguments) for "
+ "long options.";
if (!error && (style & allow_short) &&
!(style & short_allow_adjacent) && !(style & short_allow_next))
- error = "style disallows parameters for short options";
+ error = "boost::program_options misconfiguration: "
+ "choose one or other of 'command_line_style::short_allow_next' "
+ "(whitespace separated arguments) or "
+ "'command_line_style::short_allow_adjacent' ('=' separated arguments) for "
+ "short options.";
if (!error && (style & allow_short) &&
!(style & allow_dash_for_short) && !(style & allow_slash_for_short))
- error = "style disallows all characters for short options";
+ error = "boost::program_options misconfiguration: "
+ "choose one or other of 'command_line_style::allow_slash_for_short' "
+ "(slashes) or 'command_line_style::allow_dash_for_short' (dashes) for "
+ "short options.";
if (error)
boost::throw_exception(invalid_command_line_style(error));
@@ -192,6 +182,23 @@ namespace boost { namespace program_options { namespace detail {
m_positional = &positional;
}
+ int
+ cmdline::get_canonical_option_prefix()
+ {
+ if (m_style & allow_long)
+ return allow_long;
+
+ if (m_style & allow_long_disguise)
+ return allow_long_disguise;
+
+ if ((m_style & allow_short) && (m_style & allow_dash_for_short))
+ return allow_dash_for_short;
+
+ if ((m_style & allow_short) && (m_style & allow_slash_for_short))
+ return allow_slash_for_short;
+
+ return 0;
+ }
vector<option>
cmdline::run()
@@ -242,7 +249,7 @@ namespace boost { namespace program_options { namespace detail {
bool ok = false;
for(unsigned i = 0; i < style_parsers.size(); ++i)
{
- unsigned current_size = args.size();
+ unsigned current_size = static_cast<unsigned>(args.size());
vector<option> next = style_parsers[i](args);
// Check that option names
@@ -277,7 +284,7 @@ namespace boost { namespace program_options { namespace detail {
}
/* If an key option is followed by a positional option,
- can can consume more tokens (e.g. it's multitoke option),
+ can can consume more tokens (e.g. it's multitoken option),
give those tokens to it. */
vector<option> result2;
for (unsigned i = 0; i < result.size(); ++i)
@@ -288,11 +295,21 @@ namespace boost { namespace program_options { namespace detail {
if (opt.string_key.empty())
continue;
- const option_description* xd =
- m_desc->find_nothrow(opt.string_key,
- is_style_active(allow_guessing),
- is_style_active(long_case_insensitive),
- is_style_active(short_case_insensitive));
+ const option_description* xd;
+ try
+ {
+ xd = m_desc->find_nothrow(opt.string_key,
+ is_style_active(allow_guessing),
+ is_style_active(long_case_insensitive),
+ is_style_active(short_case_insensitive));
+ }
+ catch(error_with_option_name& e)
+ {
+ // add context and rethrow
+ e.add_context(opt.string_key, opt.original_tokens[0], get_canonical_option_prefix());
+ throw;
+ }
+
if (!xd)
continue;
@@ -304,7 +321,7 @@ namespace boost { namespace program_options { namespace detail {
// We only allow to grab tokens that are not already
// recognized as key options.
- int can_take_more = max_tokens - opt.value.size();
+ int can_take_more = max_tokens - static_cast<int>(opt.value.size());
unsigned j = i+1;
for (; can_take_more && j < result.size(); --can_take_more, ++j)
{
@@ -383,92 +400,112 @@ namespace boost { namespace program_options { namespace detail {
if (opt.string_key.empty())
return;
- // First check that the option is valid, and get its description.
- const option_description* xd = m_desc->find_nothrow(opt.string_key,
- is_style_active(allow_guessing),
- is_style_active(long_case_insensitive),
- is_style_active(short_case_insensitive));
+ //
+ // Be defensive:
+ // will have no original token if option created by handle_additional_parser()
+ std::string original_token_for_exceptions = opt.string_key;
+ if (opt.original_tokens.size())
+ original_token_for_exceptions = opt.original_tokens[0];
- if (!xd)
+ try
{
- if (m_allow_unregistered) {
- opt.unregistered = true;
- return;
- } else {
- boost::throw_exception(unknown_option(opt.string_key));
- }
- }
- const option_description& d = *xd;
+ // First check that the option is valid, and get its description.
+ const option_description* xd = m_desc->find_nothrow(opt.string_key,
+ is_style_active(allow_guessing),
+ is_style_active(long_case_insensitive),
+ is_style_active(short_case_insensitive));
- // Canonize the name
- opt.string_key = d.key(opt.string_key);
+ if (!xd)
+ {
+ if (m_allow_unregistered) {
+ opt.unregistered = true;
+ return;
+ } else {
+ boost::throw_exception(unknown_option());
+ }
+ }
+ const option_description& d = *xd;
- // We check that the min/max number of tokens for the option
- // agrees with the number of tokens we have. The 'adjacent_value'
- // (the value in --foo=1) counts as a separate token, and if present
- // must be consumed. The following tokens on the command line may be
- // left unconsumed.
+ // Canonize the name
+ opt.string_key = d.key(opt.string_key);
- // We don't check if those tokens look like option, or not!
+ // We check that the min/max number of tokens for the option
+ // agrees with the number of tokens we have. The 'adjacent_value'
+ // (the value in --foo=1) counts as a separate token, and if present
+ // must be consumed. The following tokens on the command line may be
+ // left unconsumed.
- unsigned min_tokens = d.semantic()->min_tokens();
- unsigned max_tokens = d.semantic()->max_tokens();
-
- unsigned present_tokens = opt.value.size() + other_tokens.size();
-
- if (present_tokens >= min_tokens)
- {
- if (!opt.value.empty() && max_tokens == 0)
- {
- boost::throw_exception(invalid_command_line_syntax(opt.string_key,
- invalid_command_line_syntax::extra_parameter));
- }
-
- // If an option wants, at minimum, N tokens, we grab them there,
- // when adding these tokens as values to current option we check
- // if they look like options
- if (opt.value.size() <= min_tokens)
- {
- min_tokens -= opt.value.size();
- }
- else
- {
- min_tokens = 0;
- }
+ // We don't check if those tokens look like option, or not!
- // Everything's OK, move the values to the result.
- for(;!other_tokens.empty() && min_tokens--; )
+ unsigned min_tokens = d.semantic()->min_tokens();
+ unsigned max_tokens = d.semantic()->max_tokens();
+
+ unsigned present_tokens = static_cast<unsigned>(opt.value.size() + other_tokens.size());
+
+ if (present_tokens >= min_tokens)
{
- // check if extra parameter looks like a known option
- // we use style parsers to check if it is syntactically an option,
- // additionally we check if an option_description exists
- vector<option> followed_option;
- vector<string> next_token(1, other_tokens[0]);
- for (unsigned i = 0; followed_option.empty() && i < style_parsers.size(); ++i)
+ if (!opt.value.empty() && max_tokens == 0)
+ {
+ boost::throw_exception(
+ invalid_command_line_syntax(invalid_command_line_syntax::extra_parameter));
+ }
+
+ // If an option wants, at minimum, N tokens, we grab them there,
+ // when adding these tokens as values to current option we check
+ // if they look like options
+ if (opt.value.size() <= min_tokens)
{
- followed_option = style_parsers[i](next_token);
+ min_tokens -= static_cast<unsigned>(opt.value.size());
}
- if (!followed_option.empty())
+ else
{
- const option_description* od = m_desc->find_nothrow(other_tokens[0],
- is_style_active(allow_guessing),
- is_style_active(long_case_insensitive),
- is_style_active(short_case_insensitive));
- if (od)
- boost::throw_exception(invalid_command_line_syntax(opt.string_key,
- invalid_command_line_syntax::missing_parameter));
+ min_tokens = 0;
+ }
+
+ // Everything's OK, move the values to the result.
+ for(;!other_tokens.empty() && min_tokens--; )
+ {
+ // check if extra parameter looks like a known option
+ // we use style parsers to check if it is syntactically an option,
+ // additionally we check if an option_description exists
+ vector<option> followed_option;
+ vector<string> next_token(1, other_tokens[0]);
+ for (unsigned i = 0; followed_option.empty() && i < style_parsers.size(); ++i)
+ {
+ followed_option = style_parsers[i](next_token);
+ }
+ if (!followed_option.empty())
+ {
+ original_token_for_exceptions = other_tokens[0];
+ const option_description* od = m_desc->find_nothrow(other_tokens[0],
+ is_style_active(allow_guessing),
+ is_style_active(long_case_insensitive),
+ is_style_active(short_case_insensitive));
+ if (od)
+ boost::throw_exception(
+ invalid_command_line_syntax(invalid_command_line_syntax::missing_parameter));
+ }
+ opt.value.push_back(other_tokens[0]);
+ opt.original_tokens.push_back(other_tokens[0]);
+ other_tokens.erase(other_tokens.begin());
}
- opt.value.push_back(other_tokens[0]);
- opt.original_tokens.push_back(other_tokens[0]);
- other_tokens.erase(other_tokens.begin());
}
- }
- else
- {
- boost::throw_exception(invalid_command_line_syntax(opt.string_key,
- invalid_command_line_syntax::missing_parameter));
+ else
+ {
+ boost::throw_exception(
+ invalid_command_line_syntax(invalid_command_line_syntax::missing_parameter));
+ }
+ }
+ // use only original token for unknown_option / ambiguous_option since by definition
+ // they are unrecognised / unparsable
+ catch(error_with_option_name& e)
+ {
+ // add context and rethrow
+ e.add_context(opt.string_key, original_token_for_exceptions, get_canonical_option_prefix());
+ throw;
}
+
}
vector<option>
@@ -486,8 +523,11 @@ namespace boost { namespace program_options { namespace detail {
name = tok.substr(2, p-2);
adjacent = tok.substr(p+1);
if (adjacent.empty())
- boost::throw_exception( invalid_command_line_syntax(name,
- invalid_command_line_syntax::empty_adjacent_parameter) );
+ boost::throw_exception( invalid_command_line_syntax(
+ invalid_command_line_syntax::empty_adjacent_parameter,
+ name,
+ name,
+ get_canonical_option_prefix()) );
}
else
{
@@ -523,9 +563,20 @@ namespace boost { namespace program_options { namespace detail {
// of token is considered to be value, not further grouped
// option.
for(;;) {
- const option_description* d
- = m_desc->find_nothrow(name, false, false,
- is_style_active(short_case_insensitive));
+ const option_description* d;
+ try
+ {
+
+ d = m_desc->find_nothrow(name, false, false,
+ is_style_active(short_case_insensitive));
+ }
+ catch(error_with_option_name& e)
+ {
+ // add context and rethrow
+ e.add_context(name, name, get_canonical_option_prefix());
+ throw;
+ }
+
// FIXME: check for 'allow_sticky'.
if (d && (m_style & allow_sticky) &&
@@ -589,15 +640,24 @@ namespace boost { namespace program_options { namespace detail {
((tok[0] == '-' && tok[1] != '-') ||
((m_style & allow_slash_for_short) && tok[0] == '/')))
{
- if (m_desc->find_nothrow(tok.substr(1, tok.find('=')-1),
- is_style_active(allow_guessing),
- is_style_active(long_case_insensitive),
- is_style_active(short_case_insensitive)))
+ try
+ {
+ if (m_desc->find_nothrow(tok.substr(1, tok.find('=')-1),
+ is_style_active(allow_guessing),
+ is_style_active(long_case_insensitive),
+ is_style_active(short_case_insensitive)))
+ {
+ args[0].insert(0, "-");
+ if (args[0][1] == '/')
+ args[0][1] = '-';
+ return parse_long_option(args);
+ }
+ }
+ catch(error_with_option_name& e)
{
- args[0].insert(0, "-");
- if (args[0][1] == '/')
- args[0][1] = '-';
- return parse_long_option(args);
+ // add context and rethrow
+ e.add_context(tok, tok, get_canonical_option_prefix());
+ throw;
}
}
return vector<option>();
diff --git a/3rdParty/Boost/src/libs/program_options/src/config_file.cpp b/3rdParty/Boost/src/libs/program_options/src/config_file.cpp
index a12844c..f2a57b4 100644
--- a/3rdParty/Boost/src/libs/program_options/src/config_file.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/config_file.cpp
@@ -57,7 +57,9 @@ namespace boost { namespace program_options { namespace detail {
bad_prefixes = true;
}
if (bad_prefixes)
- boost::throw_exception(error("bad prefixes"));
+ boost::throw_exception(error("options '" + string(name) + "' and '" +
+ *i + "*' will both match the same "
+ "arguments from the configuration file"));
allowed_prefixes.insert(s);
}
}
@@ -117,7 +119,7 @@ namespace boost { namespace program_options { namespace detail {
break;
} else {
- boost::throw_exception(invalid_syntax(s, invalid_syntax::unrecognized_line));
+ boost::throw_exception(invalid_config_file_syntax(s, invalid_syntax::unrecognized_line));
}
}
}
diff --git a/3rdParty/Boost/src/libs/program_options/src/options_description.cpp b/3rdParty/Boost/src/libs/program_options/src/options_description.cpp
index 0d8dfd4..343bd30 100644
--- a/3rdParty/Boost/src/libs/program_options/src/options_description.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/options_description.cpp
@@ -137,6 +137,31 @@ namespace boost { namespace program_options {
return m_short_name;
}
+ std::string
+ option_description::canonical_display_name(int prefix_style) const
+ {
+ if (!m_long_name.empty())
+ {
+ if (prefix_style == command_line_style::allow_long)
+ return "--" + m_long_name;
+ if (prefix_style == command_line_style::allow_long_disguise)
+ return "-" + m_long_name;
+ }
+ // sanity check: m_short_name[0] should be '-' or '/'
+ if (m_short_name.length() == 2)
+ {
+ if (prefix_style == command_line_style::allow_slash_for_short)
+ return string("/") + m_short_name[1];
+ if (prefix_style == command_line_style::allow_dash_for_short)
+ return string("-") + m_short_name[1];
+ }
+ if (!m_long_name.empty())
+ return m_long_name;
+ else
+ return m_short_name;
+ }
+
+
const std::string&
option_description::long_name() const
{
@@ -174,10 +199,13 @@ namespace boost { namespace program_options {
option_description::format_name() const
{
if (!m_short_name.empty())
- return string(m_short_name).append(" [ --").
- append(m_long_name).append(" ]");
- else
- return string("--").append(m_long_name);
+ {
+ return m_long_name.empty()
+ ? m_short_name
+ : string(m_short_name).append(" [ --").
+ append(m_long_name).append(" ]");
+ }
+ return string("--").append(m_long_name);
}
std::string
@@ -289,7 +317,7 @@ namespace boost { namespace program_options {
const option_description* d = find_nothrow(name, approx,
long_ignore_case, short_ignore_case);
if (!d)
- boost::throw_exception(unknown_option(name));
+ boost::throw_exception(unknown_option());
return *d;
}
@@ -337,8 +365,7 @@ namespace boost { namespace program_options {
}
}
if (full_matches.size() > 1)
- boost::throw_exception(
- ambiguous_option(name, full_matches));
+ boost::throw_exception(ambiguous_option(full_matches));
// If we have a full match, and an approximate match,
// ignore approximate match instead of reporting error.
@@ -346,8 +373,7 @@ namespace boost { namespace program_options {
// "--all" on the command line should select the first one,
// without ambiguity.
if (full_matches.empty() && approximate_matches.size() > 1)
- boost::throw_exception(
- ambiguous_option(name, approximate_matches));
+ boost::throw_exception(ambiguous_option(approximate_matches));
return found.get();
}
@@ -396,7 +422,7 @@ namespace boost { namespace program_options {
if (count(par.begin(), par.end(), '\t') > 1)
{
boost::throw_exception(program_options::error(
- "Only one tab per paragraph is allowed"));
+ "Only one tab per paragraph is allowed in the options description"));
}
// erase tab from string
@@ -443,7 +469,7 @@ namespace boost { namespace program_options {
// Take care to never increment the iterator past
// the end, since MSVC 8.0 (brokenly), assumes that
// doing that, even if no access happens, is a bug.
- unsigned remaining = distance(line_begin, par_end);
+ unsigned remaining = static_cast<unsigned>(std::distance(line_begin, par_end));
string::const_iterator line_end = line_begin +
((remaining < line_length) ? remaining : line_length);
@@ -463,7 +489,7 @@ namespace boost { namespace program_options {
{
// is last_space within the second half ot the
// current line
- if (static_cast<unsigned>(distance(last_space, line_end)) <
+ if (static_cast<unsigned>(std::distance(last_space, line_end)) <
(line_length / 2))
{
line_end = last_space;
@@ -476,8 +502,8 @@ namespace boost { namespace program_options {
if (first_line)
{
- indent += par_indent;
- line_length -= par_indent; // there's less to work with now
+ indent += static_cast<unsigned>(par_indent);
+ line_length -= static_cast<unsigned>(par_indent); // there's less to work with now
first_line = false;
}
@@ -566,7 +592,7 @@ namespace boost { namespace program_options {
os.put(' ');
}
} else {
- for(unsigned pad = first_column_width - ss.str().size(); pad > 0; --pad)
+ for(unsigned pad = first_column_width - static_cast<unsigned>(ss.str().size()); pad > 0; --pad)
{
os.put(' ');
}
diff --git a/3rdParty/Boost/src/libs/program_options/src/parsers.cpp b/3rdParty/Boost/src/libs/program_options/src/parsers.cpp
index bc3b858..2361a48 100644
--- a/3rdParty/Boost/src/libs/program_options/src/parsers.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/parsers.cpp
@@ -45,7 +45,10 @@
// See: http://article.gmane.org/gmane.comp.lib.boost.devel/103843
// See: http://lists.gnu.org/archive/html/bug-guile/2004-01/msg00013.html
#if defined(__APPLE__) && defined(__DYNAMIC__)
-#include <crt_externs.h>
+// The proper include for this is crt_externs.h, however it's not
+// available on iOS. The right replacement is not known. See
+// https://svn.boost.org/trac/boost/ticket/5053
+extern "C" { extern char ***_NSGetEnviron(void); }
#define environ (*_NSGetEnviron())
#else
#if defined(__MWERKS__)
@@ -85,7 +88,8 @@ namespace boost { namespace program_options {
basic_parsed_options<wchar_t>
::basic_parsed_options(const parsed_options& po)
: description(po.description),
- utf8_encoded_options(po)
+ utf8_encoded_options(po),
+ m_options_prefix(po.m_options_prefix)
{
for (unsigned i = 0; i < po.options.size(); ++i)
options.push_back(woption_from_option(po.options[i]));
@@ -107,7 +111,7 @@ namespace boost { namespace program_options {
if (d.long_name().empty())
boost::throw_exception(
- error("long name required for config file"));
+ error("abbreviated option names are not permitted in options configuration files"));
allowed_options.insert(d.long_name());
}
diff --git a/3rdParty/Boost/src/libs/program_options/src/positional_options.cpp b/3rdParty/Boost/src/libs/program_options/src/positional_options.cpp
index 55995d7..72dc0d6 100644
--- a/3rdParty/Boost/src/libs/program_options/src/positional_options.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/positional_options.cpp
@@ -34,7 +34,7 @@ namespace boost { namespace program_options {
positional_options_description::max_total_count() const
{
return m_trailing.empty() ?
- m_names.size() : (std::numeric_limits<unsigned>::max)();
+ static_cast<unsigned>(m_names.size()) : (std::numeric_limits<unsigned>::max)();
}
const std::string&
diff --git a/3rdParty/Boost/src/libs/program_options/src/program_options_utf8_codecvt_facet.cpp b/3rdParty/Boost/src/libs/program_options/src/program_options_utf8_codecvt_facet.cpp
index c0fd7c0..2e4c532 100644
--- a/3rdParty/Boost/src/libs/program_options/src/program_options_utf8_codecvt_facet.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/program_options_utf8_codecvt_facet.cpp
@@ -12,7 +12,7 @@
#define BOOST_UTF8_END_NAMESPACE }}}
#define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL
-#include "../../detail/utf8_codecvt_facet.cpp"
+#include <boost/detail/utf8_codecvt_facet.ipp>
#undef BOOST_UTF8_BEGIN_NAMESPACE
diff --git a/3rdParty/Boost/src/libs/program_options/src/value_semantic.cpp b/3rdParty/Boost/src/libs/program_options/src/value_semantic.cpp
index f5770f1..5314029 100644
--- a/3rdParty/Boost/src/libs/program_options/src/value_semantic.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/value_semantic.cpp
@@ -7,6 +7,8 @@
#include <boost/program_options/config.hpp>
#include <boost/program_options/value_semantic.hpp>
#include <boost/program_options/detail/convert.hpp>
+#include <boost/program_options/detail/cmdline.hpp>
+#include <set>
#include <cctype>
@@ -14,6 +16,22 @@ namespace boost { namespace program_options {
using namespace std;
+
+#ifndef BOOST_NO_STD_WSTRING
+ namespace
+ {
+ std::string convert_value(const std::wstring& s)
+ {
+ try {
+ return to_local_8_bit(s);
+ }
+ catch(const std::exception&) {
+ return "<unrepresentable unicode string>";
+ }
+ }
+ }
+#endif
+
void
value_semantic_codecvt_helper<char>::
parse(boost::any& value_store,
@@ -139,7 +157,7 @@ namespace boost { namespace program_options {
else if (s == "off" || s == "no" || s == "0" || s == "false")
v = any(false);
else
- boost::throw_exception(validation_error(validation_error::invalid_bool_value, s));
+ boost::throw_exception(invalid_bool_value(s));
}
// This is blatant copy-paste. However, templating this will cause a problem,
@@ -161,7 +179,7 @@ namespace boost { namespace program_options {
else if (s == L"off" || s == L"no" || s == L"0" || s == L"false")
v = any(false);
else
- boost::throw_exception(validation_error(validation_error::invalid_bool_value));
+ boost::throw_exception(invalid_bool_value(convert_value(s)));
}
#endif
BOOST_PROGRAM_OPTIONS_DECL
@@ -194,120 +212,212 @@ namespace boost { namespace program_options {
invalid_option_value::
invalid_option_value(const std::string& bad_value)
- : validation_error(validation_error::invalid_option_value, bad_value)
- {}
-
-#ifndef BOOST_NO_STD_WSTRING
- namespace
+ : validation_error(validation_error::invalid_option_value)
{
- std::string convert_value(const std::wstring& s)
- {
- try {
- return to_local_8_bit(s);
- }
- catch(const std::exception&) {
- return "<unrepresentable unicode string>";
- }
- }
+ set_substitute("value", bad_value);
}
+#ifndef BOOST_NO_STD_WSTRING
invalid_option_value::
invalid_option_value(const std::wstring& bad_value)
- : validation_error(validation_error::invalid_option_value, convert_value(bad_value))
- {}
-#endif
- const std::string&
- unknown_option::get_option_name() const throw()
- {
- return m_option_name;
+ : validation_error(validation_error::invalid_option_value)
+ {
+ set_substitute("value", convert_value(bad_value));
}
+#endif
- const std::string&
- ambiguous_option::get_option_name() const throw()
- {
- return m_option_name;
- }
-
- const std::vector<std::string>&
- ambiguous_option::alternatives() const throw()
+
+
+ invalid_bool_value::
+ invalid_bool_value(const std::string& bad_value)
+ : validation_error(validation_error::invalid_bool_value)
{
- return m_alternatives;
+ set_substitute("value", bad_value);
}
- void
- multiple_values::set_option_name(const std::string& option_name)
+
+
+
+
+
+ error_with_option_name::error_with_option_name( const std::string& template_,
+ const std::string& option_name,
+ const std::string& original_token,
+ int option_style) :
+ error(template_),
+ m_option_style(option_style),
+ m_error_template(template_)
{
- m_option_name = option_name;
+ // parameter | placeholder | value
+ // --------- | ----------- | -----
+ set_substitute_default("canonical_option", "option '%canonical_option%'", "option");
+ set_substitute_default("value", "argument ('%value%')", "argument");
+ set_substitute_default("prefix", "%prefix%", "");
+ m_substitutions["option"] = option_name;
+ m_substitutions["original_token"] = original_token;
}
- const std::string&
- multiple_values::get_option_name() const throw()
+
+ const char* error_with_option_name::what() const throw()
{
- return m_option_name;
+ // will substitute tokens each time what is run()
+ substitute_placeholders(m_error_template);
+
+ return m_message.c_str();
}
-
- void
- multiple_occurrences::set_option_name(const std::string& option_name)
+
+ void error_with_option_name::replace_token(const string& from, const string& to) const
{
- m_option_name = option_name;
+ while (1)
+ {
+ std::size_t pos = m_message.find(from.c_str(), 0, from.length());
+ // not found: all replaced
+ if (pos == std::string::npos)
+ return;
+ m_message.replace(pos, from.length(), to);
+ }
}
- const std::string&
- multiple_occurrences::get_option_name() const throw()
+ string error_with_option_name::get_canonical_option_prefix() const
{
- return m_option_name;
+ switch (m_option_style)
+ {
+ case command_line_style::allow_dash_for_short:
+ return "-";
+ case command_line_style::allow_slash_for_short:
+ return "/";
+ case command_line_style::allow_long_disguise:
+ return "-";
+ case command_line_style::allow_long:
+ return "--";
+ case 0:
+ return "";
+ }
+ throw std::logic_error("error_with_option_name::m_option_style can only be "
+ "one of [0, allow_dash_for_short, allow_slash_for_short, "
+ "allow_long_disguise or allow_long]");
}
-
- validation_error::
- validation_error(kind_t kind,
- const std::string& option_value,
- const std::string& option_name)
- : error("")
- , m_kind(kind)
- , m_option_name(option_name)
- , m_option_value(option_value)
- , m_message(error_message(kind))
+
+
+ string error_with_option_name::get_canonical_option_name() const
{
- if (!option_value.empty())
- {
- m_message.append(std::string("'") + option_value + std::string("'"));
- }
+ if (!m_substitutions.find("option")->second.length())
+ return m_substitutions.find("original_token")->second;
+
+ string original_token = strip_prefixes(m_substitutions.find("original_token")->second);
+ string option_name = strip_prefixes(m_substitutions.find("option")->second);
+
+ // For long options, use option name
+ if (m_option_style == command_line_style::allow_long ||
+ m_option_style == command_line_style::allow_long_disguise)
+ return get_canonical_option_prefix() + option_name;
+
+ // For short options use first letter of original_token
+ if (m_option_style && original_token.length())
+ return get_canonical_option_prefix() + original_token[0];
+
+ // no prefix
+ return option_name;
}
- void
- validation_error::set_option_name(const std::string& option_name)
+
+ void error_with_option_name::substitute_placeholders(const string& error_template) const
{
- m_option_name = option_name;
+ m_message = error_template;
+ std::map<std::string, std::string> substitutions(m_substitutions);
+ substitutions["canonical_option"] = get_canonical_option_name();
+ substitutions["prefix"] = get_canonical_option_prefix();
+
+
+ //
+ // replace placeholder with defaults if values are missing
+ //
+ for (map<string, string_pair>::const_iterator iter = m_substitution_defaults.begin();
+ iter != m_substitution_defaults.end(); ++iter)
+ {
+ // missing parameter: use default
+ if (substitutions.count(iter->first) == 0 ||
+ substitutions[iter->first].length() == 0)
+ replace_token(iter->second.first, iter->second.second);
+ }
+
+
+ //
+ // replace placeholder with values
+ // placeholder are denoted by surrounding '%'
+ //
+ for (map<string, string>::iterator iter = substitutions.begin();
+ iter != substitutions.end(); ++iter)
+ replace_token('%' + iter->first + '%', iter->second);
}
- const std::string&
- validation_error::get_option_name() const throw()
+
+ void ambiguous_option::substitute_placeholders(const string& original_error_template) const
{
- return m_option_name;
+ // For short forms, all alternatives must be identical, by
+ // definition, to the specified option, so we don't need to
+ // display alternatives
+ if (m_option_style == command_line_style::allow_dash_for_short ||
+ m_option_style == command_line_style::allow_slash_for_short)
+ {
+ error_with_option_name::substitute_placeholders(original_error_template);
+ return;
+ }
+
+
+ string error_template = original_error_template;
+ // remove duplicates using std::set
+ std::set<std::string> alternatives_set (m_alternatives.begin(), m_alternatives.end());
+ std::vector<std::string> alternatives_vec (alternatives_set.begin(), alternatives_set.end());
+
+ error_template += " and matches ";
+ // Being very cautious: should be > 1 alternative!
+ if (alternatives_vec.size() > 1)
+ {
+ for (unsigned i = 0; i < alternatives_vec.size() - 1; ++i)
+ error_template += "'%prefix%" + alternatives_vec[i] + "', ";
+ error_template += "and ";
+ }
+
+ // there is a programming error if multiple options have the same name...
+ if (m_alternatives.size() > 1 && alternatives_vec.size() == 1)
+ error_template += "different versions of ";
+
+ error_template += "'%prefix%" + alternatives_vec.back() + "'";
+
+
+ // use inherited logic
+ error_with_option_name::substitute_placeholders(error_template);
}
- std::string
- validation_error::error_message(kind_t kind)
+
+
+
+
+
+ string
+ validation_error::get_template(kind_t kind)
{
// Initially, store the message in 'const char*' variable,
// to avoid conversion to std::string in all cases.
const char* msg;
switch(kind)
{
- case multiple_values_not_allowed:
- msg = "multiple values not allowed";
- break;
- case at_least_one_value_required:
- msg = "at least one value required";
- break;
case invalid_bool_value:
- msg = "invalid bool value";
+ msg = "the argument ('%value%') for option '%canonical_option%' is invalid. Valid choices are 'on|off', 'yes|no', '1|0' and 'true|false'";
break;
case invalid_option_value:
- msg = "invalid option value";
+ msg = "the argument ('%value%') for option '%canonical_option%' is invalid";
+ break;
+ case multiple_values_not_allowed:
+ msg = "option '%canonical_option%' only takes a single argument";
+ break;
+ case at_least_one_value_required:
+ msg = "option '%canonical_option%' requires at least one argument";
break;
+ // currently unused
case invalid_option:
- msg = "invalid option";
+ msg = "option '%canonical_option%' is not valid";
break;
default:
msg = "unknown error";
@@ -315,21 +425,4 @@ namespace boost { namespace program_options {
return msg;
}
- const char*
- validation_error::what() const throw()
- {
- if (!m_option_name.empty())
- {
- m_message = "in option '" + m_option_name + "': "
- + error_message(m_kind);
- }
- return m_message.c_str();
- }
-
- const std::string&
- required_option::get_option_name() const throw()
- {
- return m_option_name;
- }
-
}}
diff --git a/3rdParty/Boost/src/libs/program_options/src/variables_map.cpp b/3rdParty/Boost/src/libs/program_options/src/variables_map.cpp
index 29b1de9..caf354e 100644
--- a/3rdParty/Boost/src/libs/program_options/src/variables_map.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/variables_map.cpp
@@ -38,65 +38,68 @@ namespace boost { namespace program_options {
// Declared once, to please Intel in VC++ mode;
unsigned i;
- // First, convert/store all given options
- for (i = 0; i < options.options.size(); ++i) {
+ // Declared here so can be used to provide context for exceptions
+ string option_name;
+ string original_token;
- const string& name = options.options[i].string_key;
- // Skip positional options without name
- if (name.empty())
- continue;
-
- // Ignore unregistered option. The 'unregistered'
- // field can be true only if user has explicitly asked
- // to allow unregistered options. We can't store them
- // to variables map (lacking any information about paring),
- // so just ignore them.
- if (options.options[i].unregistered)
- continue;
-
- // If option has final value, skip this assignment
- if (xm.m_final.count(name))
- continue;
-
- const option_description& d = desc.find(name, false,
- false, false);
+ try
+ {
- variable_value& v = m[name];
- if (v.defaulted()) {
- // Explicit assignment here erases defaulted value
- v = variable_value();
- }
-
- try {
+ // First, convert/store all given options
+ for (i = 0; i < options.options.size(); ++i) {
+
+ option_name = options.options[i].string_key;
+ original_token = options.options[i].original_tokens.size() ?
+ options.options[i].original_tokens[0] :
+ option_name;
+ // Skip positional options without name
+ if (option_name.empty())
+ continue;
+
+ // Ignore unregistered option. The 'unregistered'
+ // field can be true only if user has explicitly asked
+ // to allow unregistered options. We can't store them
+ // to variables map (lacking any information about paring),
+ // so just ignore them.
+ if (options.options[i].unregistered)
+ continue;
+
+ // If option has final value, skip this assignment
+ if (xm.m_final.count(option_name))
+ continue;
+
+ string original_token = options.options[i].original_tokens.size() ?
+ options.options[i].original_tokens[0] : "";
+ const option_description& d = desc.find(option_name, false,
+ false, false);
+
+ variable_value& v = m[option_name];
+ if (v.defaulted()) {
+ // Explicit assignment here erases defaulted value
+ v = variable_value();
+ }
+
d.semantic()->parse(v.value(), options.options[i].value, utf8);
+
+ v.m_value_semantic = d.semantic();
+
+ // The option is not composing, and the value is explicitly
+ // provided. Ignore values of this option for subsequent
+ // calls to 'store'. We store this to a temporary set,
+ // so that several assignment inside *this* 'store' call
+ // are allowed.
+ if (!d.semantic()->is_composing())
+ new_final.insert(option_name);
}
+ }
#ifndef BOOST_NO_EXCEPTIONS
- catch(validation_error& e)
- {
- e.set_option_name(name);
- throw;
- }
- catch(multiple_occurrences& e)
- {
- e.set_option_name(name);
- throw;
- }
- catch(multiple_values& e)
- {
- e.set_option_name(name);
- throw;
- }
-#endif
- v.m_value_semantic = d.semantic();
-
- // The option is not composing, and the value is explicitly
- // provided. Ignore values of this option for subsequent
- // calls to 'store'. We store this to a temporary set,
- // so that several assignment inside *this* 'store' call
- // are allowed.
- if (!d.semantic()->is_composing())
- new_final.insert(name);
+ catch(error_with_option_name& e)
+ {
+ // add context and rethrow
+ e.add_context(option_name, original_token, options.m_options_prefix);
+ throw;
}
+#endif
xm.m_final.insert(new_final.begin(), new_final.end());
@@ -127,7 +130,14 @@ namespace boost { namespace program_options {
// add empty value if this is an required option
if (d.semantic()->is_required()) {
- xm.m_required.insert(key);
+
+ // For option names specified in multiple ways, e.g. on the command line,
+ // config file etc, the following precedence rules apply:
+ // "--" > ("-" or "/") > ""
+ // Precedence is set conveniently by a single call to length()
+ string canonical_name = d.canonical_display_name(options.m_options_prefix);
+ if (canonical_name.length() > xm.m_required[key].length())
+ xm.m_required[key] = canonical_name;
}
}
}
@@ -182,6 +192,13 @@ namespace boost { namespace program_options {
: abstract_variables_map(next)
{}
+ void variables_map::clear()
+ {
+ std::map<std::string, variable_value>::clear();
+ m_final.clear();
+ m_required.clear();
+ }
+
const variable_value&
variables_map::get(const std::string& name) const
{
@@ -197,15 +214,16 @@ namespace boost { namespace program_options {
variables_map::notify()
{
// This checks if all required options occur
- for (set<string>::const_iterator r = m_required.begin();
+ for (map<string, string>::const_iterator r = m_required.begin();
r != m_required.end();
++r)
{
- const string& opt = *r;
+ const string& opt = r->first;
+ const string& display_opt = r->second;
map<string, variable_value>::const_iterator iter = find(opt);
if (iter == end() || iter->second.empty())
{
- boost::throw_exception(required_option(opt));
+ boost::throw_exception(required_option(display_opt));
}
}
diff --git a/3rdParty/Boost/src/libs/program_options/src/winmain.cpp b/3rdParty/Boost/src/libs/program_options/src/winmain.cpp
index 8a7c43f..6220043 100644
--- a/3rdParty/Boost/src/libs/program_options/src/winmain.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/winmain.cpp
@@ -7,6 +7,8 @@
#include <boost/program_options/parsers.hpp>
#include <cctype>
+using std::size_t;
+
#ifdef _WIN32
namespace boost { namespace program_options {
@@ -89,7 +91,7 @@ namespace boost { namespace program_options {
{
std::vector<std::wstring> result;
std::vector<std::string> aux = split_winmain(to_internal(cmdline));
- for (unsigned i = 0, e = aux.size(); i < e; ++i)
+ for (size_t i = 0, e = aux.size(); i < e; ++i)
result.push_back(from_utf8(aux[i]));
return result;
}
diff --git a/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp b/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp
index a99de14..6701020 100644
--- a/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp
@@ -21,6 +21,7 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
+#include "internals.hpp"
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
@@ -107,26 +108,6 @@ c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transfo
return result;
}
-enum
-{
- char_class_space=1<<0,
- char_class_print=1<<1,
- char_class_cntrl=1<<2,
- char_class_upper=1<<3,
- char_class_lower=1<<4,
- char_class_alpha=1<<5,
- char_class_digit=1<<6,
- char_class_punct=1<<7,
- char_class_xdigit=1<<8,
- char_class_alnum=char_class_alpha|char_class_digit,
- char_class_graph=char_class_alnum|char_class_punct,
- char_class_blank=1<<9,
- char_class_word=1<<10,
- char_class_unicode=1<<11,
- char_class_horizontal=1<<12,
- char_class_vertical=1<<13
-};
-
c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2)
{
static const char_class_type masks[] =
diff --git a/3rdParty/Boost/src/libs/regex/src/cregex.cpp b/3rdParty/Boost/src/libs/regex/src/cregex.cpp
index 5c27330..8d69139 100644
--- a/3rdParty/Boost/src/libs/regex/src/cregex.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/cregex.cpp
@@ -361,11 +361,24 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
while(dstart != dend)
{
+ // Verify that sprintf will not overflow:
+ if(std::strlen(dstart.path()) + std::strlen(directory_iterator::separator()) + std::strlen(ptr) >= MAX_PATH)
+ {
+ // Oops overflow, skip this item:
+ ++dstart;
+ continue;
+ }
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
- (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
+ int r = (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
#else
- (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
+ int r = (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
#endif
+ if(r < 0)
+ {
+ // sprintf failed, skip this item:
+ ++dstart;
+ continue;
+ }
BuildFileList(pl, buf, recurse);
++dstart;
}
diff --git a/3rdParty/Boost/src/libs/regex/src/fileiter.cpp b/3rdParty/Boost/src/libs/regex/src/fileiter.cpp
index ff1d111..780a12f 100644
--- a/3rdParty/Boost/src/libs/regex/src/fileiter.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/fileiter.cpp
@@ -19,6 +19,7 @@
#define BOOST_REGEX_SOURCE
+#include <boost/config.hpp>
#include <climits>
#include <stdexcept>
#include <string>
@@ -847,10 +848,16 @@ bool iswild(const char* mask, const char* name)
unsigned _fi_attributes(const char* root, const char* name)
{
char buf[MAX_PATH];
+ // verify that we can not overflow:
+ if(std::strlen(root) + std::strlen(_fi_sep) + std::strlen(name) >= MAX_PATH)
+ return 0;
+ int r;
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
- (std::sprintf)(buf, "%s%s", root, name);
+ r = (std::sprintf)(buf, "%s%s", root, name);
else
- (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
+ r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
+ if(r < 0)
+ return 0; // sprintf failed
DIR* d = opendir(buf);
if(d)
{
@@ -870,6 +877,7 @@ _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindF
{
if(_fi_FindNextFile(dat, lpFindFileData))
return dat;
+ closedir(h);
}
delete dat;
return 0;
diff --git a/3rdParty/Boost/src/libs/regex/src/internals.hpp b/3rdParty/Boost/src/libs/regex/src/internals.hpp
new file mode 100644
index 0000000..3a15cc6
--- /dev/null
+++ b/3rdParty/Boost/src/libs/regex/src/internals.hpp
@@ -0,0 +1,35 @@
+/*
+ *
+ * Copyright (c) 2011
+ * John Maddock
+ *
+ * Use, modification and distribution are subject to the
+ * Boost Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ *
+ */
+
+#ifndef BOOST_REGEX_SRC_INTERNALS_HPP
+#define BOOST_REGEX_SRC_INTERNALS_HPP
+
+enum
+{
+ char_class_space=1<<0,
+ char_class_print=1<<1,
+ char_class_cntrl=1<<2,
+ char_class_upper=1<<3,
+ char_class_lower=1<<4,
+ char_class_alpha=1<<5,
+ char_class_digit=1<<6,
+ char_class_punct=1<<7,
+ char_class_xdigit=1<<8,
+ char_class_alnum=char_class_alpha|char_class_digit,
+ char_class_graph=char_class_alnum|char_class_punct,
+ char_class_blank=1<<9,
+ char_class_word=1<<10,
+ char_class_unicode=1<<11,
+ char_class_horizontal=1<<12,
+ char_class_vertical=1<<13
+};
+
+#endif // BOOST_REGEX_SRC_INTERNALS_HPP
diff --git a/3rdParty/Boost/src/libs/regex/src/posix_api.cpp b/3rdParty/Boost/src/libs/regex/src/posix_api.cpp
index 37ed422..e59c19e 100644
--- a/3rdParty/Boost/src/libs/regex/src/posix_api.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/posix_api.cpp
@@ -18,6 +18,7 @@
#define BOOST_REGEX_SOURCE
+#include <boost/config.hpp>
#include <cstdio>
#include <boost/regex.hpp>
#include <boost/cregex.hpp>
@@ -167,11 +168,17 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
{
if(std::strcmp(e->re_endp, names[i]) == 0)
{
+ //
+ // We're converting an integer i to a string, and since i <= REG_E_UNKNOWN
+ // a five character string is *always* large enough:
+ //
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
- (::sprintf_s)(localbuf, 5, "%d", i);
+ int r = (::sprintf_s)(localbuf, 5, "%d", i);
#else
- (std::sprintf)(localbuf, "%d", i);
+ int r = (std::sprintf)(localbuf, "%d", i);
#endif
+ if(r < 0)
+ return 0; // sprintf failed
if(std::strlen(localbuf) < buf_size)
re_detail::strcpy_s(buf, buf_size, localbuf);
return std::strlen(localbuf) + 1;
diff --git a/3rdParty/Boost/src/libs/regex/src/regex.cpp b/3rdParty/Boost/src/libs/regex/src/regex.cpp
index 27ac43c..ea20a06 100644
--- a/3rdParty/Boost/src/libs/regex/src/regex.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/regex.cpp
@@ -19,6 +19,7 @@
#define BOOST_REGEX_SOURCE
+#include <boost/config.hpp>
#include <new>
#include <boost/regex.hpp>
#include <boost/throw_exception.hpp>
diff --git a/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp b/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp
index 7a8de80..f75f0a5 100644
--- a/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp
@@ -18,6 +18,7 @@
#define BOOST_REGEX_SOURCE
+#include <boost/config.hpp>
#include <memory>
#include <cstring>
#include <boost/assert.hpp>
@@ -45,7 +46,8 @@ void BOOST_REGEX_CALL raw_storage::resize(size_type n)
// allocate and copy data:
register pointer ptr = static_cast<pointer>(::operator new(newsize));
BOOST_REGEX_NOEH_ASSERT(ptr)
- std::memcpy(ptr, start, datasize);
+ if(start)
+ std::memcpy(ptr, start, datasize);
// get rid of old buffer:
::operator delete(start);
diff --git a/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp b/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp
index a9e96d9..b3d2c5a 100644
--- a/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp
@@ -22,6 +22,7 @@
#include <boost/detail/workaround.hpp>
#include <memory>
#include <string>
+#include "internals.hpp"
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \
&& !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))\
@@ -147,26 +148,6 @@ c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::t
return result;
}
-enum
-{
- char_class_space=1<<0,
- char_class_print=1<<1,
- char_class_cntrl=1<<2,
- char_class_upper=1<<3,
- char_class_lower=1<<4,
- char_class_alpha=1<<5,
- char_class_digit=1<<6,
- char_class_punct=1<<7,
- char_class_xdigit=1<<8,
- char_class_alnum=char_class_alpha|char_class_digit,
- char_class_graph=char_class_alnum|char_class_punct,
- char_class_blank=1<<9,
- char_class_word=1<<10,
- char_class_unicode=1<<11,
- char_class_horizontal=1<<12,
- char_class_vertical=1<<13
-};
-
c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2)
{
static const char_class_type masks[] =
diff --git a/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp b/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp
index 3c693c6..ff5c90d 100644
--- a/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp
+++ b/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp
@@ -74,7 +74,7 @@ const wchar_t* wnames[] = {
};
}
-typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > c_regex_type;
+typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > wc_regex_type;
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
{
@@ -84,7 +84,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
- expression->guts = new c_regex_type();
+ expression->guts = new wc_regex_type();
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
@@ -134,9 +134,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
try{
#endif
expression->re_magic = wmagic_value;
- static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
- expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
- result = static_cast<c_regex_type*>(expression->guts)->error_code();
+ static_cast<wc_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
+ expression->re_nsub = static_cast<wc_regex_type*>(expression->guts)->mark_count() - 1;
+ result = static_cast<wc_regex_type*>(expression->guts)->error_code();
#ifndef BOOST_NO_EXCEPTIONS
}
catch(const boost::regex_error& be)
@@ -215,7 +215,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
{
std::string p;
if((e) && (e->re_magic == wmagic_value))
- p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
+ p = static_cast<wc_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
else
{
p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
@@ -264,7 +264,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
#endif
if(expression->re_magic == wmagic_value)
{
- result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags);
+ result = regex_search(start, end, m, *static_cast<wc_regex_type*>(expression->guts), flags);
}
else
return result;
@@ -301,7 +301,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression)
{
if(expression->re_magic == wmagic_value)
{
- delete static_cast<c_regex_type*>(expression->guts);
+ delete static_cast<wc_regex_type*>(expression->guts);
}
expression->re_magic = 0;
}
diff --git a/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp b/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp
index 1ddde63..ac9a292 100644
--- a/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp
+++ b/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp
@@ -24,7 +24,7 @@ typedef slot_container_type::iterator group_iterator;
typedef slot_container_type::const_iterator const_group_iterator;
-#if BOOST_WORKAROUND(_MSC_VER, <= 1600)
+#if BOOST_WORKAROUND(_MSC_VER, <= 1700)
void named_slot_map_iterator::decrement() { assert(false); }
void named_slot_map_iterator::advance(difference_type) { assert(false); }
#endif
@@ -102,7 +102,7 @@ void named_slot_map::disconnect(const stored_group& name)
i->first.disconnect();
i = next;
}
- groups.erase(group);
+ groups.erase((const_group_iterator) group);
}
}
@@ -125,7 +125,7 @@ void named_slot_map::remove_disconnected_slots()
}
// Clear out empty groups
- if (empty(g)) groups.erase(g++);
+ if (empty(g)) groups.erase((const_group_iterator) g++);
else ++g;
}
}
diff --git a/3rdParty/Boost/src/libs/system/src/error_code.cpp b/3rdParty/Boost/src/libs/system/src/error_code.cpp
index bcdbea9..6772d15 100644
--- a/3rdParty/Boost/src/libs/system/src/error_code.cpp
+++ b/3rdParty/Boost/src/libs/system/src/error_code.cpp
@@ -74,7 +74,7 @@ namespace
// strerror_r is preferred because it is always thread safe,
// however, we fallback to strerror in certain cases because:
// -- Windows doesn't provide strerror_r.
- // -- HP and Sundo provide strerror_r on newer systems, but there is
+ // -- HP and Sun do provide strerror_r on newer systems, but there is
// no way to tell if is available at runtime and in any case their
// versions of strerror are thread safe anyhow.
// -- Linux only sometimes provides strerror_r.
@@ -84,6 +84,7 @@ namespace
# if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\
|| (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\
|| (defined(__osf__) && !defined(_REENTRANT))\
+ || (defined(__INTEGRITY))\
|| (defined(__vms))\
|| (defined(__QNXNTO__))
const char * c_str = std::strerror( ev );
diff --git a/3rdParty/Boost/src/libs/thread/src/future.cpp b/3rdParty/Boost/src/libs/thread/src/future.cpp
new file mode 100755
index 0000000..33980f5
--- /dev/null
+++ b/3rdParty/Boost/src/libs/thread/src/future.cpp
@@ -0,0 +1,61 @@
+// (C) Copyright 2012 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/thread/detail/config.hpp>
+#ifndef BOOST_NO_EXCEPTIONS
+
+
+#include <boost/thread/future.hpp>
+
+namespace boost
+{
+
+ namespace thread_detail
+ {
+
+ class future_error_category :
+ public boost::system::error_category
+ {
+ public:
+ virtual const char* name() const; //BOOST_NOEXCEPT;
+ virtual std::string message(int ev) const;
+ };
+
+ const char*
+ future_error_category::name() const //BOOST_NOEXCEPT
+ {
+ return "future";
+ }
+
+ std::string
+ future_error_category::message(int ev) const
+ {
+ switch (BOOST_SCOPED_ENUM_NATIVE(future_errc)(ev))
+ {
+ case future_errc::broken_promise:
+ return std::string("The associated promise has been destructed prior "
+ "to the associated state becoming ready.");
+ case future_errc::future_already_retrieved:
+ return std::string("The future has already been retrieved from "
+ "the promise or packaged_task.");
+ case future_errc::promise_already_satisfied:
+ return std::string("The state of the promise has already been set.");
+ case future_errc::no_state:
+ return std::string("Operation not permitted on an object without "
+ "an associated state.");
+ }
+ return std::string("unspecified future_errc value\n");
+ }
+ }
+
+ const system::error_category&
+ future_category() BOOST_NOEXCEPT
+ {
+ static thread_detail::future_error_category f;
+ return f;
+ }
+
+}
+#endif
diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp b/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp
index 6e3722a..d5fd656 100644
--- a/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp
+++ b/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2007 Anthony Williams
//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define __STDC_CONSTANT_MACROS
@@ -8,12 +8,13 @@
#include <boost/assert.hpp>
#include <pthread.h>
#include <stdlib.h>
+#include <memory>
namespace boost
{
namespace detail
{
- BOOST_THREAD_DECL boost::uintmax_t once_global_epoch=UINTMAX_C(~0);
+ BOOST_THREAD_DECL thread_detail::uintmax_atomic_t once_global_epoch=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C;
BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER;
BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER;
@@ -21,31 +22,51 @@ namespace boost
{
pthread_key_t epoch_tss_key;
pthread_once_t epoch_tss_key_flag=PTHREAD_ONCE_INIT;
-
- extern "C" void delete_epoch_tss_data(void* data)
+
+ extern "C"
{
- free(data);
+ static void delete_epoch_tss_data(void* data)
+ {
+ free(data);
+ }
+
+ static void create_epoch_tss_key()
+ {
+ BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data));
+ }
}
- extern "C" void create_epoch_tss_key()
+#if defined BOOST_THREAD_PATCH
+ const pthread_once_t pthread_once_init_value=PTHREAD_ONCE_INIT;
+ struct BOOST_THREAD_DECL delete_epoch_tss_key_on_dlclose_t
{
- BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data));
- }
-
+ delete_epoch_tss_key_on_dlclose_t()
+ {
+ }
+ ~delete_epoch_tss_key_on_dlclose_t()
+ {
+ if(memcmp(&epoch_tss_key_flag, &pthread_once_init_value, sizeof(pthread_once_t)))
+ {
+ pthread_key_delete(epoch_tss_key);
+ }
+ }
+ };
+ delete_epoch_tss_key_on_dlclose_t delete_epoch_tss_key_on_dlclose;
+#endif
}
-
- boost::uintmax_t& get_once_per_thread_epoch()
+
+ thread_detail::uintmax_atomic_t& get_once_per_thread_epoch()
{
BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key));
void* data=pthread_getspecific(epoch_tss_key);
if(!data)
{
- data=malloc(sizeof(boost::uintmax_t));
+ data=malloc(sizeof(thread_detail::uintmax_atomic_t));
BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data));
- *static_cast<boost::uintmax_t*>(data)=UINTMAX_C(~0);
+ *static_cast<thread_detail::uintmax_atomic_t*>(data)=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C;
}
- return *static_cast<boost::uintmax_t*>(data);
+ return *static_cast<thread_detail::uintmax_atomic_t*>(data);
}
}
-
+
}
diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp b/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp
index 187c024..c83eac1 100644
--- a/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp
+++ b/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp
@@ -1,20 +1,22 @@
// Copyright (C) 2001-2003
// William E. Kempf
// Copyright (C) 2007-8 Anthony Williams
+// (C) Copyright 2011 Vicente J. Botet Escriba
//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/thread/detail/config.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
-#include <boost/thread/condition.hpp>
+#include <boost/thread/condition_variable.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/once.hpp>
#include <boost/thread/tss.hpp>
#include <boost/throw_exception.hpp>
-#ifdef __linux__
+
+#ifdef __GLIBC__
#include <sys/sysinfo.h>
#elif defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/types.h>
@@ -23,14 +25,25 @@
#include <unistd.h>
#endif
-#include "timeconv.inl"
+#include "./timeconv.inl"
+
+#pragma GCC diagnostic ignored "-Wreturn-type"
namespace boost
{
namespace detail
{
thread_data_base::~thread_data_base()
- {}
+ {
+ {
+ for (notify_list_t::iterator i = notify.begin(), e = notify.end();
+ i != e; ++i)
+ {
+ i->second->unlock();
+ i->first->notify_all();
+ }
+ }
+ }
struct thread_exit_callback_node
{
@@ -45,12 +58,16 @@ namespace boost
namespace
{
+#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
+ boost::once_flag current_thread_tls_init_flag;
+#else
boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
+#endif
pthread_key_t current_thread_tls_key;
extern "C"
{
- void tls_destructor(void* data)
+ static void tls_destructor(void* data)
{
boost::detail::thread_data_base* thread_info=static_cast<boost::detail::thread_data_base*>(data);
if(thread_info)
@@ -86,14 +103,31 @@ namespace boost
}
}
}
-
+
+#if defined BOOST_THREAD_PATCH
+
+ struct delete_current_thread_tls_key_on_dlclose_t
+ {
+ delete_current_thread_tls_key_on_dlclose_t()
+ {
+ }
+ ~delete_current_thread_tls_key_on_dlclose_t()
+ {
+ if (current_thread_tls_init_flag.epoch!=BOOST_ONCE_INITIAL_FLAG_VALUE)
+ {
+ pthread_key_delete(current_thread_tls_key);
+ }
+ }
+ };
+ delete_current_thread_tls_key_on_dlclose_t delete_current_thread_tls_key_on_dlclose;
+#endif
void create_current_thread_tls_key()
{
BOOST_VERIFY(!pthread_key_create(&current_thread_tls_key,&tls_destructor));
}
}
-
+
boost::detail::thread_data_base* get_current_thread_data()
{
boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
@@ -106,26 +140,27 @@ namespace boost
BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data));
}
}
-
+
namespace
{
extern "C"
{
- void* thread_proxy(void* param)
+ static void* thread_proxy(void* param)
{
boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self;
thread_info->self.reset();
detail::set_current_thread_data(thread_info.get());
- try
+ BOOST_TRY
{
thread_info->run();
}
- catch(thread_interrupted const&)
+ BOOST_CATCH (thread_interrupted const&)
{
}
+ BOOST_CATCH_END
// Removed as it stops the debugger identifying the cause of the exception
// Unhandled exceptions still cause the application to terminate
-// catch(...)
+// BOOST_CATCH(...)
// {
// std::terminate();
// }
@@ -146,9 +181,11 @@ namespace boost
{
interrupt_enabled=false;
}
-
+
void run()
{}
+ void notify_all_at_thread_exit(condition_variable*, mutex*)
+ {}
private:
externally_launched_thread(externally_launched_thread&);
@@ -177,7 +214,7 @@ namespace boost
}
- thread::thread()
+ thread::thread() BOOST_NOEXCEPT
{}
void thread::start_thread()
@@ -187,15 +224,47 @@ namespace boost
if (res != 0)
{
thread_info->self.reset();
- boost::throw_exception(thread_resource_error());
+ boost::throw_exception(thread_resource_error(res, "boost thread: failed in pthread_create"));
}
}
- thread::~thread()
+ void thread::start_thread(const attributes& attr)
{
- detach();
+ thread_info->self=thread_info;
+ const attributes::native_handle_type* h = attr.native_handle();
+ int res = pthread_create(&thread_info->thread_handle, h, &thread_proxy, thread_info.get());
+ if (res != 0)
+ {
+ thread_info->self.reset();
+ boost::throw_exception(thread_resource_error());
+ }
+ int detached_state;
+ res = pthread_attr_getdetachstate(h, &detached_state);
+ if (res != 0)
+ {
+ thread_info->self.reset();
+ boost::throw_exception(thread_resource_error());
+ }
+ if (PTHREAD_CREATE_DETACHED==detached_state)
+ {
+ detail::thread_data_ptr local_thread_info;
+ thread_info.swap(local_thread_info);
+
+ if(local_thread_info)
+ {
+ //lock_guard<mutex> lock(local_thread_info->data_mutex);
+ if(!local_thread_info->join_started)
+ {
+ //BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle));
+ local_thread_info->join_started=true;
+ local_thread_info->joined=true;
+ }
+ }
+ }
}
+
+
detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return thread_info;
@@ -203,11 +272,15 @@ namespace boost
void thread::join()
{
+ if (this_thread::get_id() == get_id())
+ {
+ boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
+ }
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
if(local_thread_info)
{
bool do_join=false;
-
+
{
unique_lock<mutex> lock(local_thread_info->data_mutex);
while(!local_thread_info->done)
@@ -215,7 +288,7 @@ namespace boost
local_thread_info->done_condition.wait(lock);
}
do_join=!local_thread_info->join_started;
-
+
if(do_join)
{
local_thread_info->join_started=true;
@@ -236,32 +309,42 @@ namespace boost
local_thread_info->joined=true;
local_thread_info->done_condition.notify_all();
}
-
+
if(thread_info==local_thread_info)
{
thread_info.reset();
}
}
+ else
+ {
+#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
+ boost::throw_exception(thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable"));
+#endif
+ }
}
- bool thread::timed_join(system_time const& wait_until)
+ bool thread::do_try_join_until(struct timespec const &timeout)
{
+ if (this_thread::get_id() == get_id())
+ {
+ boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
+ }
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
if(local_thread_info)
{
bool do_join=false;
-
+
{
unique_lock<mutex> lock(local_thread_info->data_mutex);
while(!local_thread_info->done)
{
- if(!local_thread_info->done_condition.timed_wait(lock,wait_until))
+ if(!local_thread_info->done_condition.do_timed_wait(lock,timeout))
{
return false;
}
}
do_join=!local_thread_info->join_started;
-
+
if(do_join)
{
local_thread_info->join_started=true;
@@ -282,16 +365,22 @@ namespace boost
local_thread_info->joined=true;
local_thread_info->done_condition.notify_all();
}
-
+
if(thread_info==local_thread_info)
{
thread_info.reset();
}
+ return true;
+ }
+ else
+ {
+#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
+ boost::throw_exception(thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable"));
+#endif
}
- return true;
}
- bool thread::joinable() const
+ bool thread::joinable() const BOOST_NOEXCEPT
{
return (get_thread_info)();
}
@@ -301,7 +390,7 @@ namespace boost
{
detail::thread_data_ptr local_thread_info;
thread_info.swap(local_thread_info);
-
+
if(local_thread_info)
{
lock_guard<mutex> lock(local_thread_info->data_mutex);
@@ -316,20 +405,24 @@ namespace boost
namespace this_thread
{
-
+
+#ifdef __DECXXX
+ /// Workaround of DECCXX issue of incorrect template substitution
+ template<>
+#endif
void sleep(const system_time& st)
{
detail::thread_data_base* const thread_info=detail::get_current_thread_data();
-
+
if(thread_info)
{
unique_lock<mutex> lk(thread_info->sleep_mutex);
- while(thread_info->sleep_condition.timed_wait(lk,st));
+ while(thread_info->sleep_condition.timed_wait(lk,st)) {}
}
else
{
xtime const xt=get_xtime(st);
-
+
for (int foo=0; foo < 5; ++foo)
{
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
@@ -339,7 +432,7 @@ namespace boost
# elif defined(BOOST_HAS_NANOSLEEP)
timespec ts;
to_timespec_duration(xt, ts);
-
+
// nanosleep takes a timespec that is an offset, not
// an absolute time.
nanosleep(&ts, 0);
@@ -350,14 +443,14 @@ namespace boost
cond.timed_wait(lock, xt);
# endif
xtime cur;
- xtime_get(&cur, TIME_UTC);
+ xtime_get(&cur, TIME_UTC_);
if (xtime_cmp(xt, cur) <= 0)
return;
}
}
}
- void yield()
+ void yield() BOOST_NOEXCEPT
{
# if defined(BOOST_HAS_SCHED_YIELD)
BOOST_VERIFY(!sched_yield());
@@ -365,13 +458,12 @@ namespace boost
BOOST_VERIFY(!pthread_yield());
# else
xtime xt;
- xtime_get(&xt, TIME_UTC);
+ xtime_get(&xt, TIME_UTC_);
sleep(xt);
# endif
}
}
-
- unsigned thread::hardware_concurrency()
+ unsigned thread::hardware_concurrency() BOOST_NOEXCEPT
{
#if defined(PTW32_VERSION) || defined(__hpux)
return pthread_num_processors_np();
@@ -382,15 +474,19 @@ namespace boost
#elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
int const count=sysconf(_SC_NPROCESSORS_ONLN);
return (count>0)?count:0;
-#elif defined(_GNU_SOURCE)
+#elif defined(__GLIBC__)
return get_nprocs();
#else
return 0;
#endif
}
- thread::id thread::get_id() const
+ thread::id thread::get_id() const BOOST_NOEXCEPT
{
+ #if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
+ //return local_thread_info->thread_handle;
+ return const_cast<thread*>(this)->native_handle();
+ #else
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
if(local_thread_info)
{
@@ -398,8 +494,9 @@ namespace boost
}
else
{
- return id();
+ return id();
}
+ #endif
}
void thread::interrupt()
@@ -417,7 +514,7 @@ namespace boost
}
}
- bool thread::interruption_requested() const
+ bool thread::interruption_requested() const BOOST_NOEXCEPT
{
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
if(local_thread_info)
@@ -444,19 +541,24 @@ namespace boost
return pthread_t();
}
}
-
-
+
+
namespace this_thread
{
- thread::id get_id()
+ thread::id get_id() BOOST_NOEXCEPT
{
+ #if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
+ return pthread_self();
+ #else
boost::detail::thread_data_base* const thread_info=get_or_make_current_thread_data();
return thread::id(thread_info?thread_info->shared_from_this():detail::thread_data_ptr());
+ #endif
}
void interruption_point()
{
+#ifndef BOOST_NO_EXCEPTIONS
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
if(thread_info && thread_info->interrupt_enabled)
{
@@ -467,15 +569,16 @@ namespace boost
throw thread_interrupted();
}
}
+#endif
}
-
- bool interruption_enabled()
+
+ bool interruption_enabled() BOOST_NOEXCEPT
{
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
return thread_info && thread_info->interrupt_enabled;
}
-
- bool interruption_requested()
+
+ bool interruption_requested() BOOST_NOEXCEPT
{
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
if(!thread_info)
@@ -489,7 +592,7 @@ namespace boost
}
}
- disable_interruption::disable_interruption():
+ disable_interruption::disable_interruption() BOOST_NOEXCEPT:
interruption_was_enabled(interruption_enabled())
{
if(interruption_was_enabled)
@@ -497,8 +600,8 @@ namespace boost
detail::get_current_thread_data()->interrupt_enabled=false;
}
}
-
- disable_interruption::~disable_interruption()
+
+ disable_interruption::~disable_interruption() BOOST_NOEXCEPT
{
if(detail::get_current_thread_data())
{
@@ -506,15 +609,15 @@ namespace boost
}
}
- restore_interruption::restore_interruption(disable_interruption& d)
+ restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT
{
if(d.interruption_was_enabled)
{
detail::get_current_thread_data()->interrupt_enabled=true;
}
}
-
- restore_interruption::~restore_interruption()
+
+ restore_interruption::~restore_interruption() BOOST_NOEXCEPT
{
if(detail::get_current_thread_data())
{
@@ -545,7 +648,7 @@ namespace boost
return &current_node->second;
}
}
- return NULL;
+ return 0;
}
void* get_tss_data(void const* key)
@@ -554,7 +657,7 @@ namespace boost
{
return current_node->value;
}
- return NULL;
+ return 0;
}
void add_new_tss_node(void const* key,
@@ -570,7 +673,7 @@ namespace boost
detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
current_thread_data->tss_data.erase(key);
}
-
+
void set_tss_data(void const* key,
boost::shared_ptr<tss_cleanup_function> func,
void* tss_data,bool cleanup_existing)
@@ -591,12 +694,21 @@ namespace boost
erase_tss_node(key);
}
}
- else
+ else if(func || (tss_data!=0))
{
add_new_tss_node(key,func,tss_data);
}
}
}
+ BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
+ {
+ detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
+ if(current_thread_data)
+ {
+ current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
+ }
+ }
+
}
diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl b/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl
index b75a135..cab7c55 100644
--- a/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl
+++ b/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl
@@ -20,8 +20,8 @@ const int NANOSECONDS_PER_MICROSECOND = 1000;
inline void to_time(int milliseconds, boost::xtime& xt)
{
int res = 0;
- res = boost::xtime_get(&xt, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC);
+ res = boost::xtime_get(&xt, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
@@ -33,7 +33,6 @@ inline void to_time(int milliseconds, boost::xtime& xt)
xt.nsec -= NANOSECONDS_PER_SECOND;
}
}
-
#if defined(BOOST_HAS_PTHREADS)
inline void to_timespec(const boost::xtime& xt, timespec& ts)
{
@@ -57,8 +56,8 @@ inline void to_timespec_duration(const boost::xtime& xt, timespec& ts)
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
if (boost::xtime_cmp(xt, cur) <= 0)
{
@@ -88,8 +87,8 @@ inline void to_duration(boost::xtime xt, int& milliseconds)
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
if (boost::xtime_cmp(xt, cur) <= 0)
milliseconds = 0;
@@ -110,8 +109,8 @@ inline void to_microduration(boost::xtime xt, int& microseconds)
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
if (boost::xtime_cmp(xt, cur) <= 0)
microseconds = 0;
diff --git a/3rdParty/Boost/src/libs/thread/src/tss_null.cpp b/3rdParty/Boost/src/libs/thread/src/tss_null.cpp
index e93ba0f..b5029f1 100644
--- a/3rdParty/Boost/src/libs/thread/src/tss_null.cpp
+++ b/3rdParty/Boost/src/libs/thread/src/tss_null.cpp
@@ -8,7 +8,7 @@
#if defined(BOOST_HAS_WINTHREADS) && (defined(BOOST_THREAD_BUILD_LIB) || defined(BOOST_THREAD_TEST) || defined(UNDER_CE)) && (!defined(_MSC_VER) || defined(UNDER_CE))
-namespace boost
+namespace boost
{
/*
This file is a "null" implementation of tss cleanup; it's
@@ -32,7 +32,7 @@ namespace boost
longer needed and can be removed.
*/
}
-
+
}
#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) && !defined(_MSC_VER)
diff --git a/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp b/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp
index 05c7a6c..5a26f5e 100644
--- a/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp
+++ b/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp
@@ -4,29 +4,60 @@
// (C) Copyright 2007 Anthony Williams
// (C) Copyright 2007 David Deakins
+#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x400
+#endif
+
+#ifndef WINVER
#define WINVER 0x400
+#endif
#include <boost/thread/thread.hpp>
-#include <algorithm>
-#include <windows.h>
-#ifndef UNDER_CE
-#include <process.h>
-#endif
-#include <stdio.h>
#include <boost/thread/once.hpp>
#include <boost/thread/tss.hpp>
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/detail/tss_hooks.hpp>
+
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
-#include <boost/thread/detail/tss_hooks.hpp>
#include <boost/date_time/posix_time/conversion.hpp>
+#include <memory>
+#include <algorithm>
+#ifndef UNDER_CE
+#include <process.h>
+#endif
+#include <stdio.h>
+#include <windows.h>
+
namespace boost
{
+ namespace detail
+ {
+ thread_data_base::~thread_data_base()
+ {
+ {
+ for (notify_list_t::iterator i = notify.begin(), e = notify.end();
+ i != e; ++i)
+ {
+ i->second->unlock();
+ i->first->notify_all();
+ }
+ }
+ }
+ }
namespace
{
+#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
+ boost::once_flag current_thread_tls_init_flag;
+#else
boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
- DWORD current_thread_tls_key=0;
+#endif
+#if defined(UNDER_CE)
+ // Windows CE does not define the TLS_OUT_OF_INDEXES constant.
+#define TLS_OUT_OF_INDEXES 0xFFFFFFFF
+#endif
+ DWORD current_thread_tls_key=TLS_OUT_OF_INDEXES;
void create_current_thread_tls_key()
{
@@ -37,16 +68,16 @@ namespace boost
void cleanup_tls_key()
{
- if(current_thread_tls_key)
+ if(current_thread_tls_key!=TLS_OUT_OF_INDEXES)
{
TlsFree(current_thread_tls_key);
- current_thread_tls_key=0;
+ current_thread_tls_key=TLS_OUT_OF_INDEXES;
}
}
detail::thread_data_base* get_current_thread_data()
{
- if(!current_thread_tls_key)
+ if(current_thread_tls_key==TLS_OUT_OF_INDEXES)
{
return 0;
}
@@ -56,13 +87,13 @@ namespace boost
void set_current_thread_data(detail::thread_data_base* new_data)
{
boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
- if(current_thread_tls_key)
+ if(current_thread_tls_key!=TLS_OUT_OF_INDEXES)
BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data));
else
boost::throw_exception(thread_resource_error());
}
-#ifdef BOOST_NO_THREADEX
+#ifndef BOOST_HAS_THREADEX
// Windows CE doesn't define _beginthreadex
struct ThreadProxyData
@@ -75,22 +106,25 @@ namespace boost
DWORD WINAPI ThreadProxy(LPVOID args)
{
- ThreadProxyData* data=reinterpret_cast<ThreadProxyData*>(args);
+ std::auto_ptr<ThreadProxyData> data(reinterpret_cast<ThreadProxyData*>(args));
DWORD ret=data->start_address_(data->arglist_);
- delete data;
return ret;
}
-
+
typedef void* uintptr_t;
- inline uintptr_t const _beginthreadex(void* security, unsigned stack_size, unsigned (__stdcall* start_address)(void*),
+ inline uintptr_t _beginthreadex(void* security, unsigned stack_size, unsigned (__stdcall* start_address)(void*),
void* arglist, unsigned initflag, unsigned* thrdaddr)
{
DWORD threadID;
+ ThreadProxyData* data = new ThreadProxyData(start_address,arglist);
HANDLE hthread=CreateThread(static_cast<LPSECURITY_ATTRIBUTES>(security),stack_size,ThreadProxy,
- new ThreadProxyData(start_address,arglist),initflag,&threadID);
- if (hthread!=0)
- *thrdaddr=threadID;
+ data,initflag,&threadID);
+ if (hthread==0) {
+ delete data;
+ return 0;
+ }
+ *thrdaddr=threadID;
return reinterpret_cast<uintptr_t const>(hthread);
}
@@ -111,19 +145,6 @@ namespace boost
{}
};
- struct tss_data_node
- {
- void const* key;
- boost::shared_ptr<boost::detail::tss_cleanup_function> func;
- void* value;
- tss_data_node* next;
-
- tss_data_node(void const* key_,boost::shared_ptr<boost::detail::tss_cleanup_function> func_,void* value_,
- tss_data_node* next_):
- key(key_),func(func_),value(value_),next(next_)
- {}
- };
-
}
namespace
@@ -133,7 +154,7 @@ namespace boost
detail::thread_data_ptr current_thread_data(get_current_thread_data(),false);
if(current_thread_data)
{
- while(current_thread_data->tss_data || current_thread_data->thread_exit_callbacks)
+ while(! current_thread_data->tss_data.empty() || current_thread_data->thread_exit_callbacks)
{
while(current_thread_data->thread_exit_callbacks)
{
@@ -146,36 +167,43 @@ namespace boost
}
boost::detail::heap_delete(current_node);
}
- while(current_thread_data->tss_data)
+ for(std::map<void const*,detail::tss_data_node>::iterator next=current_thread_data->tss_data.begin(),
+ current,
+ end=current_thread_data->tss_data.end();
+ next!=end;)
{
- detail::tss_data_node* const current_node=current_thread_data->tss_data;
- current_thread_data->tss_data=current_node->next;
- if(current_node->func)
+ current=next;
+ ++next;
+ if(current->second.func && (current->second.value!=0))
{
- (*current_node->func)(current_node->value);
+ (*current->second.func)(current->second.value);
}
- boost::detail::heap_delete(current_node);
+ current_thread_data->tss_data.erase(current);
}
}
-
+
set_current_thread_data(0);
}
}
-
+
unsigned __stdcall thread_start_function(void* param)
{
detail::thread_data_base* const thread_info(reinterpret_cast<detail::thread_data_base*>(param));
set_current_thread_data(thread_info);
- try
+#ifndef BOOST_NO_EXCEPTIONS
+ try // BOOST_NO_EXCEPTIONS protected
+#endif
{
thread_info->run();
}
- catch(thread_interrupted const&)
+#ifndef BOOST_NO_EXCEPTIONS
+ catch(thread_interrupted const&) // BOOST_NO_EXCEPTIONS protected
{
}
+#endif
// Removed as it stops the debugger identifying the cause of the exception
// Unhandled exceptions still cause the application to terminate
-// catch(...)
+// catch(...) // BOOST_NO_EXCEPTIONS protected
// {
// std::terminate();
// }
@@ -184,7 +212,7 @@ namespace boost
}
}
- thread::thread()
+ thread::thread() BOOST_NOEXCEPT
{}
void thread::start_thread()
@@ -199,6 +227,19 @@ namespace boost
ResumeThread(thread_info->thread_handle);
}
+ void thread::start_thread(const attributes& attr)
+ {
+ //uintptr_t const new_thread=_beginthreadex(attr.get_security(),attr.get_stack_size(),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
+ uintptr_t const new_thread=_beginthreadex(0,static_cast<unsigned int>(attr.get_stack_size()),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
+ if(!new_thread)
+ {
+ boost::throw_exception(thread_resource_error());
+ }
+ intrusive_ptr_add_ref(thread_info.get());
+ thread_info->thread_handle=(detail::win32::handle)(new_thread);
+ ResumeThread(thread_info->thread_handle);
+ }
+
thread::thread(detail::thread_data_ptr data):
thread_info(data)
{}
@@ -213,9 +254,12 @@ namespace boost
++count;
interruption_enabled=false;
}
-
+
void run()
{}
+ void notify_all_at_thread_exit(condition_variable*, mutex*)
+ {}
+
private:
externally_launched_thread(externally_launched_thread&);
void operator=(externally_launched_thread&);
@@ -224,15 +268,19 @@ namespace boost
void make_external_thread_data()
{
externally_launched_thread* me=detail::heap_new<externally_launched_thread>();
- try
+#ifndef BOOST_NO_EXCEPTIONS
+ try // BOOST_NO_EXCEPTIONS protected
+#endif
{
set_current_thread_data(me);
}
- catch(...)
+#ifndef BOOST_NO_EXCEPTIONS
+ catch(...) // BOOST_NO_EXCEPTIONS protected
{
detail::heap_delete(me);
- throw;
+ throw; // BOOST_NO_EXCEPTIONS protected
}
+#endif
}
detail::thread_data_base* get_or_make_current_thread_data()
@@ -245,48 +293,73 @@ namespace boost
}
return current_thread_data;
}
-
- }
- thread::~thread()
- {
- detach();
}
-
- thread::id thread::get_id() const
+
+ thread::id thread::get_id() const BOOST_NOEXCEPT
{
+ #if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
+ detail::thread_data_ptr local_thread_info=(get_thread_info)();
+ return local_thread_info?local_thread_info->id:0;
+ //return const_cast<thread*>(this)->native_handle();
+ #else
return thread::id((get_thread_info)());
+ #endif
}
- bool thread::joinable() const
+ bool thread::joinable() const BOOST_NOEXCEPT
{
return (get_thread_info)();
}
-
void thread::join()
{
+ if (this_thread::get_id() == get_id())
+ {
+ boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
+ }
detail::thread_data_ptr local_thread_info=(get_thread_info)();
if(local_thread_info)
{
this_thread::interruptible_wait(local_thread_info->thread_handle,detail::timeout::sentinel());
release_handle();
}
+ else
+ {
+#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
+ boost::throw_exception(thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable"));
+#endif
+ }
}
bool thread::timed_join(boost::system_time const& wait_until)
{
- detail::thread_data_ptr local_thread_info=(get_thread_info)();
- if(local_thread_info)
- {
- if(!this_thread::interruptible_wait(local_thread_info->thread_handle,get_milliseconds_until(wait_until)))
- {
- return false;
- }
- release_handle();
- }
- return true;
+ return do_try_join_until(get_milliseconds_until(wait_until));
}
-
+
+ bool thread::do_try_join_until(uintmax_t milli)
+ {
+ if (this_thread::get_id() == get_id())
+ {
+ boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
+ }
+ detail::thread_data_ptr local_thread_info=(get_thread_info)();
+ if(local_thread_info)
+ {
+ if(!this_thread::interruptible_wait(local_thread_info->thread_handle,milli))
+ {
+ return false;
+ }
+ release_handle();
+ return true;
+ }
+ else
+ {
+#ifdef BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
+ boost::throw_exception(thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable"));
+#endif
+ }
+ }
+
void thread::detach()
{
release_handle();
@@ -296,7 +369,7 @@ namespace boost
{
thread_info=0;
}
-
+
void thread::interrupt()
{
detail::thread_data_ptr local_thread_info=(get_thread_info)();
@@ -305,20 +378,20 @@ namespace boost
local_thread_info->interrupt();
}
}
-
- bool thread::interruption_requested() const
+
+ bool thread::interruption_requested() const BOOST_NOEXCEPT
{
detail::thread_data_ptr local_thread_info=(get_thread_info)();
return local_thread_info.get() && (detail::win32::WaitForSingleObject(local_thread_info->interruption_handle,0)==0);
}
-
- unsigned thread::hardware_concurrency()
+
+ unsigned thread::hardware_concurrency() BOOST_NOEXCEPT
{
SYSTEM_INFO info={{0}};
GetSystemInfo(&info);
return info.dwNumberOfProcessors;
}
-
+
thread::native_handle_type thread::native_handle()
{
detail::thread_data_ptr local_thread_info=(get_thread_info)();
@@ -369,7 +442,7 @@ namespace boost
target_time.abs_time.time_of_day().ticks_per_second();
if(ticks_per_second>hundred_nanoseconds_in_one_second)
{
- posix_time::time_duration::tick_type const
+ posix_time::time_duration::tick_type const
ticks_per_hundred_nanoseconds=
ticks_per_second/hundred_nanoseconds_in_one_second;
due_time.QuadPart+=
@@ -387,7 +460,7 @@ namespace boost
return due_time;
}
}
-
+
bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time)
{
@@ -408,10 +481,10 @@ namespace boost
}
detail::win32::handle_manager timer_handle;
-
+
#ifndef UNDER_CE
unsigned const min_timer_wait_period=20;
-
+
if(!target_time.is_sentinel())
{
detail::timeout::remaining_time const time_left=target_time.remaining_milliseconds();
@@ -422,7 +495,7 @@ namespace boost
if(timer_handle!=0)
{
LARGE_INTEGER due_time=get_due_time(target_time);
-
+
bool const set_time_succeeded=SetWaitableTimer(timer_handle,&due_time,0,0,0,false)!=0;
if(set_time_succeeded)
{
@@ -438,17 +511,17 @@ namespace boost
}
}
#endif
-
+
bool const using_timer=timeout_index!=~0u;
detail::timeout::remaining_time time_left(0);
-
+
do
{
if(!using_timer)
{
time_left=target_time.remaining_milliseconds();
}
-
+
if(handle_count)
{
unsigned long const notified_index=detail::win32::WaitForMultipleObjects(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds);
@@ -482,9 +555,14 @@ namespace boost
return false;
}
- thread::id get_id()
+ thread::id get_id() BOOST_NOEXCEPT
{
+ #if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
+ //return detail::win32::GetCurrentThread();
+ return detail::win32::GetCurrentThreadId();
+ #else
return thread::id(get_or_make_current_thread_data());
+ #endif
}
void interruption_point()
@@ -495,23 +573,23 @@ namespace boost
throw thread_interrupted();
}
}
-
- bool interruption_enabled()
+
+ bool interruption_enabled() BOOST_NOEXCEPT
{
return get_current_thread_data() && get_current_thread_data()->interruption_enabled;
}
-
- bool interruption_requested()
+
+ bool interruption_requested() BOOST_NOEXCEPT
{
return get_current_thread_data() && (detail::win32::WaitForSingleObject(get_current_thread_data()->interruption_handle,0)==0);
}
- void yield()
+ void yield() BOOST_NOEXCEPT
{
detail::win32::Sleep(0);
}
-
- disable_interruption::disable_interruption():
+
+ disable_interruption::disable_interruption() BOOST_NOEXCEPT:
interruption_was_enabled(interruption_enabled())
{
if(interruption_was_enabled)
@@ -519,8 +597,8 @@ namespace boost
get_current_thread_data()->interruption_enabled=false;
}
}
-
- disable_interruption::~disable_interruption()
+
+ disable_interruption::~disable_interruption() BOOST_NOEXCEPT
{
if(get_current_thread_data())
{
@@ -528,15 +606,15 @@ namespace boost
}
}
- restore_interruption::restore_interruption(disable_interruption& d)
+ restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT
{
if(d.interruption_was_enabled)
{
get_current_thread_data()->interruption_enabled=true;
}
}
-
- restore_interruption::~restore_interruption()
+
+ restore_interruption::~restore_interruption() BOOST_NOEXCEPT
{
if(get_current_thread_data())
{
@@ -561,14 +639,11 @@ namespace boost
detail::thread_data_base* const current_thread_data(get_current_thread_data());
if(current_thread_data)
{
- detail::tss_data_node* current_node=current_thread_data->tss_data;
- while(current_node)
+ std::map<void const*,tss_data_node>::iterator current_node=
+ current_thread_data->tss_data.find(key);
+ if(current_node!=current_thread_data->tss_data.end())
{
- if(current_node->key==key)
- {
- return current_node;
- }
- current_node=current_node->next;
+ return &current_node->second;
}
}
return NULL;
@@ -582,24 +657,44 @@ namespace boost
}
return NULL;
}
-
- void set_tss_data(void const* key,boost::shared_ptr<tss_cleanup_function> func,void* tss_data,bool cleanup_existing)
+
+ void add_new_tss_node(void const* key,
+ boost::shared_ptr<tss_cleanup_function> func,
+ void* tss_data)
+ {
+ detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
+ current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data)));
+ }
+
+ void erase_tss_node(void const* key)
+ {
+ detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
+ current_thread_data->tss_data.erase(key);
+ }
+
+ void set_tss_data(void const* key,
+ boost::shared_ptr<tss_cleanup_function> func,
+ void* tss_data,bool cleanup_existing)
{
if(tss_data_node* const current_node=find_tss_data(key))
{
- if(cleanup_existing && current_node->func.get() && current_node->value)
+ if(cleanup_existing && current_node->func && (current_node->value!=0))
{
(*current_node->func)(current_node->value);
}
- current_node->func=func;
- current_node->value=tss_data;
+ if(func || (tss_data!=0))
+ {
+ current_node->func=func;
+ current_node->value=tss_data;
+ }
+ else
+ {
+ erase_tss_node(key);
+ }
}
- else if(func && tss_data)
+ else if(func || (tss_data!=0))
{
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- tss_data_node* const new_node=
- heap_new<tss_data_node>(key,func,tss_data,current_thread_data->tss_data);
- current_thread_data->tss_data=new_node;
+ add_new_tss_node(key,func,tss_data);
}
}
}
@@ -619,6 +714,14 @@ namespace boost
boost::run_thread_exit_callbacks();
}
+ BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
+ {
+ detail::thread_data_base* const current_thread_data(get_current_thread_data());
+ if(current_thread_data)
+ {
+ current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
+ }
+ }
}
diff --git a/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl b/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl
index 5ec3b17..c646783 100644
--- a/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl
+++ b/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl
@@ -17,8 +17,8 @@ const int NANOSECONDS_PER_MICROSECOND = 1000;
inline void to_time(int milliseconds, boost::xtime& xt)
{
int res = 0;
- res = boost::xtime_get(&xt, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&xt, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
@@ -54,8 +54,8 @@ inline void to_timespec_duration(const boost::xtime& xt, timespec& ts)
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
if (boost::xtime_cmp(xt, cur) <= 0)
{
@@ -85,8 +85,8 @@ inline void to_duration(boost::xtime xt, int& milliseconds)
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
if (boost::xtime_cmp(xt, cur) <= 0)
milliseconds = 0;
@@ -107,8 +107,8 @@ inline void to_microduration(boost::xtime xt, int& microseconds)
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
if (boost::xtime_cmp(xt, cur) <= 0)
microseconds = 0;
diff --git a/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp b/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp
index 9699a12..2dc019f 100644
--- a/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp
+++ b/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp
@@ -5,6 +5,7 @@
#include <boost/thread/detail/config.hpp>
+
#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL)
#include <boost/thread/detail/tss_hooks.hpp>
diff --git a/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp b/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp
index 8ef045b..1654b19 100644
--- a/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp
+++ b/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp
@@ -1,4 +1,4 @@
-// $Id: tss_pe.cpp 66259 2010-10-29 23:27:00Z anthonyw $
+// $Id: tss_pe.cpp 79373 2012-07-09 05:55:01Z viboes $
// (C) Copyright Aaron W. LaFramboise, Roland Schwarz, Michael Glassford 2004.
// (C) Copyright 2007 Roland Schwarz
// (C) Copyright 2007 Anthony Williams
@@ -11,7 +11,7 @@
#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB)
-#if defined(__MINGW32__) && !defined(_WIN64)
+#if (defined(__MINGW32__) && !defined(_WIN64)) || defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR)
#include <boost/thread/detail/tss_hooks.hpp>
@@ -25,7 +25,7 @@ namespace boost
}
namespace {
- void NTAPI on_tls_callback(void* h, DWORD dwReason, PVOID pv)
+ void NTAPI on_tls_callback(void* , DWORD dwReason, PVOID )
{
switch (dwReason)
{
@@ -38,7 +38,8 @@ namespace {
}
}
-#if (__MINGW32_MAJOR_VERSION >3) || ((__MINGW32_MAJOR_VERSION==3) && (__MINGW32_MINOR_VERSION>=18))
+#if defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION >3) || \
+ ((__MINGW32_MAJOR_VERSION==3) && (__MINGW32_MINOR_VERSION>=18))
extern "C"
{
PIMAGE_TLS_CALLBACK __crt_xl_tls_callback__ __attribute__ ((section(".CRT$XLB"))) = on_tls_callback;