@ -10,6 +10,7 @@
@@ -10,6 +10,7 @@
# include "util.h"
# include "chainparamsbase.h"
# include "fs.h"
# include "random.h"
# include "serialize.h"
# include "sync.h"
@ -79,8 +80,6 @@
@@ -79,8 +80,6 @@
# include <boost/algorithm/string/case_conv.hpp> // for to_lower()
# include <boost/algorithm/string/join.hpp>
# include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
# include <boost/filesystem.hpp>
# include <boost/filesystem/fstream.hpp>
# include <boost/foreach.hpp>
# include <boost/program_options/detail/config_file.hpp>
# include <boost/program_options/parsers.hpp>
@ -215,8 +214,8 @@ void OpenDebugLog()
@@ -215,8 +214,8 @@ void OpenDebugLog()
assert ( fileout = = NULL ) ;
assert ( vMsgsBeforeOpenLog ) ;
boost : : file system : : path pathDebug = GetDataDir ( ) / " debug.log " ;
fileout = fopen ( pathDebug . string ( ) . c_str ( ) , " a " ) ;
fs : : path pathDebug = GetDataDir ( ) / " debug.log " ;
fileout = fsbridge : : fopen ( pathDebug , " a " ) ;
if ( fileout ) {
setbuf ( fileout , NULL ) ; // unbuffered
// dump buffered messages from before we opened the log
@ -354,8 +353,8 @@ int LogPrintStr(const std::string &str)
@@ -354,8 +353,8 @@ int LogPrintStr(const std::string &str)
// reopen the log file, if requested
if ( fReopenDebugLog ) {
fReopenDebugLog = false ;
boost : : file system : : path pathDebug = GetDataDir ( ) / " debug.log " ;
if ( freopen ( pathDebug . string ( ) . c_str ( ) , " a " , fileout ) ! = NULL )
fs : : path pathDebug = GetDataDir ( ) / " debug.log " ;
if ( fsbridge : : freopen ( pathDebug , " a " , fileout ) ! = NULL )
setbuf ( fileout , NULL ) ; // unbuffered
}
@ -512,9 +511,8 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
@@ -512,9 +511,8 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
fprintf ( stderr , " \n \n ************************ \n %s \n " , message . c_str ( ) ) ;
}
boost : : file system : : path GetDefaultDataDir ( )
fs : : path GetDefaultDataDir ( )
{
namespace fs = boost : : filesystem ;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Bitcoin
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Bitcoin
// Mac: ~/Library/Application Support/Bitcoin
@ -539,13 +537,12 @@ boost::filesystem::path GetDefaultDataDir()
@@ -539,13 +537,12 @@ boost::filesystem::path GetDefaultDataDir()
# endif
}
static boost : : file system : : path pathCached ;
static boost : : file system : : path pathCachedNetSpecific ;
static fs : : path pathCached ;
static fs : : path pathCachedNetSpecific ;
static CCriticalSection csPathCached ;
const boost : : file system : : path & GetDataDir ( bool fNetSpecific )
const fs : : path & GetDataDir ( bool fNetSpecific )
{
namespace fs = boost : : filesystem ;
LOCK ( csPathCached ) ;
@ -577,13 +574,13 @@ void ClearDatadirCache()
@@ -577,13 +574,13 @@ void ClearDatadirCache()
{
LOCK ( csPathCached ) ;
pathCached = boost : : file system : : path ( ) ;
pathCachedNetSpecific = boost : : file system : : path ( ) ;
pathCached = fs : : path ( ) ;
pathCachedNetSpecific = fs : : path ( ) ;
}
boost : : file system : : path GetConfigFile ( const std : : string & confPath )
fs : : path GetConfigFile ( const std : : string & confPath )
{
boost : : file system : : path pathConfigFile ( confPath ) ;
fs : : path pathConfigFile ( confPath ) ;
if ( ! pathConfigFile . is_complete ( ) )
pathConfigFile = GetDataDir ( false ) / pathConfigFile ;
@ -592,7 +589,7 @@ boost::filesystem::path GetConfigFile(const std::string& confPath)
@@ -592,7 +589,7 @@ boost::filesystem::path GetConfigFile(const std::string& confPath)
void ReadConfigFile ( const std : : string & confPath )
{
boost : : file system : : ifstream streamConfig ( GetConfigFile ( confPath ) ) ;
fs : : ifstream streamConfig ( GetConfigFile ( confPath ) ) ;
if ( ! streamConfig . good ( ) )
return ; // No bitcoin.conf file is OK
@ -617,16 +614,16 @@ void ReadConfigFile(const std::string& confPath)
@@ -617,16 +614,16 @@ void ReadConfigFile(const std::string& confPath)
}
# ifndef WIN32
boost : : file system : : path GetPidFile ( )
fs : : path GetPidFile ( )
{
boost : : file system : : path pathPidFile ( GetArg ( " -pid " , BITCOIN_PID_FILENAME ) ) ;
fs : : path pathPidFile ( GetArg ( " -pid " , BITCOIN_PID_FILENAME ) ) ;
if ( ! pathPidFile . is_complete ( ) ) pathPidFile = GetDataDir ( ) / pathPidFile ;
return pathPidFile ;
}
void CreatePidFile ( const boost : : file system : : path & path , pid_t pid )
void CreatePidFile ( const fs : : path & path , pid_t pid )
{
FILE * file = fopen ( path . string ( ) . c_str ( ) , " w " ) ;
FILE * file = fsbridge : : fopen ( path , " w " ) ;
if ( file )
{
fprintf ( file , " %d \n " , pid ) ;
@ -635,7 +632,7 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
@@ -635,7 +632,7 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
}
# endif
bool RenameOver ( boost : : file system : : path src , boost : : file system : : path dest )
bool RenameOver ( fs : : path src , fs : : path dest )
{
# ifdef WIN32
return MoveFileExA ( src . string ( ) . c_str ( ) , dest . string ( ) . c_str ( ) ,
@ -651,13 +648,13 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
@@ -651,13 +648,13 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
* Specifically handles case where path p exists , but it wasn ' t possible for the user to
* write to the parent directory .
*/
bool TryCreateDirectory ( const boost : : file system : : path & p )
bool TryCreateDirectory ( const fs : : path & p )
{
try
{
return boost : : file system : : create_directory ( p ) ;
} catch ( const boost : : file system : : filesystem_error & ) {
if ( ! boost : : file system : : exists ( p ) | | ! boost : : file system : : is_directory ( p ) )
return fs : : create_directory ( p ) ;
} catch ( const fs : : filesystem_error & ) {
if ( ! fs : : exists ( p ) | | ! fs : : is_directory ( p ) )
throw ;
}
@ -764,11 +761,11 @@ void ShrinkDebugFile()
@@ -764,11 +761,11 @@ void ShrinkDebugFile()
// Amount of debug.log to save at end when shrinking (must fit in memory)
constexpr size_t RECENT_DEBUG_HISTORY_SIZE = 10 * 1000000 ;
// Scroll debug.log if it's getting too big
boost : : file system : : path pathLog = GetDataDir ( ) / " debug.log " ;
FILE * file = fopen ( pathLog . string ( ) . c_str ( ) , " r " ) ;
fs : : path pathLog = GetDataDir ( ) / " debug.log " ;
FILE * file = fsbridge : : fopen ( pathLog , " r " ) ;
// If debug.log file is more than 10% bigger the RECENT_DEBUG_HISTORY_SIZE
// trim it down by saving only the last RECENT_DEBUG_HISTORY_SIZE bytes
if ( file & & boost : : file system : : file_size ( pathLog ) > 11 * ( RECENT_DEBUG_HISTORY_SIZE / 10 ) )
if ( file & & fs : : file_size ( pathLog ) > 11 * ( RECENT_DEBUG_HISTORY_SIZE / 10 ) )
{
// Restart the file with some of the end
std : : vector < char > vch ( RECENT_DEBUG_HISTORY_SIZE , 0 ) ;
@ -776,7 +773,7 @@ void ShrinkDebugFile()
@@ -776,7 +773,7 @@ void ShrinkDebugFile()
int nBytes = fread ( vch . data ( ) , 1 , vch . size ( ) , file ) ;
fclose ( file ) ;
file = fopen ( pathLog . string ( ) . c_str ( ) , " w " ) ;
file = fsbridge : : fopen ( pathLog , " w " ) ;
if ( file )
{
fwrite ( vch . data ( ) , 1 , nBytes , file ) ;
@ -788,10 +785,8 @@ void ShrinkDebugFile()
@@ -788,10 +785,8 @@ void ShrinkDebugFile()
}
# ifdef WIN32
boost : : file system : : path GetSpecialFolderPath ( int nFolder , bool fCreate )
fs : : path GetSpecialFolderPath ( int nFolder , bool fCreate )
{
namespace fs = boost : : filesystem ;
char pszPath [ MAX_PATH ] = " " ;
if ( SHGetSpecialFolderPathA ( NULL , pszPath , nFolder , fCreate ) )
@ -851,9 +846,9 @@ void SetupEnvironment()
@@ -851,9 +846,9 @@ void SetupEnvironment()
// The path locale is lazy initialized and to avoid deinitialization errors
// in multithreading environments, it is set explicitly by the main thread.
// A dummy locale is used to extract the internal default locale, used by
// boost:: file system ::path, which is then used to explicitly imbue the path.
std : : locale loc = boost : : file system : : path : : imbue ( std : : locale : : classic ( ) ) ;
boost : : file system : : path : : imbue ( loc ) ;
// fs::path, which is then used to explicitly imbue the path.
std : : locale loc = fs : : path : : imbue ( std : : locale : : classic ( ) ) ;
fs : : path : : imbue ( loc ) ;
}
bool SetupNetworking ( )