Adding udp multicast support, filesystem::rename
This commit is contained in:
parent
f765440760
commit
5499d5bb30
4 changed files with 31 additions and 4 deletions
|
|
@ -108,6 +108,7 @@ namespace fc {
|
||||||
uint64_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 rename( 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 );
|
||||||
|
|
||||||
path unique_path();
|
path unique_path();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef _FC_UDP_SOCKET_HPP_
|
#pragma once
|
||||||
#define _FC_UDP_SOCKET_HPP_
|
|
||||||
#include <fc/utility.hpp>
|
#include <fc/utility.hpp>
|
||||||
#include <fc/shared_ptr.hpp>
|
#include <fc/shared_ptr.hpp>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
namespace ip {
|
namespace ip {
|
||||||
class endpoint;
|
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 );
|
size_t send_to( const char* b, size_t l, const fc::ip::endpoint& to );
|
||||||
void close();
|
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 );
|
void connect( const fc::ip::endpoint& e );
|
||||||
fc::ip::endpoint local_endpoint()const;
|
fc::ip::endpoint local_endpoint()const;
|
||||||
|
|
||||||
|
|
@ -34,5 +38,3 @@ namespace fc {
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,17 @@ namespace fc {
|
||||||
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); }
|
||||||
uint64_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 remove_all( const path& p ) { boost::filesystem::remove_all(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 ) {
|
void copy( const path& f, const path& t ) {
|
||||||
try {
|
try {
|
||||||
boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) );
|
boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) );
|
||||||
|
|
|
||||||
|
|
@ -91,4 +91,17 @@ namespace fc {
|
||||||
my->_sock.connect( to_asio_ep(e) );
|
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) ) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue