mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 07:22:57 +02:00
lua_filehelpers.cpp: Add lua script function 'cp()'
- Set Lua api version to 1.48
Origin commit data
------------------
Commit: 270cd318ec
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-09-03 (Sat, 03 Sep 2016)
This commit is contained in:
@@ -4,4 +4,4 @@
|
|||||||
* to luainstance.h changes
|
* to luainstance.h changes
|
||||||
*/
|
*/
|
||||||
#define LUA_API_VERSION_MAJOR 1
|
#define LUA_API_VERSION_MAJOR 1
|
||||||
#define LUA_API_VERSION_MINOR 47
|
#define LUA_API_VERSION_MINOR 48
|
||||||
|
@@ -50,6 +50,7 @@ void CLuaInstFileHelpers::LuaFileHelpersRegister(lua_State *L)
|
|||||||
{
|
{
|
||||||
luaL_Reg meth[] = {
|
luaL_Reg meth[] = {
|
||||||
{ "new", CLuaInstFileHelpers::FileHelpersNew },
|
{ "new", CLuaInstFileHelpers::FileHelpersNew },
|
||||||
|
{ "cp", CLuaInstFileHelpers::FileHelpersCp },
|
||||||
{ "__gc", CLuaInstFileHelpers::FileHelpersDelete },
|
{ "__gc", CLuaInstFileHelpers::FileHelpersDelete },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
@@ -70,6 +71,46 @@ int CLuaInstFileHelpers::FileHelpersNew(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CLuaInstFileHelpers::FileHelpersCp(lua_State *L)
|
||||||
|
{
|
||||||
|
CLuaFileHelpers *D = FileHelpersCheckData(L, 1);
|
||||||
|
if (!D) return 0;
|
||||||
|
|
||||||
|
int numargs = lua_gettop(L) - 1;
|
||||||
|
int min_numargs = 2;
|
||||||
|
if (numargs < min_numargs) {
|
||||||
|
printf("luascript cp: not enough arguments (%d, expected %d)\n", numargs, min_numargs);
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lua_isstring(L, 2)) {
|
||||||
|
printf("luascript cp: argument 1 is not a string.\n");
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *from = "";
|
||||||
|
from = luaL_checkstring(L, 2);
|
||||||
|
|
||||||
|
if (!lua_isstring(L, 3)) {
|
||||||
|
printf("luascript cp: argument 2 is not a string.\n");
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *to = "";
|
||||||
|
to = luaL_checkstring(L, 3);
|
||||||
|
|
||||||
|
const char *flags = "";
|
||||||
|
if (numargs > min_numargs)
|
||||||
|
flags = luaL_checkstring(L, 4);
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
|
CFileHelpers fh;
|
||||||
|
ret = fh.cp(from, to, flags);
|
||||||
|
|
||||||
|
lua_pushboolean(L, ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ class CLuaInstFileHelpers
|
|||||||
private:
|
private:
|
||||||
static CLuaFileHelpers *FileHelpersCheckData(lua_State *L, int n);
|
static CLuaFileHelpers *FileHelpersCheckData(lua_State *L, int n);
|
||||||
static int FileHelpersNew(lua_State *L);
|
static int FileHelpersNew(lua_State *L);
|
||||||
|
static int FileHelpersCp(lua_State *L);
|
||||||
static int FileHelpersDelete(lua_State *L);
|
static int FileHelpersDelete(lua_State *L);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user