mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
CFileHelpers: Add DebugInfo functions for displaying error messages..
..in lua script functions
Origin commit data
------------------
Commit: 83a902d524
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-09-04 (Sun, 04 Sep 2016)
This commit is contained in:
@@ -538,6 +538,8 @@ CFileHelpers::CFileHelpers()
|
|||||||
FileBufSize = 0xFFFF;
|
FileBufSize = 0xFFFF;
|
||||||
FileBuf = new char[FileBufSize];
|
FileBuf = new char[FileBufSize];
|
||||||
doCopyFlag = true;
|
doCopyFlag = true;
|
||||||
|
ConsoleQuiet = false;
|
||||||
|
clearDebugInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CFileHelpers::~CFileHelpers()
|
CFileHelpers::~CFileHelpers()
|
||||||
@@ -554,6 +556,36 @@ CFileHelpers* CFileHelpers::getInstance()
|
|||||||
return FileHelpers;
|
return FileHelpers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFileHelpers::clearDebugInfo()
|
||||||
|
{
|
||||||
|
DebugInfo.msg.clear();
|
||||||
|
DebugInfo.file.clear();
|
||||||
|
DebugInfo.func.clear();
|
||||||
|
DebugInfo.line = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFileHelpers::setDebugInfo(const char* msg, const char* file, const char* func, int line)
|
||||||
|
{
|
||||||
|
DebugInfo.msg = msg;
|
||||||
|
DebugInfo.file = file;
|
||||||
|
DebugInfo.func = func;
|
||||||
|
DebugInfo.line = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFileHelpers::readDebugInfo(helpersDebugInfo* di)
|
||||||
|
{
|
||||||
|
di->msg = DebugInfo.msg;
|
||||||
|
di->file = DebugInfo.file;
|
||||||
|
di->func = DebugInfo.func;
|
||||||
|
di->line = DebugInfo.line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFileHelpers::printDebugInfo()
|
||||||
|
{
|
||||||
|
if (!ConsoleQuiet)
|
||||||
|
printf(">>>> [%s:%d] %s\n", DebugInfo.func.c_str(), DebugInfo.line, DebugInfo.msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
bool CFileHelpers::cp(const char *Src, const char *Dst, const char *Flags/*=""*/)
|
bool CFileHelpers::cp(const char *Src, const char *Dst, const char *Flags/*=""*/)
|
||||||
{
|
{
|
||||||
if ((Src == NULL) || (Dst == NULL))
|
if ((Src == NULL) || (Dst == NULL))
|
||||||
|
@@ -74,6 +74,13 @@ time_t toEpoch(std::string &date);
|
|||||||
std::string& str_replace(const std::string &search, const std::string &replace, std::string &text);
|
std::string& str_replace(const std::string &search, const std::string &replace, std::string &text);
|
||||||
std::string& htmlEntityDecode(std::string& text);
|
std::string& htmlEntityDecode(std::string& text);
|
||||||
|
|
||||||
|
struct helpersDebugInfo {
|
||||||
|
std::string msg;
|
||||||
|
std::string file;
|
||||||
|
std::string func;
|
||||||
|
int line;
|
||||||
|
};
|
||||||
|
|
||||||
class CFileHelpers
|
class CFileHelpers
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -81,12 +88,22 @@ class CFileHelpers
|
|||||||
char *FileBuf;
|
char *FileBuf;
|
||||||
int fd1, fd2;
|
int fd1, fd2;
|
||||||
|
|
||||||
|
bool ConsoleQuiet;
|
||||||
|
helpersDebugInfo DebugInfo;
|
||||||
|
void setDebugInfo(const char* msg, const char* file, const char* func, int line);
|
||||||
|
void printDebugInfo();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFileHelpers();
|
CFileHelpers();
|
||||||
~CFileHelpers();
|
~CFileHelpers();
|
||||||
static CFileHelpers* getInstance();
|
static CFileHelpers* getInstance();
|
||||||
bool doCopyFlag;
|
bool doCopyFlag;
|
||||||
|
|
||||||
|
void clearDebugInfo();
|
||||||
|
void readDebugInfo(helpersDebugInfo* di);
|
||||||
|
void setConsoleQuiet(bool q) { ConsoleQuiet = q; };
|
||||||
|
bool getConsoleQuiet() { return ConsoleQuiet; };
|
||||||
|
|
||||||
bool cp(const char *Src, const char *Dst, const char *Flags="");
|
bool cp(const char *Src, const char *Dst, const char *Flags="");
|
||||||
bool copyFile(const char *Src, const char *Dst, mode_t forceMode=0);
|
bool copyFile(const char *Src, const char *Dst, mode_t forceMode=0);
|
||||||
bool copyDir(const char *Src, const char *Dst, bool backupMode=false);
|
bool copyDir(const char *Src, const char *Dst, bool backupMode=false);
|
||||||
|
Reference in New Issue
Block a user