mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-12 21:19:08 +01:00
Core/Util: Extracted GetPID to separate function
(cherry picked from commit e3af42e05c)
This commit is contained in:
@@ -218,22 +218,29 @@ bool IsIPAddress(char const* ipaddress)
|
||||
}
|
||||
|
||||
/// create PID file
|
||||
uint32 CreatePIDFile(const std::string& filename)
|
||||
uint32 CreatePIDFile(std::string const& filename)
|
||||
{
|
||||
FILE* pid_file = fopen (filename.c_str(), "w" );
|
||||
FILE* pid_file = fopen(filename.c_str(), "w");
|
||||
if (pid_file == NULL)
|
||||
return 0;
|
||||
|
||||
uint32 pid = GetPID();
|
||||
|
||||
fprintf(pid_file, "%u", pid);
|
||||
fclose(pid_file);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
uint32 GetPID()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD pid = GetCurrentProcessId();
|
||||
#else
|
||||
pid_t pid = getpid();
|
||||
#endif
|
||||
|
||||
fprintf(pid_file, "%u", pid );
|
||||
fclose(pid_file);
|
||||
|
||||
return (uint32)pid;
|
||||
return uint32(pid);
|
||||
}
|
||||
|
||||
size_t utf8length(std::string& utf8str)
|
||||
|
||||
@@ -314,7 +314,8 @@ bool Utf8ToUpperOnlyLatin(std::string& utf8String);
|
||||
|
||||
bool IsIPAddress(char const* ipaddress);
|
||||
|
||||
uint32 CreatePIDFile(const std::string& filename);
|
||||
uint32 CreatePIDFile(std::string const& filename);
|
||||
uint32 GetPID();
|
||||
|
||||
std::string ByteArrayToHexStr(uint8 const* bytes, uint32 length, bool reverse = false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user