diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 36 | ||||
-rwxr-xr-x | apps/plugins/lua/rocklib_aux.pl | 2 |
2 files changed, 38 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 82a03ab6b4..64394b8728 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -363,6 +363,39 @@ RB_WRAP(get_plugin_action) | |||
363 | return 1; | 363 | return 1; |
364 | } | 364 | } |
365 | 365 | ||
366 | RB_WRAP(strip_extension) | ||
367 | { | ||
368 | const char* filename = luaL_checkstring(L, -1); | ||
369 | const char* pos = rb->strrchr(filename, '.'); | ||
370 | if(pos != NULL) | ||
371 | lua_pushlstring (L, filename, pos - filename); | ||
372 | |||
373 | return 1; | ||
374 | } | ||
375 | |||
376 | RB_WRAP(create_numbered_filename) | ||
377 | { | ||
378 | luaL_Buffer b; | ||
379 | luaL_buffinit(L, &b); | ||
380 | char *buffer = luaL_prepbuffer(&b); | ||
381 | buffer[0] = '\0'; | ||
382 | |||
383 | const char * path = luaL_checkstring(L, 1); | ||
384 | const char * prefix = luaL_checkstring(L, 2); | ||
385 | const char * suffix = luaL_checkstring(L, 3); | ||
386 | int numberlen = luaL_optint(L, 4, -1); | ||
387 | |||
388 | if(rb->create_numbered_filename(buffer, path, prefix, suffix, numberlen)) | ||
389 | { | ||
390 | luaL_addstring(&b, buffer); | ||
391 | luaL_pushresult(&b); | ||
392 | } | ||
393 | else | ||
394 | return 0; | ||
395 | |||
396 | return 1; | ||
397 | } | ||
398 | |||
366 | #define RB_FUNC(func) {#func, rock_##func} | 399 | #define RB_FUNC(func) {#func, rock_##func} |
367 | static const luaL_Reg rocklib[] = | 400 | static const luaL_Reg rocklib[] = |
368 | { | 401 | { |
@@ -410,6 +443,9 @@ static const luaL_Reg rocklib[] = | |||
410 | 443 | ||
411 | RB_FUNC(get_plugin_action), | 444 | RB_FUNC(get_plugin_action), |
412 | 445 | ||
446 | RB_FUNC(strip_extension), | ||
447 | RB_FUNC(create_numbered_filename), | ||
448 | |||
413 | {NULL, NULL} | 449 | {NULL, NULL} |
414 | }; | 450 | }; |
415 | #undef RB_FUNC | 451 | #undef RB_FUNC |
diff --git a/apps/plugins/lua/rocklib_aux.pl b/apps/plugins/lua/rocklib_aux.pl index f04457f189..085a191ee3 100755 --- a/apps/plugins/lua/rocklib_aux.pl +++ b/apps/plugins/lua/rocklib_aux.pl | |||
@@ -65,6 +65,8 @@ my @forbidden_functions = ('^open$', | |||
65 | '^fdprintf$', | 65 | '^fdprintf$', |
66 | '^read_line$', | 66 | '^read_line$', |
67 | '^[a-z]+dir$', | 67 | '^[a-z]+dir$', |
68 | '^strip_extension$', | ||
69 | '^create_numbered_filename$', | ||
68 | '^s?+rand$', | 70 | '^s?+rand$', |
69 | '^strl?+cpy$', | 71 | '^strl?+cpy$', |
70 | '^strl?+cat$', | 72 | '^strl?+cat$', |