mirror of
https://github.com/boostorg/bcp.git
synced 2026-07-21 13:13:34 +00:00
Bring bcp up to date with filesystem V3.
[SVN r67486]
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ void bcp_implementation::add_directory(const fs::path& p)
|
||||
// we need to convert *i back into
|
||||
// a relative path, what follows is a hack:
|
||||
//
|
||||
std::string s(i->string());
|
||||
std::string s(i->path().string());
|
||||
if(m_boost_path.string().size())
|
||||
s.erase(0, m_boost_path.string().size() + 1);
|
||||
fs::path np = s;
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#if defined(BOOST_FILESYSTEM_VERSION) && (BOOST_FILESYSTEM_VERSION != 3)
|
||||
# error "This library must be built with Boost.Filesystem version 3"
|
||||
#else
|
||||
#define BOOST_FILESYSTEM_VERSION 3
|
||||
#endif
|
||||
|
||||
class bcp_application;
|
||||
typedef boost::shared_ptr<bcp_application> pbcp_application;
|
||||
|
||||
|
||||
+5
-12
@@ -81,7 +81,7 @@ void bcp_implementation::enable_unix_lines()
|
||||
void bcp_implementation::set_boost_path(const char* p)
|
||||
{
|
||||
// Hack to strip trailing slashes from the path
|
||||
m_boost_path = (fs::path(p, fs::native) / "boost").parent_path();
|
||||
m_boost_path = (fs::path(p) / "boost").parent_path();
|
||||
fs::path check = m_boost_path / "boost" / "version.hpp";
|
||||
if(!fs::exists(check))
|
||||
{
|
||||
@@ -94,7 +94,7 @@ void bcp_implementation::set_boost_path(const char* p)
|
||||
|
||||
void bcp_implementation::set_destination(const char* p)
|
||||
{
|
||||
m_dest_path = fs::path(p, fs::native);
|
||||
m_dest_path = fs::path(p);
|
||||
}
|
||||
|
||||
void bcp_implementation::add_module(const char* p)
|
||||
@@ -140,7 +140,7 @@ int bcp_implementation::run()
|
||||
if(!m_list_mode && !m_license_mode && !fs::exists(m_dest_path))
|
||||
{
|
||||
std::string msg("Destination path does not exist: ");
|
||||
msg.append(m_dest_path.native_file_string());
|
||||
msg.append(m_dest_path.string());
|
||||
std::runtime_error e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
@@ -190,15 +190,8 @@ int bcp_implementation::run()
|
||||
//
|
||||
fs::path module;
|
||||
fs::path exmodule;
|
||||
try{
|
||||
module = fs::path(*i);
|
||||
exmodule = fs::path(*i + ".hpp");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
module = fs::path(*i, fs::native);
|
||||
exmodule = fs::path(*i + ".hpp", fs::native);
|
||||
}
|
||||
module = fs::path(*i);
|
||||
exmodule = fs::path(*i + ".hpp");
|
||||
|
||||
if(m_scan_mode)
|
||||
{
|
||||
|
||||
+11
-11
@@ -63,7 +63,7 @@ void bcp_implementation::copy_path(const fs::path& p)
|
||||
static std::vector<char> v1, v2;
|
||||
v1.clear();
|
||||
v2.clear();
|
||||
std::ifstream is((m_boost_path / p).native_file_string().c_str());
|
||||
std::ifstream is((m_boost_path / p).string().c_str());
|
||||
std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
|
||||
|
||||
static boost::regex libname_matcher;
|
||||
@@ -78,9 +78,9 @@ void bcp_implementation::copy_path(const fs::path& p)
|
||||
|
||||
std::ofstream os;
|
||||
if(m_unix_lines)
|
||||
os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
os.open((m_dest_path / p).string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
else
|
||||
os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
|
||||
os.open((m_dest_path / p).string().c_str(), std::ios_base::out);
|
||||
os.write(&*v1.begin(), v1.size());
|
||||
os.close();
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void bcp_implementation::copy_path(const fs::path& p)
|
||||
static std::vector<char> v1, v2;
|
||||
v1.clear();
|
||||
v2.clear();
|
||||
std::ifstream is((m_boost_path / p).native_file_string().c_str());
|
||||
std::ifstream is((m_boost_path / p).string().c_str());
|
||||
std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
|
||||
|
||||
static boost::regex libname_matcher;
|
||||
@@ -111,9 +111,9 @@ void bcp_implementation::copy_path(const fs::path& p)
|
||||
|
||||
std::ofstream os;
|
||||
if(m_unix_lines)
|
||||
os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
os.open((m_dest_path / p).string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
else
|
||||
os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
|
||||
os.open((m_dest_path / p).string().c_str(), std::ios_base::out);
|
||||
os.write(&*v1.begin(), v1.size());
|
||||
os.close();
|
||||
}
|
||||
@@ -127,7 +127,7 @@ void bcp_implementation::copy_path(const fs::path& p)
|
||||
static std::vector<char> v1, v2;
|
||||
v1.clear();
|
||||
v2.clear();
|
||||
std::ifstream is((m_boost_path / p).native_file_string().c_str());
|
||||
std::ifstream is((m_boost_path / p).string().c_str());
|
||||
std::copy(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>(), std::back_inserter(v1));
|
||||
|
||||
static const boost::regex namespace_matcher(
|
||||
@@ -202,20 +202,20 @@ void bcp_implementation::copy_path(const fs::path& p)
|
||||
|
||||
std::ofstream os;
|
||||
if(m_unix_lines)
|
||||
os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
os.open((m_dest_path / p).string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
else
|
||||
os.open((m_dest_path / p).native_file_string().c_str(), std::ios_base::out);
|
||||
os.open((m_dest_path / p).string().c_str(), std::ios_base::out);
|
||||
if(v1.size())
|
||||
os.write(&*v1.begin(), v1.size());
|
||||
os.close();
|
||||
}
|
||||
else if(m_unix_lines && !is_binary_file(p))
|
||||
{
|
||||
std::ifstream is((m_boost_path / p).native_file_string().c_str());
|
||||
std::ifstream is((m_boost_path / p).string().c_str());
|
||||
std::istreambuf_iterator<char> isi(is);
|
||||
std::istreambuf_iterator<char> end;
|
||||
|
||||
std::ofstream os((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
std::ofstream os((m_dest_path / p).string().c_str(), std::ios_base::binary | std::ios_base::out);
|
||||
std::ostreambuf_iterator<char> osi(os);
|
||||
|
||||
std::copy(isi, end, osi);
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ bool bcp_implementation::is_source_file(const fs::path& p)
|
||||
")",
|
||||
boost::regex::perl | boost::regex::icase
|
||||
);
|
||||
return boost::regex_match(p.filename(), e);
|
||||
return boost::regex_match(p.filename().string(), e);
|
||||
}
|
||||
|
||||
bool bcp_implementation::is_html_file(const fs::path& p)
|
||||
@@ -34,7 +34,7 @@ bool bcp_implementation::is_html_file(const fs::path& p)
|
||||
"html?|css"
|
||||
")"
|
||||
);
|
||||
return boost::regex_match(p.filename(), e);
|
||||
return boost::regex_match(p.filename().string(), e);
|
||||
}
|
||||
|
||||
bool bcp_implementation::is_binary_file(const fs::path& p)
|
||||
@@ -52,7 +52,7 @@ bool bcp_implementation::is_binary_file(const fs::path& p)
|
||||
"|"
|
||||
"(Jamfile|makefile|configure)",
|
||||
boost::regex::perl | boost::regex::icase);
|
||||
return !boost::regex_match(p.leaf(), e);
|
||||
return !boost::regex_match(p.leaf().string(), e);
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,6 @@ bool bcp_implementation::is_jam_file(const fs::path& p)
|
||||
"(Jamfile|Jamroot)\\.?",
|
||||
boost::regex::perl | boost::regex::icase
|
||||
);
|
||||
return boost::regex_match(p.filename(), e);
|
||||
return boost::regex_match(p.filename().string(), e);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -57,11 +57,11 @@ void fileview::close()
|
||||
void fileview::open(const boost::filesystem::path& p)
|
||||
{
|
||||
cow();
|
||||
std::ifstream is(p.native_file_string().c_str());
|
||||
std::ifstream is(p.string().c_str());
|
||||
if(!is)
|
||||
{
|
||||
std::string msg("Bad file name: ");
|
||||
msg += p.native_file_string();
|
||||
msg += p.string();
|
||||
std::runtime_error e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(BOOST_FILESYSTEM_VERSION) && (BOOST_FILESYSTEM_VERSION != 3)
|
||||
# error "This library must be built with Boost.Filesystem version 3"
|
||||
#else
|
||||
#define BOOST_FILESYSTEM_VERSION 3
|
||||
#endif
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "bcp.hpp"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include "bcp.hpp"
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std{
|
||||
@@ -60,7 +60,7 @@ int cpp_main(int argc, char* argv[])
|
||||
// with files that already exist, if they're not portable
|
||||
// names it's too late for us to do anything about it).
|
||||
//
|
||||
boost::filesystem::path::default_name_check(filesystem_name_check);
|
||||
/*boost::filesystem::path::default_name_check(filesystem_name_check);*/
|
||||
//
|
||||
// without arguments just show help:
|
||||
//
|
||||
@@ -68,7 +68,7 @@ int cpp_main(int argc, char* argv[])
|
||||
{
|
||||
std::cout << "Error: insufficient arguments, don't know what to do." << std::endl;
|
||||
show_usage();
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
// create the application object:
|
||||
|
||||
@@ -57,7 +57,7 @@ void bcp_implementation::output_license_info()
|
||||
i = m_license_data.begin();
|
||||
j = m_license_data.end();
|
||||
|
||||
std::ofstream os(m_dest_path.native_file_string().c_str());
|
||||
std::ofstream os(m_dest_path.string().c_str());
|
||||
if(!os)
|
||||
{
|
||||
std::string msg("Error opening ");
|
||||
|
||||
+2
-2
@@ -239,10 +239,10 @@ void bcp_implementation::scan_license(const fs::path& p, const fileview& v)
|
||||
// Perform the actual conversion
|
||||
if (m_bsl_convert_mode) {
|
||||
try{
|
||||
std::ofstream out((m_boost_path / p).native_file_string().c_str());
|
||||
std::ofstream out((m_boost_path / p).string().c_str());
|
||||
if (!out) {
|
||||
std::string msg("Cannot open file for license conversion: ");
|
||||
msg += p.native_file_string();
|
||||
msg += p.string();
|
||||
std::runtime_error e(msg);
|
||||
boost::throw_exception(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user