16 #include "mysys_priv.h"
18 #include "mysys_err.h"
24 int my_rename(
const char *from,
const char *
to, myf MyFlags)
27 DBUG_ENTER(
"my_rename");
28 DBUG_PRINT(
"my",(
"from %s to %s MyFlags %d", from, to, MyFlags));
30 #if defined(HAVE_FILE_VERSIONS)
33 MY_STAT my_stat_result;
35 if (my_stat(to,&my_stat_result,MYF(0)))
39 if (MyFlags & MY_FAE+MY_WME)
41 char errbuf[MYSYS_STRERROR_SIZE];
42 my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG), from, to,
43 my_errno, my_strerror(errbuf,
sizeof(errbuf), my_errno));
51 if(!MoveFileEx(from, to, MOVEFILE_COPY_ALLOWED|
52 MOVEFILE_REPLACE_EXISTING))
54 my_osmaperr(GetLastError());
61 if (MyFlags & (MY_FAE+MY_WME))
63 char errbuf[MYSYS_STRERROR_SIZE];
64 my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG), from, to,
65 my_errno, my_strerror(errbuf,
sizeof(errbuf), my_errno));
68 else if (MyFlags & MY_SYNC_DIR)
70 #ifdef NEED_EXPLICIT_SYNC_DIR
72 char dir_from[FN_REFLEN], dir_to[FN_REFLEN];
73 size_t dir_from_length, dir_to_length;
74 dirname_part(dir_from, from, &dir_from_length);
75 dirname_part(dir_to, to, &dir_to_length);
76 if (my_sync_dir(dir_from, MyFlags) ||
77 (strcmp(dir_from, dir_to) &&
78 my_sync_dir(dir_to, MyFlags)))