bug fixes / windows port
This commit is contained in:
parent
a8772e5aa0
commit
42cf0e62a8
13 changed files with 44 additions and 28 deletions
|
|
@ -78,9 +78,10 @@ namespace fc {
|
||||||
bool is_directory( const path& p );
|
bool is_directory( const path& p );
|
||||||
bool is_regular_file( const path& p );
|
bool is_regular_file( const path& p );
|
||||||
void create_directories( const path& p );
|
void create_directories( const path& p );
|
||||||
|
void remove_all( const path& p );
|
||||||
path absolute( const path& p );
|
path absolute( const path& p );
|
||||||
path canonical( const path& p );
|
path canonical( const path& p );
|
||||||
size_t file_size( const path& p );
|
uint64_t file_size( const path& p );
|
||||||
bool remove( const path& p );
|
bool remove( const path& p );
|
||||||
void copy( const path& from, const path& to );
|
void copy( const path& from, const path& to );
|
||||||
void create_hard_link( const path& from, const path& to );
|
void create_hard_link( const path& from, const path& to );
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#ifndef _FC_LOG_HPP_
|
#pragma once
|
||||||
#define _FC_LOG_HPP_
|
|
||||||
#include <fc/utility.hpp>
|
#include <fc/utility.hpp>
|
||||||
|
|
||||||
namespace boost { class mutex; }
|
namespace boost { class mutex; }
|
||||||
|
|
@ -30,4 +29,3 @@ namespace fc {
|
||||||
#define elog(...) do { fc::log( CONSOLE_RED, __FILE__, __LINE__, __func__, __VA_ARGS__ ); }while(false)
|
#define elog(...) do { fc::log( CONSOLE_RED, __FILE__, __LINE__, __func__, __VA_ARGS__ ); }while(false)
|
||||||
|
|
||||||
|
|
||||||
#endif // _FC_LOG_HPP_
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@
|
||||||
#include <fc/typename.hpp>
|
#include <fc/typename.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
template<BOOST_PP_ENUM_PARAMS(9, typename A)> struct tuple;
|
template<BOOST_PP_ENUM_PARAMS(9, typename A)> struct tuple;
|
||||||
|
|
||||||
|
|
@ -30,14 +27,14 @@ namespace fc {
|
||||||
class key_val;
|
class key_val;
|
||||||
class object {
|
class object {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<key_val>::const_iterator const_iterator;
|
typedef fc::vector<key_val>::const_iterator const_iterator;
|
||||||
//fc::string type;
|
//fc::string type;
|
||||||
std::vector<key_val> fields;
|
fc::vector<key_val> fields;
|
||||||
};
|
};
|
||||||
class array {
|
class array {
|
||||||
public:
|
public:
|
||||||
array( size_t s = 0 ):fields(s){}
|
array( size_t s = 0 ):fields(s){}
|
||||||
std::vector<value> fields;
|
fc::vector<value> fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct const_visitor {
|
struct const_visitor {
|
||||||
|
|
@ -141,6 +138,7 @@ namespace fc {
|
||||||
/** gets the stored type **/
|
/** gets the stored type **/
|
||||||
const char* type()const;
|
const char* type()const;
|
||||||
bool is_null()const;
|
bool is_null()const;
|
||||||
|
bool is_string()const;
|
||||||
|
|
||||||
void visit( const_visitor&& v )const;
|
void visit( const_visitor&& v )const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace fc {
|
||||||
virtual void operator()( const float& v ){ m_out = fc::lexical_cast<fc::string>(v); }
|
virtual void operator()( const float& v ){ m_out = fc::lexical_cast<fc::string>(v); }
|
||||||
virtual void operator()( const double& v ){ m_out = fc::lexical_cast<fc::string>(v); }
|
virtual void operator()( const double& v ){ m_out = fc::lexical_cast<fc::string>(v); }
|
||||||
virtual void operator()( const bool& v ){ m_out = v != 0 ? "true" : "false"; }
|
virtual void operator()( const bool& v ){ m_out = v != 0 ? "true" : "false"; }
|
||||||
virtual void operator()( const fc::string& v ){ m_out = v; }
|
virtual void operator()( const fc::string& v ) { m_out = v; }
|
||||||
virtual void operator()( const value::object& ) { FC_THROW_MSG("bad cast"); }
|
virtual void operator()( const value::object& ) { FC_THROW_MSG("bad cast"); }
|
||||||
virtual void operator()( const value::array& ) { FC_THROW_MSG("bad cast"); }
|
virtual void operator()( const value::array& ) { FC_THROW_MSG("bad cast"); }
|
||||||
virtual void operator()( ) { FC_THROW_MSG("bad cast"); }
|
virtual void operator()( ) { FC_THROW_MSG("bad cast"); }
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,11 @@ fc::string error_frame::to_string()const {
|
||||||
if( meta ) {
|
if( meta ) {
|
||||||
auto itr = meta->find( key.c_str() );
|
auto itr = meta->find( key.c_str() );
|
||||||
if( itr != meta->end() ) {
|
if( itr != meta->end() ) {
|
||||||
|
if( itr->val.is_string() ) {
|
||||||
|
ss<<itr->val.cast<fc::string>();
|
||||||
|
} else {
|
||||||
ss << fc::json::to_string( itr->val );
|
ss << fc::json::to_string( itr->val );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ss << "???";
|
ss << "???";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <fc/value_cast.hpp>
|
#include <fc/value_cast.hpp>
|
||||||
|
#include <fc/error_report.hpp>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
void pack( fc::value& v, const fc::path& s ) {
|
void pack( fc::value& v, const fc::path& s ) {
|
||||||
|
|
@ -121,8 +122,19 @@ namespace fc {
|
||||||
void create_directories( const path& p ) { boost::filesystem::create_directories(p); }
|
void create_directories( const path& p ) { boost::filesystem::create_directories(p); }
|
||||||
bool is_directory( const path& p ) { return boost::filesystem::is_directory(p); }
|
bool is_directory( const path& p ) { return boost::filesystem::is_directory(p); }
|
||||||
bool is_regular_file( const path& p ) { return boost::filesystem::is_regular_file(p); }
|
bool is_regular_file( const path& p ) { return boost::filesystem::is_regular_file(p); }
|
||||||
size_t file_size( const path& p ) { return boost::filesystem::file_size(p); }
|
uint64_t file_size( const path& p ) { return boost::filesystem::file_size(p); }
|
||||||
void copy( const path& f, const path& t ) { boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); }
|
void remove_all( const path& p ) { boost::filesystem::remove_all(p); }
|
||||||
|
void copy( const path& f, const path& t ) {
|
||||||
|
try {
|
||||||
|
boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) );
|
||||||
|
} catch ( boost::system::system_error& e ) {
|
||||||
|
FC_THROW_REPORT( "Copy from ${srcfile} to ${dstfile} failed because ${reason}",
|
||||||
|
fc::value().set("srcfile",f).set("dstfile",t).set("reason",e.what() ) );
|
||||||
|
} catch ( ... ) {
|
||||||
|
FC_THROW_REPORT( "Copy from ${srcfile} to ${dstfile} failed",
|
||||||
|
fc::value().set("srcfile",f).set("dstfile",t).set("inner", fc::except_str() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
void create_hard_link( const path& f, const path& t ) { boost::filesystem::create_hard_link( f, t ); }
|
void create_hard_link( const path& f, const path& t ) { boost::filesystem::create_hard_link( f, t ); }
|
||||||
bool remove( const path& f ) { return boost::filesystem::remove( f ); }
|
bool remove( const path& f ) { return boost::filesystem::remove( f ); }
|
||||||
fc::path canonical( const fc::path& p ) { return boost::filesystem::canonical(p); }
|
fc::path canonical( const fc::path& p ) { return boost::filesystem::canonical(p); }
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,6 @@ namespace fc {
|
||||||
}
|
}
|
||||||
|
|
||||||
cin_t::~cin_t() {
|
cin_t::~cin_t() {
|
||||||
wlog( "~cin_t" );
|
|
||||||
/*
|
/*
|
||||||
cin_buffer& b = get_cin_buffer();
|
cin_buffer& b = get_cin_buffer();
|
||||||
if( b.read_ready ) {
|
if( b.read_ready ) {
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,10 @@ namespace fc { namespace json {
|
||||||
send_error( id, error_object( "error report", fc::value(eo) ) );
|
send_error( id, error_object( "error report", fc::value(eo) ) );
|
||||||
}
|
}
|
||||||
} catch ( const fc::json::error_object& eo ) {
|
} catch ( const fc::json::error_object& eo ) {
|
||||||
|
wlog( "%s", eo.message.c_str() );
|
||||||
send_error( id, eo );
|
send_error( id, eo );
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
|
wlog( "%s", fc::except_str().c_str() );
|
||||||
send_error( id, error_object( fc::except_str(), fc::value() ) );
|
send_error( id, error_object( fc::except_str(), fc::value() ) );
|
||||||
}
|
}
|
||||||
} else { // ignore exception + result
|
} else { // ignore exception + result
|
||||||
|
|
|
||||||
|
|
@ -55,12 +55,10 @@ namespace fc { namespace json {
|
||||||
|
|
||||||
rpc_stream_connection::rpc_stream_connection( fc::istream& i, fc::ostream& o )
|
rpc_stream_connection::rpc_stream_connection( fc::istream& i, fc::ostream& o )
|
||||||
:my( new impl(i,o,*this) ){
|
:my( new impl(i,o,*this) ){
|
||||||
slog( "%p", this );
|
|
||||||
}
|
}
|
||||||
rpc_stream_connection::rpc_stream_connection(){ slog( "%p...",this); }
|
rpc_stream_connection::rpc_stream_connection(){ slog( "%p...",this); }
|
||||||
rpc_stream_connection::rpc_stream_connection(const rpc_stream_connection& c):my(c.my){ slog( "%p",this); }
|
rpc_stream_connection::rpc_stream_connection(const rpc_stream_connection& c):my(c.my){ slog( "%p",this); }
|
||||||
rpc_stream_connection::~rpc_stream_connection(){
|
rpc_stream_connection::~rpc_stream_connection(){
|
||||||
slog( "my %p", my.get() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the life of the streams must exceed the life of all copies
|
// the life of the streams must exceed the life of all copies
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ namespace fc {
|
||||||
}
|
}
|
||||||
return file_name;
|
return file_name;
|
||||||
}
|
}
|
||||||
|
boost::mutex& log_mutex() {
|
||||||
|
static boost::mutex* m = new boost::mutex(); return *m;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define isatty _isatty
|
#define isatty _isatty
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,13 @@ namespace fc {
|
||||||
try {
|
try {
|
||||||
return static_cast<std::streamsize>(fc::asio::read_some( *m_pi, boost::asio::buffer( s, static_cast<size_t>(n) ) ));
|
return static_cast<std::streamsize>(fc::asio::read_some( *m_pi, boost::asio::buffer( s, static_cast<size_t>(n) ) ));
|
||||||
} catch ( const boost::system::system_error& e ) {
|
} catch ( const boost::system::system_error& e ) {
|
||||||
wlog( "%s", fc::except_str().c_str() );
|
// wlog( "%s", fc::except_str().c_str() );
|
||||||
if( e.code() == boost::asio::error::eof )
|
if( e.code() == boost::asio::error::eof )
|
||||||
return -1;
|
return -1;
|
||||||
|
wlog( "%s", fc::except_str().c_str() );
|
||||||
throw;
|
throw;
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
wlog( "%s", fc::except_str().c_str() );
|
//wlog( "%s", fc::except_str().c_str() );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -74,8 +75,7 @@ FC_START_SHARED_IMPL( fc::process )
|
||||||
inp->close();
|
inp->close();
|
||||||
}
|
}
|
||||||
if( _exited.valid() && !_exited.ready()) {
|
if( _exited.valid() && !_exited.ready()) {
|
||||||
slog( "terminate...");
|
//child->terminate();
|
||||||
child->terminate();
|
|
||||||
_exited.wait();
|
_exited.wait();
|
||||||
}
|
}
|
||||||
}catch(...) {
|
}catch(...) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,6 @@ namespace fc {
|
||||||
void* thread_ptr() {
|
void* thread_ptr() {
|
||||||
return &thread::current();
|
return &thread::current();
|
||||||
}
|
}
|
||||||
boost::mutex& log_mutex() {
|
|
||||||
static boost::mutex m; return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
thread*& current_thread() {
|
thread*& current_thread() {
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include <fc/exception.hpp>
|
#include <fc/exception.hpp>
|
||||||
#include <fc/typename.hpp>
|
#include <fc/typename.hpp>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <fc/error_report.hpp>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
||||||
|
|
@ -290,6 +291,9 @@ value& value::operator=( const value& v ){
|
||||||
bool value::is_null()const {
|
bool value::is_null()const {
|
||||||
return strcmp(gh(holder)->type(), "void") == 0;
|
return strcmp(gh(holder)->type(), "void") == 0;
|
||||||
}
|
}
|
||||||
|
bool value::is_string()const {
|
||||||
|
return strcmp(gh(holder)->type(), "string") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
value::object::const_iterator value::find( const char* key )const {
|
value::object::const_iterator value::find( const char* key )const {
|
||||||
|
|
@ -302,7 +306,7 @@ value::object::const_iterator value::find( const char* key )const {
|
||||||
}
|
}
|
||||||
return o->val.fields.end();
|
return o->val.fields.end();
|
||||||
}
|
}
|
||||||
FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
//FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
||||||
return value::object::const_iterator();
|
return value::object::const_iterator();
|
||||||
}
|
}
|
||||||
value::object::const_iterator value::begin()const {
|
value::object::const_iterator value::begin()const {
|
||||||
|
|
@ -310,7 +314,7 @@ value::object::const_iterator value::begin()const {
|
||||||
const detail::value_holder_impl<value::object>* o = static_cast<const detail::value_holder_impl<value::object>*>(gh(holder));
|
const detail::value_holder_impl<value::object>* o = static_cast<const detail::value_holder_impl<value::object>*>(gh(holder));
|
||||||
return o->val.fields.begin();
|
return o->val.fields.begin();
|
||||||
}
|
}
|
||||||
FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
//// FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
||||||
return value::object::const_iterator();
|
return value::object::const_iterator();
|
||||||
//return nullptr;
|
//return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -319,7 +323,7 @@ value::object::const_iterator value::end()const {
|
||||||
const detail::value_holder_impl<value::object>* o = static_cast<const detail::value_holder_impl<value::object>*>(gh(holder));
|
const detail::value_holder_impl<value::object>* o = static_cast<const detail::value_holder_impl<value::object>*>(gh(holder));
|
||||||
return o->val.fields.end();
|
return o->val.fields.end();
|
||||||
}
|
}
|
||||||
FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
////FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
||||||
return value::object::const_iterator();
|
return value::object::const_iterator();
|
||||||
//return nullptr;
|
//return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -338,7 +342,7 @@ value& value::operator[]( const char* key ) {
|
||||||
new (gh(holder)) detail::value_holder_impl<value::object>(value::object());
|
new (gh(holder)) detail::value_holder_impl<value::object>(value::object());
|
||||||
return (*this)[key];
|
return (*this)[key];
|
||||||
}
|
}
|
||||||
FC_THROW_MSG( "Bad cast of %s to object", gh(holder)->type() );
|
FC_THROW_REPORT( "Bad cast of ${type} to object", fc::value().set("type",gh(holder)->type()) );
|
||||||
return *((value*)0);
|
return *((value*)0);
|
||||||
}
|
}
|
||||||
value& value::operator[]( const fc::string& key ) { return (*this)[key.c_str()]; }
|
value& value::operator[]( const fc::string& key ) { return (*this)[key.c_str()]; }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue