From 915c200ebcd8903652ef7b867e0f89568ac00529 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 22 Aug 2019 21:18:37 +0200 Subject: [PATCH] luascript: use fileExists --- client/cmdscript.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/cmdscript.c b/client/cmdscript.c index 90cd65532..eb7979a00 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -26,6 +26,7 @@ #include "lauxlib.h" #include "proxmark3.h" #include "ui.h" +#include "fileutils.h" #ifdef _WIN32 #include "scandir.h" @@ -153,10 +154,8 @@ static int CmdScriptRun(const char *Cmd) { strcat(script_path, LUA_SCRIPTS_DIRECTORY); strcat(script_path, script_name); strcat(script_path, suffix); - FILE *file; - if ((file = fopen(script_path, "r"))) + if (fileExists(script_path)) { - fclose(file); PrintAndLogEx(SUCCESS, "Executing: %s, args '%s'\n", script_path, arguments); found = true; error = luaL_loadfile(lua_state, script_path); @@ -170,10 +169,8 @@ static int CmdScriptRun(const char *Cmd) { strcat(script_path, LUA_SCRIPTS_DIRECTORY); strcat(script_path, script_name); strcat(script_path, suffix); - FILE *file; - if ((file = fopen(script_path, "r"))) + if (fileExists(script_path)) { - fclose(file); PrintAndLogEx(SUCCESS, "Executing: %s, args '%s'\n", script_path, arguments); found = true; error = luaL_loadfile(lua_state, script_path); @@ -185,10 +182,8 @@ static int CmdScriptRun(const char *Cmd) { strcat(script_path, LUA_SCRIPTS_DIRECTORY); strcat(script_path, script_name); strcat(script_path, suffix); - FILE *file; - if ((file = fopen(script_path, "r"))) + if (fileExists(script_path)) { - fclose(file); PrintAndLogEx(SUCCESS, "Executing: %s, args '%s'\n", script_path, arguments); found = true; error = luaL_loadfile(lua_state, script_path);