Add a new configuration file command ifnxcp that allows file copying without overwriting already existing file.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@410 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2008-01-13 00:12:59 +00:00
parent 83de87968d
commit 45f9640554
4 changed files with 10 additions and 0 deletions

View File

@ -86,6 +86,7 @@ game_start { yylval.i = DGLTIME_GAMESTART; return TYPE_CMDQUEUENAME; }
mkdir { yylval.i = DGLCMD_MKDIR; return TYPE_DGLCMD1; } mkdir { yylval.i = DGLCMD_MKDIR; return TYPE_DGLCMD1; }
chdir { yylval.i = DGLCMD_CHDIR; return TYPE_DGLCMD1; } chdir { yylval.i = DGLCMD_CHDIR; return TYPE_DGLCMD1; }
cp { yylval.i = DGLCMD_CP; return TYPE_DGLCMD2; } cp { yylval.i = DGLCMD_CP; return TYPE_DGLCMD2; }
ifnxcp { yylval.i = DGLCMD_IF_NX_CP; return TYPE_DGLCMD2; }
unlink { yylval.i = DGLCMD_UNLINK; return TYPE_DGLCMD1; } unlink { yylval.i = DGLCMD_UNLINK; return TYPE_DGLCMD1; }
setenv { yylval.i = DGLCMD_SETENV; return TYPE_DGLCMD2; } setenv { yylval.i = DGLCMD_SETENV; return TYPE_DGLCMD2; }
exec { yylval.i = DGLCMD_EXEC; return TYPE_DGLCMD2; } exec { yylval.i = DGLCMD_EXEC; return TYPE_DGLCMD2; }

View File

@ -99,6 +99,7 @@ typedef enum
DGLCMD_NONE = 0, DGLCMD_NONE = 0,
DGLCMD_MKDIR, /* mkdir foo */ DGLCMD_MKDIR, /* mkdir foo */
DGLCMD_CHDIR, /* chdir foo */ DGLCMD_CHDIR, /* chdir foo */
DGLCMD_IF_NX_CP, /* ifnxcp foo bar */
DGLCMD_CP, /* cp foo bar */ DGLCMD_CP, /* cp foo bar */
DGLCMD_UNLINK, /* unlink foo */ DGLCMD_UNLINK, /* unlink foo */
DGLCMD_EXEC, /* exec foo bar */ DGLCMD_EXEC, /* exec foo bar */

View File

@ -144,6 +144,13 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
case DGLCMD_CHDIR: case DGLCMD_CHDIR:
if (p1) chdir(p1); if (p1) chdir(p1);
break; break;
case DGLCMD_IF_NX_CP:
if (p1 && p2) {
FILE *tmpfile;
tmpfile = fopen(p2, "r");
if (tmpfile) break;
}
/* else fall through to cp */
case DGLCMD_CP: case DGLCMD_CP:
if (p1 && p2) { if (p1 && p2) {
FILE *cannedf, *newfile; FILE *cannedf, *newfile;

View File

@ -71,6 +71,7 @@ lockfile = "/dgl-lock"
# mkdir "foo" = creates a directory "foo" # mkdir "foo" = creates a directory "foo"
# chdir "foo" = changes current work dir to "foo" # chdir "foo" = changes current work dir to "foo"
# cp "foo" "bar" = copies file "foo" to "bar", overwriting previous "bar" # cp "foo" "bar" = copies file "foo" to "bar", overwriting previous "bar"
# ifnxcp "foo" "bar" = copies file "foo" to "bar", if "bar" doesn't exist
# unlink "foo" = deletes file "foo" # unlink "foo" = deletes file "foo"
# setenv "foo "bar" = sets environment variable "foo" to "bar" # setenv "foo "bar" = sets environment variable "foo" to "bar"
# exec "foo" "bar" = execute "foo" with "bar" as it's param # exec "foo" "bar" = execute "foo" with "bar" as it's param