mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
Use DebugInfo functions in CFileHelpers::cp / lua cp
Origin commit data
------------------
Commit: de07369d68
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-09-04 (Sun, 04 Sep 2016)
This commit is contained in:
@@ -106,7 +106,17 @@ int CLuaInstFileHelpers::FileHelpersCp(lua_State *L)
|
|||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
CFileHelpers fh;
|
CFileHelpers fh;
|
||||||
|
fh.setConsoleQuiet(true);
|
||||||
ret = fh.cp(from, to, flags);
|
ret = fh.cp(from, to, flags);
|
||||||
|
if (ret == false) {
|
||||||
|
helpersDebugInfo di;
|
||||||
|
fh.readDebugInfo(&di);
|
||||||
|
lua_Debug ar;
|
||||||
|
lua_getstack(L, 1, &ar);
|
||||||
|
lua_getinfo(L, "Sl", &ar);
|
||||||
|
printf(">>> Lua script error [%s:%d] %s\n (error from neutrino: [%s:%d])\n",
|
||||||
|
ar.short_src, ar.currentline, di.msg.c_str(), di.file.c_str(), di.line);
|
||||||
|
}
|
||||||
|
|
||||||
lua_pushboolean(L, ret);
|
lua_pushboolean(L, ret);
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -588,8 +588,12 @@ void CFileHelpers::printDebugInfo()
|
|||||||
|
|
||||||
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))
|
clearDebugInfo();
|
||||||
|
if ((Src == NULL) || (Dst == NULL)) {
|
||||||
|
setDebugInfo("One or more parameters are NULL", __path_file__, __func__, __LINE__);
|
||||||
|
printDebugInfo();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string src = Src;
|
std::string src = Src;
|
||||||
src = trim(src);
|
src = trim(src);
|
||||||
@@ -614,10 +618,16 @@ bool CFileHelpers::cp(const char *Src, const char *Dst, const char *Flags/*=""*/
|
|||||||
static struct stat FileInfo;
|
static struct stat FileInfo;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
if (wildcards == false) {
|
if (wildcards == false) {
|
||||||
if (!file_exists(src.c_str()))
|
if (!file_exists(src.c_str())) {
|
||||||
|
setDebugInfo("Source file not exist", __path_file__, __func__, __LINE__);
|
||||||
|
printDebugInfo();
|
||||||
return false;
|
return false;
|
||||||
if (lstat(src.c_str(), &FileInfo) == -1)
|
}
|
||||||
|
if (lstat(src.c_str(), &FileInfo) == -1) {
|
||||||
|
setDebugInfo("lstat error", __path_file__, __func__, __LINE__);
|
||||||
|
printDebugInfo();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
pos = src.find_last_of("/");
|
pos = src.find_last_of("/");
|
||||||
std::string fname = src.substr(pos);
|
std::string fname = src.substr(pos);
|
||||||
@@ -665,7 +675,8 @@ bool CFileHelpers::cp(const char *Src, const char *Dst, const char *Flags/*=""*/
|
|||||||
if (recursive)
|
if (recursive)
|
||||||
copyDir(src.c_str(), dst.c_str());
|
copyDir(src.c_str(), dst.c_str());
|
||||||
else {
|
else {
|
||||||
printf("#### [%s:%d] 'recursive flag' must be set to copy dir.\n", __func__, __LINE__);
|
setDebugInfo("'recursive flag' must be set to copy dir.", __path_file__, __func__, __LINE__);
|
||||||
|
printDebugInfo();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -683,13 +694,14 @@ bool CFileHelpers::cp(const char *Src, const char *Dst, const char *Flags/*=""*/
|
|||||||
copyFile(src.c_str(), dst.c_str());
|
copyFile(src.c_str(), dst.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("#### [%s:%d] Currently unsupported st_mode.\n", __func__, __LINE__);
|
setDebugInfo("Currently unsupported st_mode.", __path_file__, __func__, __LINE__);
|
||||||
|
printDebugInfo();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("#### [%s:%d] Wildcard feature not yet realized.\n", __func__, __LINE__);
|
setDebugInfo("Wildcard feature not yet realized.", __path_file__, __func__, __LINE__);
|
||||||
|
printDebugInfo();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user