summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-03-10 14:13:46 +0200
committerunknown <monty@narttu.mysql.fi>2003-03-10 14:13:46 +0200
commit809d47dd2fc0322e5c3c713ca2c2cc4818756758 (patch)
treee5ead60265e7c75b687cf6327ae7a9b589cc6e12 /mysys
parent8c955a8dba806c51b6083544a6bbe170a22c099b (diff)
parent90a25db9324bbb4f3c2a85e7ff5134dfc6abaf40 (diff)
downloadmariadb-git-809d47dd2fc0322e5c3c713ca2c2cc4818756758.tar.gz
merge
BitKeeper/etc/ignore: auto-union BitKeeper/deleted/.del-delete.result: Auto merged client/mysqlbinlog.cc: Auto merged libmysql/libmysql.c: Auto merged mysql-test/r/delete.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/t/delete.test: Auto merged mysql-test/t/type_datetime.test: Auto merged sql/field.h: Auto merged sql/ha_myisam.cc: Auto merged sql/lock.cc: Auto merged sql/log_event.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/slave.cc: Auto merged sql/sql_repl.h: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_copy.c30
-rw-r--r--mysys/my_getopt.c4
2 files changed, 24 insertions, 10 deletions
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index 012eaec4ea8..84eda781a09 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -31,17 +31,29 @@ struct utimbuf {
#endif
- /*
- Ordinary ownership and accesstimes are copied from 'from-file'
- if MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
- the modes of to-file isn't changed
- Dont set MY_FNABP or MY_NABP bits on when calling this function !
- */
+/*
+ int my_copy(const char *from, const char *to, myf MyFlags)
+
+ NOTES
+ Ordinary ownership and accesstimes are copied from 'from-file'
+ If MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
+ the modes of to-file isn't changed
+ If MyFlags & MY_DONT_OVERWRITE_FILE is set, we will give an error
+ if the file existed.
+
+ WARNING
+ Don't set MY_FNABP or MY_NABP bits on when calling this function !
+
+ RETURN
+ 0 ok
+ # Error
+
+*/
int my_copy(const char *from, const char *to, myf MyFlags)
{
uint Count;
- int new_file_stat;
+ int new_file_stat, create_flag;
File from_file,to_file;
char buff[IO_SIZE];
struct stat stat_buff,new_stat_buff;
@@ -62,8 +74,10 @@ int my_copy(const char *from, const char *to, myf MyFlags)
}
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
stat_buff=new_stat_buff;
+ create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
+
if ((to_file= my_create(to,(int) stat_buff.st_mode,
- O_WRONLY | O_TRUNC | O_BINARY | O_SHARE,
+ O_WRONLY | create_flag | O_BINARY | O_SHARE,
MyFlags)) < 0)
goto err;
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index c6fe606eaaf..759c96462f6 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -431,8 +431,8 @@ int handle_options(int *argc, char ***argv,
Will set the option value to given value
*/
-static int setval (const struct my_option *opts, char *argument,
- my_bool set_maximum_value)
+static int setval(const struct my_option *opts, char *argument,
+ my_bool set_maximum_value)
{
int err= 0;