Adding udp multicast support, filesystem::rename

This commit is contained in:
Daniel Larimer 2013-03-24 00:11:28 -04:00
parent f765440760
commit 5499d5bb30
4 changed files with 31 additions and 4 deletions

View file

@ -108,6 +108,7 @@ namespace fc {
uint64_t file_size( const path& p );
bool remove( const path& p );
void copy( const path& from, const path& to );
void rename( const path& from, const path& to );
void create_hard_link( const path& from, const path& to );
path unique_path();

View file

@ -1,11 +1,11 @@
#ifndef _FC_UDP_SOCKET_HPP_
#define _FC_UDP_SOCKET_HPP_
#pragma once
#include <fc/utility.hpp>
#include <fc/shared_ptr.hpp>
namespace fc {
namespace ip {
class endpoint;
class address;
}
/**
@ -25,6 +25,10 @@ namespace fc {
size_t send_to( const char* b, size_t l, const fc::ip::endpoint& to );
void close();
void set_multicast_enable_loopback( bool );
void set_reuse_address( bool );
void join_multicast_group( const fc::ip::address& a );
void connect( const fc::ip::endpoint& e );
fc::ip::endpoint local_endpoint()const;
@ -34,5 +38,3 @@ namespace fc {
};
}
#endif

View file

@ -147,6 +147,17 @@ namespace fc {
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); }
void remove_all( const path& p ) { boost::filesystem::remove_all(p); }
void rename( const path& f, const path& t ) {
try {
boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) );
} catch ( boost::system::system_error& e ) {
FC_THROW_REPORT( "Rename from ${srcfile} to ${dstfile} failed because ${reason}",
fc::value().set("srcfile",f).set("dstfile",t).set("reason",e.what() ) );
} catch ( ... ) {
FC_THROW_REPORT( "Rename from ${srcfile} to ${dstfile} failed",
fc::value().set("srcfile",f).set("dstfile",t).set("inner", fc::except_str() ) );
}
}
void copy( const path& f, const path& t ) {
try {
boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) );

View file

@ -91,4 +91,17 @@ namespace fc {
my->_sock.connect( to_asio_ep(e) );
}
void udp_socket::set_multicast_enable_loopback( bool s )
{
my->_sock.set_option( boost::asio::ip::multicast::enable_loopback(s) );
}
void udp_socket::set_reuse_address( bool s )
{
my->_sock.set_option( boost::asio::ip::udp::socket::reuse_address(s) );
}
void udp_socket::join_multicast_group( const fc::ip::address& a )
{
my->_sock.set_option( boost::asio::ip::multicast::join_group( boost::asio::ip::address_v4(a) ) );
}
}