@@ -314,9 +314,9 @@ static std::map<std::string,std::string> ParseTorReplyMapping(const std::string
314
314
* @param maxsize Puts a maximum size limit on the file that is read. If the file is larger than this, truncated data
315
315
* (with len > maxsize) will be returned.
316
316
*/
317
- static std::pair<bool ,std::string> ReadBinaryFile (const std::string &filename, size_t maxsize=std::numeric_limits<size_t >::max())
317
+ static std::pair<bool ,std::string> ReadBinaryFile (const fs::path &filename, size_t maxsize=std::numeric_limits<size_t >::max())
318
318
{
319
- FILE *f = fopen (filename. c_str () , " rb" );
319
+ FILE *f = fsbridge:: fopen (filename, " rb" );
320
320
if (f == NULL )
321
321
return std::make_pair (false ," " );
322
322
std::string retval;
@@ -334,9 +334,9 @@ static std::pair<bool,std::string> ReadBinaryFile(const std::string &filename, s
334
334
/* * Write contents of std::string to a file.
335
335
* @return true on success.
336
336
*/
337
- static bool WriteBinaryFile (const std::string &filename, const std::string &data)
337
+ static bool WriteBinaryFile (const fs::path &filename, const std::string &data)
338
338
{
339
- FILE *f = fopen (filename. c_str () , " wb" );
339
+ FILE *f = fsbridge:: fopen (filename, " wb" );
340
340
if (f == NULL )
341
341
return false ;
342
342
if (fwrite (data.data (), 1 , data.size (), f) != data.size ()) {
@@ -359,7 +359,7 @@ class TorController
359
359
~TorController ();
360
360
361
361
/* * Get name fo file to store private key in */
362
- std::string GetPrivateKeyFile ();
362
+ fs::path GetPrivateKeyFile ();
363
363
364
364
/* * Reconnect, after getting disconnected */
365
365
void Reconnect ();
@@ -411,7 +411,7 @@ TorController::TorController(struct event_base* _base, const std::string& _targe
411
411
// Read service private key if cached
412
412
std::pair<bool ,std::string> pkf = ReadBinaryFile (GetPrivateKeyFile ());
413
413
if (pkf.first ) {
414
- LogPrint (BCLog::TOR, " tor: Reading cached private key from %s\n " , GetPrivateKeyFile ());
414
+ LogPrint (BCLog::TOR, " tor: Reading cached private key from %s\n " , GetPrivateKeyFile (). string () );
415
415
private_key = pkf.second ;
416
416
}
417
417
}
@@ -442,9 +442,9 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe
442
442
service = LookupNumeric (std::string (service_id+" .onion" ).c_str (), GetListenPort ());
443
443
LogPrintf (" tor: Got service ID %s, advertising service %s\n " , service_id, service.ToString ());
444
444
if (WriteBinaryFile (GetPrivateKeyFile (), private_key)) {
445
- LogPrint (BCLog::TOR, " tor: Cached service private key to %s\n " , GetPrivateKeyFile ());
445
+ LogPrint (BCLog::TOR, " tor: Cached service private key to %s\n " , GetPrivateKeyFile (). string () );
446
446
} else {
447
- LogPrintf (" tor: Error writing service private key to %s\n " , GetPrivateKeyFile ());
447
+ LogPrintf (" tor: Error writing service private key to %s\n " , GetPrivateKeyFile (). string () );
448
448
}
449
449
AddLocal (service, LOCAL_MANUAL);
450
450
// ... onion requested - keep connection open
@@ -651,9 +651,9 @@ void TorController::Reconnect()
651
651
}
652
652
}
653
653
654
- std::string TorController::GetPrivateKeyFile ()
654
+ fs::path TorController::GetPrivateKeyFile ()
655
655
{
656
- return ( GetDataDir () / " onion_private_key" ). string () ;
656
+ return GetDataDir () / " onion_private_key" ;
657
657
}
658
658
659
659
void TorController::reconnect_cb (evutil_socket_t fd, short what, void *arg)
0 commit comments