This commit is contained in:
Daniel Larimer 2012-12-29 12:00:19 -05:00
parent e79d30ea3f
commit 682c005350
8 changed files with 36 additions and 8 deletions

View file

@ -97,8 +97,8 @@ add_subdirectory(vendor) #/libssh2-1.4.2)
setup_library( fc SOURCES ${sources} )
setup_executable( json_rpc_test SOURCES tests/json_rpc_test.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ${Boost_DATE_TIME_LIBRARY})
setup_executable( ssh_test SOURCES tests/ssh.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ssh2 ${OPENSSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${ZLIB_LIBRARY} ${ALL_OPENSSL_LIBRARIES} ${Boost_DATE_TIME_LIBRARY})
#setup_executable( json_rpc_test SOURCES tests/json_rpc_test.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ${Boost_DATE_TIME_LIBRARY})
#setup_executable( ssh_test SOURCES tests/ssh.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ssh2 ${OPENSSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${ZLIB_LIBRARY} ${ALL_OPENSSL_LIBRARIES} ${Boost_DATE_TIME_LIBRARY})
#add_executable( test_vec tests/vector_test.cpp )
#target_link_libraries( test_vec fc ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} )

View file

@ -21,7 +21,7 @@ struct datastream {
inline void skip( size_t s ){ m_pos += s; }
inline bool read( char* d, size_t s ) {
if( m_end - m_pos >= (size_t)s ) {
if( size_t(m_end - m_pos) >= (size_t)s ) {
memcpy( d, m_pos, s );
m_pos += s;
return true;

View file

@ -39,6 +39,8 @@ namespace fc {
fc::path parent_path()const;
fc::string string()const;
fc::string generic_string()const;
bool is_relative()const;
bool is_absolute()const;
private:
fwd<boost::filesystem::path,32> _p;
};

View file

@ -35,7 +35,6 @@ namespace fc {
friend bool operator==( const endpoint& a, const endpoint& b );
private:
address _ip;
/**
* The compiler pads endpoint to a full 8 bytes, so while
* a port number is limited in range to 16 bits, we specify
@ -44,6 +43,7 @@ namespace fc {
* where they are stored.
*/
uint32_t _port;
address _ip;
};
}
class value;

View file

@ -9,6 +9,8 @@ namespace fc {
class path;
template<typename> class vector;
fc::path find_executable_in_path( const fc::string name );
/**
* @brief start and manage an external process
*
@ -23,6 +25,7 @@ namespace fc {
open_stderr = 0x04,
open_all = open_stdin|open_stdout|open_stderr,
};
/**
* Return a new process executing the specified exe with the specified args.
*/

View file

@ -139,7 +139,7 @@ fc::string error_report::to_string()const {
}
fc::string error_report::to_detail_string()const {
fc::stringstream ss;
for( int i = 0; i < stack.size(); ++i ) {
for( uint32_t i = 0; i < stack.size(); ++i ) {
ss << stack[i].to_detail_string() << "\n";
}
return ss.str();

View file

@ -81,6 +81,8 @@ namespace fc {
fc::path path::parent_path()const {
return _p->parent_path();
}
bool path::is_relative()const { return _p->is_relative(); }
bool path::is_absolute()const { return _p->is_absolute(); }
directory_iterator::directory_iterator( const fc::path& p )
:_p(p){}
@ -119,7 +121,13 @@ namespace fc {
bool exists( const path& p ) { return boost::filesystem::exists(p); }
void create_directories( const path& p ) { boost::filesystem::create_directories(p); }
void create_directories( const path& p ) {
try {
boost::filesystem::create_directories(p);
} catch ( ... ) {
FC_THROW_REPORT( "Unable to create directories ${path}", fc::value().set("path", p ).set("inner", fc::except_str() ) );
}
}
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); }
uint64_t file_size( const path& p ) { return boost::filesystem::file_size(p); }

View file

@ -4,14 +4,29 @@
#include <fc/asio.hpp>
#include <fc/filesystem.hpp>
#include <fc/vector.hpp>
#include <boost/process.hpp>
#include <fc/error_report.hpp>
#include <fc/value.hpp>
#include <boost/process/all.hpp>
#include <boost/iostreams/stream.hpp>
#include <cstdlib>
namespace fc {
namespace bp = boost::process;
namespace io = boost::iostreams;
fc::path find_executable_in_path( const fc::string name ) {
try {
return fc::string(bp::find_executable_in_path( std::string(name), "" ));
} catch (...) {
const char* p = std::getenv("PATH");
FC_THROW_REPORT( "Unable to find executable ${exe} in path.",
fc::value().set("exe", name)
.set("inner", fc::except_str() )
.set("PATH", fc::string(p!=nullptr?p:"") ) );
}
return fc::path();
}
class process_sink : public io::sink {
public:
struct category : io::sink::category, io::flushable_tag {};