Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9bad936

Browse files
committed
Handle cp, rm, and exec for Win32.
1 parent9c26497 commit9bad936

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.110 2003/01/27 00:46:41 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.111 2003/04/04 20:40:44 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -302,7 +302,11 @@ createdb(const CreatedbStmt *stmt)
302302
}
303303

304304
/* Copy the template database to the new location */
305+
#ifndefWIN32
305306
snprintf(buf,sizeof(buf),"cp -r '%s' '%s'",src_loc,target_dir);
307+
#else
308+
snprintf(buf,sizeof(buf),"xcopy /e /i /q '%s' '%s'",src_loc,target_dir);
309+
#endif
306310

307311
if (system(buf)!=0)
308312
{
@@ -751,7 +755,11 @@ remove_dbdirs(const char *nominal_loc, const char *alt_loc)
751755
}
752756
}
753757

758+
#ifndefWIN32
754759
snprintf(buf,sizeof(buf),"rm -rf '%s'",target_dir);
760+
#else
761+
snprintf(buf,sizeof(buf),"rmdir /s /q \"%s\"",target_dir);
762+
#endif
755763

756764
if (system(buf)!=0)
757765
{

‎src/bin/psql/command.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000-2002 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.94 2003/03/20 06:43:35 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.95 2003/04/04 20:40:45 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -66,8 +66,6 @@ static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
6666
staticbooldo_connect(constchar*new_dbname,constchar*new_user);
6767
staticbooldo_shell(constchar*command);
6868

69-
70-
7169
/*----------
7270
* HandleSlashCmds:
7371
*
@@ -1515,7 +1513,11 @@ editFile(const char *fname)
15151513
sys=malloc(strlen(editorName)+strlen(fname)+10+1);
15161514
if (!sys)
15171515
return false;
1518-
sprintf(sys,"exec %s '%s'",editorName,fname);
1516+
sprintf(sys,
1517+
#ifndefWIN32
1518+
"exec "
1519+
#endif
1520+
"%s '%s'",editorName,fname);
15191521
result=system(sys);
15201522
if (result==-1)
15211523
psql_error("could not start editor %s\n",editorName);
@@ -1944,7 +1946,11 @@ do_shell(const char *command)
19441946
else
19451947
exit(EXIT_FAILURE);
19461948
}
1947-
sprintf(sys,"exec %s",shellName);
1949+
sprintf(sys,
1950+
#ifndefWIN32
1951+
"exec "
1952+
#endif
1953+
"%s",shellName);
19481954
result=system(sys);
19491955
free(sys);
19501956
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp