diff options
author | unknown <lars@mysql.com> | 2006-06-28 15:27:25 +0200 |
---|---|---|
committer | unknown <lars@mysql.com> | 2006-06-28 15:27:25 +0200 |
commit | 508e3704336ec6ce7f762c55e90594d11c8bdaf0 (patch) | |
tree | 406052829c79d452b36a2ec1ce54e80e9f00f989 /mysys | |
parent | 725ab9df20675b2d58044a6c7149785d9187dae6 (diff) | |
parent | 1fdccc89032524d51085f888a0d2356f7b6ebbfe (diff) | |
download | mariadb-git-508e3704336ec6ce7f762c55e90594d11c8bdaf0.tar.gz |
Merge mysql.com:/users/lthalmann/bk/mysql-5.0-rpl
into mysql.com:/users/lthalmann/bk/mysql-5.1-new-rpl
BitKeeper/deleted/.del-mysys.vcproj~40a49d09c4184822:
Auto merged
mysql-test/t/rpl_openssl.test:
Auto merged
sql/log.cc:
Auto merged
BitKeeper/deleted/.del-mysql.sln~76a9ff1e793b3547:
Deleted file in 5.1 (removed)
BitKeeper/deleted/.del-mysqld.vcproj~6aa7b3f9c3e28fcb:
Deleted file in 5.1 (removed)
include/my_sys.h:
Manual merge
mysql-test/mysql-test-run.pl:
Manual merge
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_delete.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mysys/my_delete.c b/mysys/my_delete.c index 5670f03da64..de2a9814a56 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -32,3 +32,54 @@ int my_delete(const char *name, myf MyFlags) } DBUG_RETURN(err); } /* my_delete */ + +#if defined(__WIN__) && defined(__NT__) +/* + Delete file which is possibly not closed. + + This function is intended to be used exclusively as a temporal solution + for Win NT in case when it is needed to delete a not closed file (note + that the file must be opened everywhere with FILE_SHARE_DELETE mode). + Deleting not-closed files can not be supported on Win 98|ME (and because + of that is considered harmful). + + The function deletes the file with its preliminary renaming. This is + because when not-closed share-delete file is deleted it still lives on + a disk until it will not be closed everwhere. This may conflict with an + attempt to create a new file with the same name. The deleted file is + 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. +*/ +int nt_share_delete(const char *name, myf MyFlags) +{ + char buf[MAX_PATH + 20]; + ulong cnt; + DBUG_ENTER("nt_share_delete"); + DBUG_PRINT("my",("name %s MyFlags %d", name, MyFlags)); + + for (cnt= GetTickCount(); cnt; cnt--) + { + sprintf(buf, "%s.%08X.deleted", name, cnt); + if (MoveFile(name, buf)) + break; + + if ((errno= GetLastError()) == ERROR_ALREADY_EXISTS) + continue; + + DBUG_PRINT("warning", ("Failed to rename %s to %s, errno: %d", + name, buf, errno)); + break; + } + + if (DeleteFile(buf)) + DBUG_RETURN(0); + + my_errno= GetLastError(); + if (MyFlags & (MY_FAE+MY_WME)) + my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), + name, my_errno); + + DBUG_RETURN(-1); +} +#endif |