diff options
author | monty@narttu.mysql.fi <> | 2003-03-10 12:48:43 +0200 |
---|---|---|
committer | monty@narttu.mysql.fi <> | 2003-03-10 12:48:43 +0200 |
commit | f1635f64f9fea3cd747e9f38653aa4ba5b5f3ed6 (patch) | |
tree | 8651694def257832c6e225eead2eec4c5a7c9aeb /mysys/my_copy.c | |
parent | e98a4473b42c75851b2bed1a82d06596637279c9 (diff) | |
parent | c231b747e3d5bea9bf636528bf5491dd29ebab8e (diff) | |
download | mariadb-git-f1635f64f9fea3cd747e9f38653aa4ba5b5f3ed6.tar.gz |
Merge with 3.23 to get fixes for --user and BACKUP TABLE
Diffstat (limited to 'mysys/my_copy.c')
-rw-r--r-- | mysys/my_copy.c | 30 |
1 files changed, 22 insertions, 8 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; |