summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/posix.h1
-rw-r--r--src/win32/posix_w32.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 7b5553061..ae6323679 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -48,5 +48,6 @@ extern int p_fsync(int fd);
extern int p_open(const char *path, int flags);
extern int p_creat(const char *path, mode_t mode);
extern int p_getcwd(char *buffer_out, size_t size);
+extern int p_rename(const char *from, const char *to);
#endif
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 4b1b0074d..6f722581e 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -388,3 +388,17 @@ int p_access(const char* path, mode_t mode)
return ret;
}
+
+extern int p_rename(const char *from, const char *to)
+{
+ wchar_t *wfrom = gitwin_to_utf16(from);
+ wchar_t *wto = gitwin_to_utf16(to);
+ int ret;
+
+ ret = MoveFileExW(wfrom, wto, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) ? GIT_SUCCESS : GIT_EOSERR;
+
+ git__free(wfrom);
+ git__free(wto);
+
+ return ret;
+}