Common: Code clean up of common
This commit is contained in:
parent
82d9027374
commit
92054583d4
|
@ -19,7 +19,8 @@ private:
|
||||||
class CGuard
|
class CGuard
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CGuard(CriticalSection& sectionName) : m_cs(sectionName)
|
CGuard(CriticalSection & sectionName) :
|
||||||
|
m_cs(sectionName)
|
||||||
{
|
{
|
||||||
m_cs.enter();
|
m_cs.enter();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +28,7 @@ public:
|
||||||
{
|
{
|
||||||
m_cs.leave();
|
m_cs.leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CriticalSection & m_cs;
|
CriticalSection & m_cs;
|
||||||
CGuard(const CGuard & copy);
|
CGuard(const CGuard & copy);
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DynLibHandle DynamicLibraryOpen(const char * pccLibraryPath, bool ShowErrors)
|
DynLibHandle DynamicLibraryOpen(const char * pccLibraryPath, bool ShowErrors)
|
||||||
|
@ -48,4 +48,3 @@ void * DynamicLibraryGetProc(DynLibHandle Lib, const char * ProcedureName)
|
||||||
return dlsym(Lib, ProcedureName);
|
return dlsym(Lib, ProcedureName);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,9 +95,18 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags)
|
||||||
ULONG dwShareMode = 0;
|
ULONG dwShareMode = 0;
|
||||||
|
|
||||||
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||||
if ((nOpenFlags & shareDenyWrite) == shareDenyWrite) { dwShareMode &= ~FILE_SHARE_WRITE; }
|
if ((nOpenFlags & shareDenyWrite) == shareDenyWrite)
|
||||||
if ((nOpenFlags & shareDenyRead) == shareDenyRead) { dwShareMode &= ~FILE_SHARE_READ; }
|
{
|
||||||
if ((nOpenFlags & shareExclusive) == shareExclusive) { dwShareMode = 0; }
|
dwShareMode &= ~FILE_SHARE_WRITE;
|
||||||
|
}
|
||||||
|
if ((nOpenFlags & shareDenyRead) == shareDenyRead)
|
||||||
|
{
|
||||||
|
dwShareMode &= ~FILE_SHARE_READ;
|
||||||
|
}
|
||||||
|
if ((nOpenFlags & shareExclusive) == shareExclusive)
|
||||||
|
{
|
||||||
|
dwShareMode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Map modeNoInherit flag
|
// Map modeNoInherit flag
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "HighResTimeStamp.h"
|
#include "HighResTimeStamp.h"
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "StdString.h"
|
#include "StdString.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
CIniFileBase::CIniFileBase(CFileBase & FileObject, const char * FileName) :
|
CIniFileBase::CIniFileBase(CFileBase & FileObject, const char * FileName) :
|
||||||
m_lastSectionSearch(0),
|
m_lastSectionSearch(0),
|
||||||
|
@ -23,7 +23,10 @@ CIniFileBase::~CIniFileBase(void)
|
||||||
|
|
||||||
void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces)
|
void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces)
|
||||||
{
|
{
|
||||||
enum { fIS_MvSize = 0x2000 };
|
enum
|
||||||
|
{
|
||||||
|
fIS_MvSize = 0x2000
|
||||||
|
};
|
||||||
|
|
||||||
unsigned char Data[fIS_MvSize + 1];
|
unsigned char Data[fIS_MvSize + 1];
|
||||||
int SizeToRead, result;
|
int SizeToRead, result;
|
||||||
|
@ -39,7 +42,10 @@ void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
SizeToRead = end - Pos;
|
SizeToRead = end - Pos;
|
||||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
if (SizeToRead > fIS_MvSize)
|
||||||
|
{
|
||||||
|
SizeToRead = fIS_MvSize;
|
||||||
|
}
|
||||||
if (SizeToRead > 0)
|
if (SizeToRead > 0)
|
||||||
{
|
{
|
||||||
m_File.Seek(SizeToRead * -1, CFileBase::current);
|
m_File.Seek(SizeToRead * -1, CFileBase::current);
|
||||||
|
@ -63,7 +69,10 @@ void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
SizeToRead = end - ReadPos;
|
SizeToRead = end - ReadPos;
|
||||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
if (SizeToRead > fIS_MvSize)
|
||||||
|
{
|
||||||
|
SizeToRead = fIS_MvSize;
|
||||||
|
}
|
||||||
m_File.Seek(ReadPos, CFileBase::begin);
|
m_File.Seek(ReadPos, CFileBase::begin);
|
||||||
m_File.Read(Data, SizeToRead);
|
m_File.Read(Data, SizeToRead);
|
||||||
m_File.Seek(WritePos, CFileBase::begin);
|
m_File.Seek(WritePos, CFileBase::begin);
|
||||||
|
@ -84,7 +93,10 @@ void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces)
|
||||||
|
|
||||||
int CIniFileBase::GetStringFromFile(char *& String, std::unique_ptr<char> & Data, int & MaxDataSize, int & DataSize, int & ReadPos)
|
int CIniFileBase::GetStringFromFile(char *& String, std::unique_ptr<char> & Data, int & MaxDataSize, int & DataSize, int & ReadPos)
|
||||||
{
|
{
|
||||||
enum { BufferIncrease = 0x2000 };
|
enum
|
||||||
|
{
|
||||||
|
BufferIncrease = 0x2000
|
||||||
|
};
|
||||||
if (MaxDataSize == 0)
|
if (MaxDataSize == 0)
|
||||||
{
|
{
|
||||||
ReadPos = 0;
|
ReadPos = 0;
|
||||||
|
@ -217,7 +229,10 @@ void CIniFileBase::SaveCurrentSection(void)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||||
if (result <= 1) { continue; }
|
if (result <= 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (strlen(CleanLine(Input)) <= 1 || Input[0] != '[')
|
if (strlen(CleanLine(Input)) <= 1 || Input[0] != '[')
|
||||||
{
|
{
|
||||||
EndPos = (long)((m_File.GetPosition() - DataSize) + ReadPos);
|
EndPos = (long)((m_File.GetPosition() - DataSize) + ReadPos);
|
||||||
|
@ -326,8 +341,14 @@ bool CIniFileBase::MoveToSectionNameData(const char * lpSectionName, bool Change
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||||
if (result <= 1) { continue; }
|
if (result <= 1)
|
||||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strlen(CleanLine(Input)) <= 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// We only care about sections
|
// We only care about sections
|
||||||
char * CurrentSection = Input;
|
char * CurrentSection = Input;
|
||||||
|
@ -337,9 +358,15 @@ bool CIniFileBase::MoveToSectionNameData(const char * lpSectionName, bool Change
|
||||||
CurrentSection += 3;
|
CurrentSection += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentSection[0] != '[') { continue; }
|
if (CurrentSection[0] != '[')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int lineEndPos = (int)strlen(CurrentSection) - 1;
|
int lineEndPos = (int)strlen(CurrentSection) - 1;
|
||||||
if (CurrentSection[lineEndPos] != ']') { continue; }
|
if (CurrentSection[lineEndPos] != ']')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Take off the ']' from the end of the string
|
// Take off the ']' from the end of the string
|
||||||
CurrentSection[lineEndPos] = 0;
|
CurrentSection[lineEndPos] = 0;
|
||||||
CurrentSection += 1;
|
CurrentSection += 1;
|
||||||
|
@ -383,11 +410,23 @@ bool CIniFileBase::MoveToSectionNameData(const char * lpSectionName, bool Change
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||||
if (result <= 1) { continue; }
|
if (result <= 1)
|
||||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
{
|
||||||
if (Input[0] == '[') { break; }
|
continue;
|
||||||
|
}
|
||||||
|
if (strlen(CleanLine(Input)) <= 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Input[0] == '[')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
char * Pos = strchr(Input, '=');
|
char * Pos = strchr(Input, '=');
|
||||||
if (Pos == nullptr) { continue; }
|
if (Pos == nullptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
char * Value = &Pos[1];
|
char * Value = &Pos[1];
|
||||||
|
|
||||||
char * Pos1 = Pos - 1;
|
char * Pos1 = Pos - 1;
|
||||||
|
@ -442,7 +481,10 @@ const char * CIniFileBase::CleanLine(char * Line)
|
||||||
// Strip any spaces or line feeds from the end of the line
|
// Strip any spaces or line feeds from the end of the line
|
||||||
for (int count = (int)strlen(&Line[0]) - 1; count >= 0; count--)
|
for (int count = (int)strlen(&Line[0]) - 1; count >= 0; count--)
|
||||||
{
|
{
|
||||||
if (Line[count] != ' ' && Line[count] != '\r') { break; }
|
if (Line[count] != ' ' && Line[count] != '\r')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
Line[count] = 0;
|
Line[count] = 0;
|
||||||
}
|
}
|
||||||
return Line;
|
return Line;
|
||||||
|
@ -502,7 +544,10 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
|
||||||
{
|
{
|
||||||
CGuard Guard(m_CS);
|
CGuard Guard(m_CS);
|
||||||
|
|
||||||
if (!m_File.IsOpen()) { return false; }
|
if (!m_File.IsOpen())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SaveCurrentSection();
|
SaveCurrentSection();
|
||||||
if (!MoveToSectionNameData(lpSectionName, true))
|
if (!MoveToSectionNameData(lpSectionName, true))
|
||||||
|
@ -520,8 +565,14 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||||
if (result <= 1) { continue; }
|
if (result <= 1)
|
||||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strlen(CleanLine(Input)) <= 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (Input[0] != '[')
|
if (Input[0] != '[')
|
||||||
{
|
{
|
||||||
|
@ -540,13 +591,19 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
|
||||||
long ReadPos = NextSectionStart;
|
long ReadPos = NextSectionStart;
|
||||||
long WritePos = DeleteSectionStart;
|
long WritePos = DeleteSectionStart;
|
||||||
|
|
||||||
enum { fIS_MvSize = 0x2000 };
|
enum
|
||||||
|
{
|
||||||
|
fIS_MvSize = 0x2000
|
||||||
|
};
|
||||||
unsigned char Data[fIS_MvSize + 1];
|
unsigned char Data[fIS_MvSize + 1];
|
||||||
int SizeToRead;
|
int SizeToRead;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
SizeToRead = end - ReadPos;
|
SizeToRead = end - ReadPos;
|
||||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
if (SizeToRead > fIS_MvSize)
|
||||||
|
{
|
||||||
|
SizeToRead = fIS_MvSize;
|
||||||
|
}
|
||||||
m_File.Seek(ReadPos, CFileBase::begin);
|
m_File.Seek(ReadPos, CFileBase::begin);
|
||||||
m_File.Read(Data, SizeToRead);
|
m_File.Read(Data, SizeToRead);
|
||||||
m_File.Seek(WritePos, CFileBase::begin);
|
m_File.Seek(WritePos, CFileBase::begin);
|
||||||
|
@ -817,7 +874,10 @@ void CIniFileBase::GetKeyValueData(const char * lpSectionName, KeyValueData & Li
|
||||||
strSection = lpSectionName;
|
strSection = lpSectionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MoveToSectionNameData(strSection.c_str(), false)) { return; }
|
if (!MoveToSectionNameData(strSection.c_str(), false))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int MaxDataSize = 0, DataSize = 0, ReadPos = 0, result;
|
int MaxDataSize = 0, DataSize = 0, ReadPos = 0, result;
|
||||||
std::unique_ptr<char> Data;
|
std::unique_ptr<char> Data;
|
||||||
|
@ -825,11 +885,23 @@ void CIniFileBase::GetKeyValueData(const char * lpSectionName, KeyValueData & Li
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||||
if (result <= 1) { continue; }
|
if (result <= 1)
|
||||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
{
|
||||||
if (Input[0] == '[') { break; }
|
continue;
|
||||||
|
}
|
||||||
|
if (strlen(CleanLine(Input)) <= 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Input[0] == '[')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
char * Pos = strchr(Input, '=');
|
char * Pos = strchr(Input, '=');
|
||||||
if (Pos == nullptr) { continue; }
|
if (Pos == nullptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Pos[0] = 0;
|
Pos[0] = 0;
|
||||||
|
|
||||||
List.insert(KeyValueData::value_type(stdstr(Input).Trim(), &Pos[1]));
|
List.insert(KeyValueData::value_type(stdstr(Input).Trim(), &Pos[1]));
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Platform.h"
|
|
||||||
#include "File.h"
|
|
||||||
#include "CriticalSection.h"
|
#include "CriticalSection.h"
|
||||||
#include <string>
|
#include "File.h"
|
||||||
#include <map>
|
#include "Platform.h"
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class CIniFileBase
|
class CIniFileBase
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,10 @@ public:
|
||||||
void SetCustomSort(SortData SortFunction);
|
void SetCustomSort(SortData SortFunction);
|
||||||
|
|
||||||
void GetVectorOfSections(SectionList & sections);
|
void GetVectorOfSections(SectionList & sections);
|
||||||
const std::string &GetFileName() { return m_FileName; }
|
const std::string & GetFileName()
|
||||||
|
{
|
||||||
|
return m_FileName;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OpenIniFileReadOnly();
|
void OpenIniFileReadOnly();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "path.h"
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include <stdio.h>
|
#include "path.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
CLog::CLog(void) :
|
CLog::CLog(void) :
|
||||||
m_FlushOnWrite(false),
|
m_FlushOnWrite(false),
|
||||||
|
@ -31,7 +31,10 @@ bool CLog::Open( const char * FileName, LOG_OPEN_MODE mode /* = Log_New */)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t nOpenFlags = CFile::modeReadWrite | CFile::modeCreate;
|
uint32_t nOpenFlags = CFile::modeReadWrite | CFile::modeCreate;
|
||||||
if (mode == Log_Append) { nOpenFlags |= CFile::modeNoTruncate; }
|
if (mode == Log_Append)
|
||||||
|
{
|
||||||
|
nOpenFlags |= CFile::modeNoTruncate;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_hLogFile.Open(File, nOpenFlags))
|
if (!m_hLogFile.Open(File, nOpenFlags))
|
||||||
{
|
{
|
||||||
|
@ -61,7 +64,10 @@ void CLog::LogF(const char * Message, ...)
|
||||||
|
|
||||||
void CLog::LogArgs(const char * Message, va_list & args)
|
void CLog::LogArgs(const char * Message, va_list & args)
|
||||||
{
|
{
|
||||||
if (!m_hLogFile.IsOpen()) { return; }
|
if (!m_hLogFile.IsOpen())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -82,7 +88,10 @@ void CLog::LogArgs(const char * Message, va_list & args )
|
||||||
|
|
||||||
void CLog::Log(const char * Message)
|
void CLog::Log(const char * Message)
|
||||||
{
|
{
|
||||||
if (!m_hLogFile.IsOpen()) { return; }
|
if (!m_hLogFile.IsOpen())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint32_t message_len = (uint32_t)strlen(Message);
|
uint32_t message_len = (uint32_t)strlen(Message);
|
||||||
m_hLogFile.Write(Message, message_len);
|
m_hLogFile.Write(Message, message_len);
|
||||||
if (m_FlushOnWrite)
|
if (m_FlushOnWrite)
|
||||||
|
@ -137,11 +146,17 @@ void CLog::Log( const char * Message )
|
||||||
uint32_t SizeToRead, WritePos = 0;
|
uint32_t SizeToRead, WritePos = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
enum { fIS_MvSize = 0x5000 };
|
enum
|
||||||
|
{
|
||||||
|
fIS_MvSize = 0x5000
|
||||||
|
};
|
||||||
unsigned char Data[fIS_MvSize + 1];
|
unsigned char Data[fIS_MvSize + 1];
|
||||||
|
|
||||||
SizeToRead = end - ReadPos;
|
SizeToRead = end - ReadPos;
|
||||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
if (SizeToRead > fIS_MvSize)
|
||||||
|
{
|
||||||
|
SizeToRead = fIS_MvSize;
|
||||||
|
}
|
||||||
|
|
||||||
m_hLogFile.Seek(ReadPos, CFile::begin);
|
m_hLogFile.Seek(ReadPos, CFile::begin);
|
||||||
|
|
||||||
|
@ -169,7 +184,10 @@ void CLog::Log( const char * Message )
|
||||||
|
|
||||||
bool CLog::Empty(void)
|
bool CLog::Empty(void)
|
||||||
{
|
{
|
||||||
if (!m_hLogFile.IsOpen()) { return true; }
|
if (!m_hLogFile.IsOpen())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (m_hLogFile.GetLength() == 0)
|
if (m_hLogFile.GetLength() == 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,18 +1,25 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "File.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "File.h"
|
|
||||||
|
|
||||||
class CLog
|
class CLog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum LOG_OPEN_MODE
|
enum LOG_OPEN_MODE
|
||||||
{
|
{
|
||||||
Log_New, Log_Append
|
Log_New,
|
||||||
|
Log_Append
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { MB = 1024 * 1024 };
|
enum
|
||||||
enum { MAX_FILE_SIZE = 10 * MB };
|
{
|
||||||
|
MB = 1024 * 1024
|
||||||
|
};
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MAX_FILE_SIZE = 10 * MB
|
||||||
|
};
|
||||||
|
|
||||||
CLog(void);
|
CLog(void);
|
||||||
~CLog(void);
|
~CLog(void);
|
||||||
|
@ -29,11 +36,26 @@ public:
|
||||||
m_MaxFileSize = Size;
|
m_MaxFileSize = Size;
|
||||||
m_FileChangeSize = (uint32_t)(Size * 0.1);
|
m_FileChangeSize = (uint32_t)(Size * 0.1);
|
||||||
}
|
}
|
||||||
inline void SetTruncateFile(bool Truncate) { m_TruncateFileLog = Truncate; }
|
inline void SetTruncateFile(bool Truncate)
|
||||||
inline void SetFlush(bool Always) { m_FlushOnWrite = Always; }
|
{
|
||||||
inline bool IsOpen(void) const { return m_hLogFile.IsOpen(); }
|
m_TruncateFileLog = Truncate;
|
||||||
inline bool Flush(void) { return m_hLogFile.Flush(); }
|
}
|
||||||
inline const std::string & FileName(void) const { return m_FileName; }
|
inline void SetFlush(bool Always)
|
||||||
|
{
|
||||||
|
m_FlushOnWrite = Always;
|
||||||
|
}
|
||||||
|
inline bool IsOpen(void) const
|
||||||
|
{
|
||||||
|
return m_hLogFile.IsOpen();
|
||||||
|
}
|
||||||
|
inline bool Flush(void)
|
||||||
|
{
|
||||||
|
return m_hLogFile.Flush();
|
||||||
|
}
|
||||||
|
inline const std::string & FileName(void) const
|
||||||
|
{
|
||||||
|
return m_FileName;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLog(const CLog &);
|
CLog(const CLog &);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
int _vscprintf(const char * format, va_list pargs)
|
int _vscprintf(const char * format, va_list pargs)
|
||||||
|
@ -22,10 +22,22 @@ int fesetround(int RoundType)
|
||||||
{
|
{
|
||||||
static const unsigned int msRound[4] = {_RC_NEAR, _RC_CHOP, _RC_UP, _RC_DOWN};
|
static const unsigned int msRound[4] = {_RC_NEAR, _RC_CHOP, _RC_UP, _RC_DOWN};
|
||||||
int32_t res = _controlfp(msRound[RoundType], _MCW_RC);
|
int32_t res = _controlfp(msRound[RoundType], _MCW_RC);
|
||||||
if (res == _RC_NEAR) { return FE_TONEAREST; }
|
if (res == _RC_NEAR)
|
||||||
if (res == _RC_CHOP) { return FE_TOWARDZERO; }
|
{
|
||||||
if (res == _RC_UP) { return FE_UPWARD; }
|
return FE_TONEAREST;
|
||||||
if (res == _RC_DOWN) { return FE_DOWNWARD; }
|
}
|
||||||
|
if (res == _RC_CHOP)
|
||||||
|
{
|
||||||
|
return FE_TOWARDZERO;
|
||||||
|
}
|
||||||
|
if (res == _RC_UP)
|
||||||
|
{
|
||||||
|
return FE_UPWARD;
|
||||||
|
}
|
||||||
|
if (res == _RC_DOWN)
|
||||||
|
{
|
||||||
|
return FE_DOWNWARD;
|
||||||
|
}
|
||||||
return FE_TONEAREST;
|
return FE_TONEAREST;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,7 +16,13 @@ int _vscprintf (const char * format, va_list pargs);
|
||||||
|
|
||||||
// FPU rounding code
|
// FPU rounding code
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
typedef enum { FE_TONEAREST = 0, FE_TOWARDZERO, FE_UPWARD, FE_DOWNWARD } eRoundType;
|
typedef enum
|
||||||
|
{
|
||||||
|
FE_TONEAREST = 0,
|
||||||
|
FE_TOWARDZERO,
|
||||||
|
FE_UPWARD,
|
||||||
|
FE_DOWNWARD,
|
||||||
|
} eRoundType;
|
||||||
int fesetround(int RoundType);
|
int fesetround(int RoundType);
|
||||||
#else
|
#else
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "StdString.h"
|
#include "StdString.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include <malloc.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <malloc.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
class stdstr;
|
class stdstr;
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
typedef std::vector<stdstr> strvector;
|
typedef std::vector<stdstr> strvector;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
class SyncEvent
|
class SyncEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { INFINITE_TIMEOUT = 0xFFFFFFFF };
|
enum
|
||||||
|
{
|
||||||
|
INFINITE_TIMEOUT = 0xFFFFFFFF
|
||||||
|
};
|
||||||
|
|
||||||
SyncEvent(bool bManualReset = true);
|
SyncEvent(bool bManualReset = true);
|
||||||
~SyncEvent(void);
|
~SyncEvent(void);
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CThread::CThread(CTHREAD_START_ROUTINE lpStartAddress) :
|
CThread::CThread(CTHREAD_START_ROUTINE lpStartAddress) :
|
||||||
|
|
|
@ -14,7 +14,10 @@ public:
|
||||||
|
|
||||||
bool Start(void * lpThreadParameter);
|
bool Start(void * lpThreadParameter);
|
||||||
|
|
||||||
inline uint32_t ThreadID(void) const { return m_threadID; }
|
inline uint32_t ThreadID(void) const
|
||||||
|
{
|
||||||
|
return m_threadID;
|
||||||
|
}
|
||||||
|
|
||||||
bool isRunning(void) const;
|
bool isRunning(void) const;
|
||||||
void Terminate(void);
|
void Terminate(void);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Trace.h"
|
#include "Trace.h"
|
||||||
#include "StdString.h"
|
|
||||||
#include "CriticalSection.h"
|
#include "CriticalSection.h"
|
||||||
#include "Thread.h"
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include "StdString.h"
|
||||||
|
#include "Thread.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -26,7 +26,10 @@ public:
|
||||||
CTraceLog()
|
CTraceLog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~CTraceLog() { CloseTrace(); }
|
~CTraceLog()
|
||||||
|
{
|
||||||
|
CloseTrace();
|
||||||
|
}
|
||||||
|
|
||||||
void TraceMessage(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message);
|
void TraceMessage(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message);
|
||||||
|
|
||||||
|
@ -142,7 +145,6 @@ void CTraceLog::FlushTrace(void)
|
||||||
{
|
{
|
||||||
m_Modules[i]->FlushTrace();
|
m_Modules[i]->FlushTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTraceLog::TraceMessage(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message)
|
void CTraceLog::TraceMessage(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message)
|
||||||
|
@ -202,7 +204,10 @@ const char * TraceModule(uint32_t module)
|
||||||
CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
|
CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
|
||||||
m_FlushFile(FlushFile)
|
m_FlushFile(FlushFile)
|
||||||
{
|
{
|
||||||
enum { MB = 1024 * 1024 };
|
enum
|
||||||
|
{
|
||||||
|
MB = 1024 * 1024
|
||||||
|
};
|
||||||
|
|
||||||
m_hLogFile.SetFlush(false);
|
m_hLogFile.SetFlush(false);
|
||||||
m_hLogFile.SetTruncateFile(true);
|
m_hLogFile.SetTruncateFile(true);
|
||||||
|
@ -222,7 +227,10 @@ CTraceFileLog::~CTraceFileLog()
|
||||||
|
|
||||||
void CTraceFileLog::Write(uint32_t module, uint8_t severity, const char * /*file*/, int /*line*/, const char * function, const char * Message)
|
void CTraceFileLog::Write(uint32_t module, uint8_t severity, const char * /*file*/, int /*line*/, const char * function, const char * Message)
|
||||||
{
|
{
|
||||||
if (!m_hLogFile.IsOpen()) { return; }
|
if (!m_hLogFile.IsOpen())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SYSTEMTIME sysTime;
|
SYSTEMTIME sysTime;
|
||||||
|
|
|
@ -37,9 +37,17 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WriteTrace(m, s, format, ...) if(g_ModuleLogLevel[(m)] >= (s)) { WriteTraceFull((m), (s), __FILE__, __LINE__, __FUNCTION__, (format), ## __VA_ARGS__); }
|
#define WriteTrace(m, s, format, ...) \
|
||||||
|
if (g_ModuleLogLevel[(m)] >= (s)) \
|
||||||
|
{ \
|
||||||
|
WriteTraceFull((m), (s), __FILE__, __LINE__, __FUNCTION__, (format), ##__VA_ARGS__); \
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define WriteTrace(m, s, format, ...) if(g_ModuleLogLevel[(m)] >= (s)) { WriteTraceFull((m), (s), __FILE__, __LINE__, __PRETTY_FUNCTION__, (format), ## __VA_ARGS__); }
|
#define WriteTrace(m, s, format, ...) \
|
||||||
|
if (g_ModuleLogLevel[(m)] >= (s)) \
|
||||||
|
{ \
|
||||||
|
WriteTraceFull((m), (s), __FILE__, __LINE__, __PRETTY_FUNCTION__, (format), ##__VA_ARGS__); \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CTraceModule * TraceAddModule(CTraceModule * TraceModule);
|
CTraceModule * TraceAddModule(CTraceModule * TraceModule);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <Tlhelp32.h>
|
#include <Tlhelp32.h>
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -17,7 +18,8 @@ void pjutil::Sleep(uint32_t timeout)
|
||||||
struct timespec elapsed, tv;
|
struct timespec elapsed, tv;
|
||||||
elapsed.tv_sec = timeout / 1000;
|
elapsed.tv_sec = timeout / 1000;
|
||||||
elapsed.tv_nsec = (timeout % 1000) * 1000000;
|
elapsed.tv_nsec = (timeout % 1000) * 1000000;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
tv.tv_sec = elapsed.tv_sec;
|
tv.tv_sec = elapsed.tv_sec;
|
||||||
tv.tv_nsec = elapsed.tv_nsec;
|
tv.tv_nsec = elapsed.tv_nsec;
|
||||||
|
|
|
@ -41,19 +41,25 @@ documentation and/or software.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
#include "path.h"
|
|
||||||
#include "StdString.h"
|
#include "StdString.h"
|
||||||
|
#include "path.h"
|
||||||
|
#include <functional>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct MD5Digest
|
struct MD5Digest
|
||||||
{
|
{
|
||||||
MD5Digest() { Reset(); }
|
MD5Digest()
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
unsigned char digest[16];
|
unsigned char digest[16];
|
||||||
|
|
||||||
void Reset() { ::memset(digest, 0, sizeof(digest)); }
|
void Reset()
|
||||||
|
{
|
||||||
|
::memset(digest, 0, sizeof(digest));
|
||||||
|
}
|
||||||
bool IsClear()
|
bool IsClear()
|
||||||
{
|
{
|
||||||
int isClear = 0;
|
int isClear = 0;
|
||||||
|
@ -110,7 +116,6 @@ public:
|
||||||
const char * hex_digest(); // Digest as a 33-byte ascii-hex string
|
const char * hex_digest(); // Digest as a 33-byte ascii-hex string
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// First, some types:
|
// First, some types:
|
||||||
typedef unsigned int uint4; // Assumes integer is 4 words long
|
typedef unsigned int uint4; // Assumes integer is 4 words long
|
||||||
typedef unsigned short int uint2; // Assumes short integer is 2 words long
|
typedef unsigned short int uint2; // Assumes short integer is 2 words long
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "StdString.h"
|
||||||
#include "Trace.h"
|
#include "Trace.h"
|
||||||
#include "TraceModulesCommon.h"
|
#include "TraceModulesCommon.h"
|
||||||
#include "StdString.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
|
@ -9,13 +9,14 @@
|
||||||
#pragma warning(disable : 4996) // warning C4091: 'typedef ': ignored on left of 'tagGPFIDL_FLAGS' when no variable is declared
|
#pragma warning(disable : 4996) // warning C4091: 'typedef ': ignored on left of 'tagGPFIDL_FLAGS' when no variable is declared
|
||||||
#include <Shlobj.h>
|
#include <Shlobj.h>
|
||||||
#include <dos.h>
|
#include <dos.h>
|
||||||
|
|
||||||
#include <CommDlg.h>
|
#include <CommDlg.h>
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#else
|
#else
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
@ -24,9 +25,17 @@
|
||||||
|
|
||||||
#undef WriteTrace
|
#undef WriteTrace
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WriteTrace(m, s, format, ...) if (g_ModuleLogLevel != nullptr && g_ModuleLogLevel[(m)] >= (s)) { WriteTraceFull((m), (s), __FILE__, __LINE__, __FUNCTION__, (format), ## __VA_ARGS__); }
|
#define WriteTrace(m, s, format, ...) \
|
||||||
|
if (g_ModuleLogLevel != nullptr && g_ModuleLogLevel[(m)] >= (s)) \
|
||||||
|
{ \
|
||||||
|
WriteTraceFull((m), (s), __FILE__, __LINE__, __FUNCTION__, (format), ##__VA_ARGS__); \
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define WriteTrace(m, s, format, ...) if (g_ModuleLogLevel != nullptr && g_ModuleLogLevel[(m)] >= (s)) { WriteTraceFull((m), (s), __FILE__, __LINE__, __PRETTY_FUNCTION__, (format), ## __VA_ARGS__); }
|
#define WriteTrace(m, s, format, ...) \
|
||||||
|
if (g_ModuleLogLevel != nullptr && g_ModuleLogLevel[(m)] >= (s)) \
|
||||||
|
{ \
|
||||||
|
WriteTraceFull((m), (s), __FILE__, __LINE__, __PRETTY_FUNCTION__, (format), ##__VA_ARGS__); \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
@ -249,7 +258,10 @@ CPath::CPath(DIR_CURRENT_DIRECTORY /*sdt*/, const char * NameExten)
|
||||||
// Application's current directory
|
// Application's current directory
|
||||||
Init();
|
Init();
|
||||||
CurrentDirectory();
|
CurrentDirectory();
|
||||||
if (NameExten) { SetNameExtension(NameExten); }
|
if (NameExten)
|
||||||
|
{
|
||||||
|
SetNameExtension(NameExten);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -258,7 +270,10 @@ CPath::CPath(DIR_MODULE_DIRECTORY /*sdt*/, const char * NameExten)
|
||||||
// The directory where the executable of this app is
|
// The directory where the executable of this app is
|
||||||
Init();
|
Init();
|
||||||
ModuleDirectory();
|
ModuleDirectory();
|
||||||
if (NameExten) { SetNameExtension(NameExten); }
|
if (NameExten)
|
||||||
|
{
|
||||||
|
SetNameExtension(NameExten);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPath::CPath(DIR_MODULE_FILE /*sdt*/)
|
CPath::CPath(DIR_MODULE_FILE /*sdt*/)
|
||||||
|
@ -599,7 +614,10 @@ void CPath::SetComponents(const char * lpszDirectory, const char * lpszName, con
|
||||||
memset(buff_fullname, 0, sizeof(buff_fullname));
|
memset(buff_fullname, 0, sizeof(buff_fullname));
|
||||||
if (lpszDirectory != nullptr && lpszDirectory[0] != '\0')
|
if (lpszDirectory != nullptr && lpszDirectory[0] != '\0')
|
||||||
{
|
{
|
||||||
if (lpszDirectory[0] != DIRECTORY_DELIMITER) { buff_fullname[0] = DIRECTORY_DELIMITER; }
|
if (lpszDirectory[0] != DIRECTORY_DELIMITER)
|
||||||
|
{
|
||||||
|
buff_fullname[0] = DIRECTORY_DELIMITER;
|
||||||
|
}
|
||||||
strncat(buff_fullname, lpszDirectory, sizeof(buff_fullname) - 1);
|
strncat(buff_fullname, lpszDirectory, sizeof(buff_fullname) - 1);
|
||||||
std::string::size_type nLength = strlen(buff_fullname);
|
std::string::size_type nLength = strlen(buff_fullname);
|
||||||
if (buff_fullname[nLength - 1] != DIRECTORY_DELIMITER && nLength < sizeof(buff_fullname))
|
if (buff_fullname[nLength - 1] != DIRECTORY_DELIMITER && nLength < sizeof(buff_fullname))
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class CPath
|
class CPath
|
||||||
{
|
{
|
||||||
// Enums
|
// Enums
|
||||||
public:
|
public:
|
||||||
|
enum DIR_CURRENT_DIRECTORY
|
||||||
enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 };
|
{
|
||||||
|
CURRENT_DIRECTORY = 1
|
||||||
|
};
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
enum DIR_MODULE_DIRECTORY { MODULE_DIRECTORY = 2 };
|
enum DIR_MODULE_DIRECTORY
|
||||||
enum DIR_MODULE_FILE { MODULE_FILE = 3 };
|
{
|
||||||
|
MODULE_DIRECTORY = 2
|
||||||
|
};
|
||||||
|
enum DIR_MODULE_FILE
|
||||||
|
{
|
||||||
|
MODULE_FILE = 3
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -58,7 +66,10 @@ public:
|
||||||
bool operator==(const CPath & rPath) const;
|
bool operator==(const CPath & rPath) const;
|
||||||
bool operator!=(const CPath & rPath) const;
|
bool operator!=(const CPath & rPath) const;
|
||||||
operator const char *() const;
|
operator const char *() const;
|
||||||
operator const std::string &() { return m_strPath; }
|
operator const std::string &()
|
||||||
|
{
|
||||||
|
return m_strPath;
|
||||||
|
}
|
||||||
|
|
||||||
// Get path components
|
// Get path components
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -82,7 +93,10 @@ public:
|
||||||
void GetComponents(std::string * pDirectory = nullptr, std::string * pName = nullptr, std::string * pExtension = nullptr) const;
|
void GetComponents(std::string * pDirectory = nullptr, std::string * pName = nullptr, std::string * pExtension = nullptr) const;
|
||||||
#endif
|
#endif
|
||||||
// Get other state
|
// Get other state
|
||||||
bool IsEmpty() const { return m_strPath.empty(); }
|
bool IsEmpty() const
|
||||||
|
{
|
||||||
|
return m_strPath.empty();
|
||||||
|
}
|
||||||
bool IsRelative() const;
|
bool IsRelative() const;
|
||||||
|
|
||||||
// Set path components
|
// Set path components
|
||||||
|
@ -104,7 +118,10 @@ public:
|
||||||
void SetComponents(const char * lpszDirectory, const char * lpszName, const char * lpszExtension);
|
void SetComponents(const char * lpszDirectory, const char * lpszName, const char * lpszExtension);
|
||||||
#endif
|
#endif
|
||||||
// Set whole path
|
// Set whole path
|
||||||
void Empty() { m_strPath.erase(); }
|
void Empty()
|
||||||
|
{
|
||||||
|
m_strPath.erase();
|
||||||
|
}
|
||||||
void CurrentDirectory();
|
void CurrentDirectory();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void Module();
|
void Module();
|
||||||
|
@ -118,7 +135,10 @@ public:
|
||||||
bool DirectoryExists() const;
|
bool DirectoryExists() const;
|
||||||
|
|
||||||
// File information
|
// File information
|
||||||
bool IsFile() const { return !IsDirectory(); }
|
bool IsFile() const
|
||||||
|
{
|
||||||
|
return !IsDirectory();
|
||||||
|
}
|
||||||
bool Exists() const;
|
bool Exists() const;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist);
|
bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist);
|
||||||
|
|
Loading…
Reference in New Issue