From bd94b978838346e5662e5ef46455ae454451c0b3 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 7 Feb 2017 22:26:42 +0100 Subject: [PATCH] CHG: syntax sugar --- client/cmdscript.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/client/cmdscript.c b/client/cmdscript.c index e9ec5871..87544a99 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -72,26 +72,27 @@ int CmdHelp(const char * Cmd) * Generate list of available commands, what it does is * generate a file listing of the script-directory for files * ending with .lua +* */ int CmdList(const char *Cmd) { - DIR *dp; struct dirent *ep; - dp = opendir ("./scripts/"); - - if (dp != NULL) - { - while ((ep = readdir (dp)) != NULL) - { - if(str_ends_with(ep->d_name, ".lua")) - PrintAndLog("%-21s %s", ep->d_name, "A script file"); - } - (void) closedir (dp); - } - else - PrintAndLog ("Couldn't open the scripts-directory"); + DIR *dp = opendir ("./scripts/"); + if ( dp == NULL ) { + PrintAndLog ("Couldn't open the scripts-directory"); + return 1; + } + + while ((ep = readdir (dp)) != NULL) + { + if(str_ends_with(ep->d_name, ".lua")) + PrintAndLog("%-21s %s", ep->d_name, "A script file"); + } + (void) closedir (dp); return 0; } + + /** * Finds a matching script-file * @brief CmdScript -- 2.39.2