Win32: Add win32 rename function that overwrites existing targets.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Klaas Freitag 2012-03-29 13:43:39 +02:00 committed by Andreas Schneider
parent 0bedd5d9a3
commit 44a078b991

View file

@ -338,6 +338,18 @@ int csync_vio_local_stat(const char *uri, csync_vio_file_stat_t *buf) {
}
int csync_vio_local_rename(const char *olduri, const char *newuri) {
#ifdef _WIN32
if(olduri && newuri) {
if (MoveFileEx(olduri, newuri, MOVEFILE_COPY_ALLOWED + MOVEFILE_REPLACE_EXISTING + MOVEFILE_WRITE_THROUGH )) {
return 0;
}
errno = GetLastError();
} else {
errno = ENOENT;
}
return -1;
#endif
return rename(olduri, newuri);
}