diff options
author | Marc Alff <marc.alff@sun.com> | 2009-12-02 11:36:20 -0700 |
---|---|---|
committer | Marc Alff <marc.alff@sun.com> | 2009-12-02 11:36:20 -0700 |
commit | 203d9f1eabf9a324d8f98cf3d9897efb89fe92dd (patch) | |
tree | a3196948d575bfe8d7b3c149b77b172cb1129520 /mysys | |
parent | f2d67abbc0fe05d0b97a63127ffc7f85c892cf98 (diff) | |
parent | 0eda48463ce9c60408515819f9d954fd48567d4f (diff) | |
download | mariadb-git-203d9f1eabf9a324d8f98cf3d9897efb89fe92dd.tar.gz |
Merge mysql-next-mr (revno 2927) --> mysql-next-mr-marc
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_delete.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/mysys/my_delete.c b/mysys/my_delete.c index 3ab6ba399f9..edee1c4e875 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -37,7 +37,7 @@ int my_delete(const char *name, myf MyFlags) } /* my_delete */ #if defined(__WIN__) -/* +/** Delete file which is possibly not closed. This function is intended to be used exclusively as a temporal solution @@ -53,6 +53,20 @@ int my_delete(const char *name, myf MyFlags) renamed to <name>.<num>.deleted where <name> - the initial name of the file, <num> - a hexadecimal number chosen to make the temporal name to be unique. + + @param the name of the being deleted file + @param the flags instructing how to react on an error internally in + the function + + @note The per-thread @c my_errno holds additional info for a caller to + decide how critical the error can be. + + @retval + 0 ok + @retval + 1 error + + */ int nt_share_delete(const char *name, myf MyFlags) { @@ -63,6 +77,7 @@ int nt_share_delete(const char *name, myf MyFlags) for (cnt= GetTickCount(); cnt; cnt--) { + errno= 0; sprintf(buf, "%s.%08X.deleted", name, cnt); if (MoveFile(name, buf)) break; @@ -78,15 +93,23 @@ int nt_share_delete(const char *name, myf MyFlags) name, buf, errno)); break; } - - if (DeleteFile(buf)) - DBUG_RETURN(0); - - my_errno= GetLastError(); + + if (errno == ERROR_FILE_NOT_FOUND) + { + my_errno= ENOENT; // marking, that `name' doesn't exist + } + else if (errno == 0) + { + if (DeleteFile(buf)) + DBUG_RETURN(0); + else if ((my_errno= GetLastError()) == 0) + my_errno= ENOENT; // marking, that `buf' doesn't exist + } else + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), - name, my_errno); - + my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), + name, my_errno); DBUG_RETURN(-1); } #endif |