small fixes

This commit is contained in:
sjn 2022-02-03 14:39:47 -08:00
parent a906f48b04
commit 53e7950962
2 changed files with 20 additions and 3 deletions

View File

@ -1113,6 +1113,7 @@ boost::filesystem::path GetPidFile()
return pathPidFile;
}
#ifdef WIN32
void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid)
{
FILE* file = fopen(path.string().c_str(), "w");
@ -1122,6 +1123,17 @@ void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid)
fclose(file);
}
}
#else
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
{
FILE* file = fopen(path.string().c_str(), "w");
if (file)
{
fprintf(file, "%d\n", pid);
fclose(file);
}
}
#endif
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{

View File

@ -7,6 +7,10 @@
#include "uint256.h"
#include <map>
#include <vector>
#include <string>
#ifndef WIN32
#include <sys/types.h>
#include <sys/time.h>
@ -15,9 +19,6 @@
#include <processthreadsapi.h>
typedef int util_pid_t; /* define for Windows compatibility */
#endif
#include <map>
#include <vector>
#include <string>
#include <boost/thread.hpp>
#include <boost/filesystem.hpp>
@ -217,7 +218,11 @@ boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
boost::filesystem::path GetConfigFile();
boost::filesystem::path GetPidFile();
#ifdef WIN32
void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid);
#else
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);