summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-11-07 19:34:24 +0100
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-11-07 20:34:27 +0100
commit0c49ec2d3b5bfc32d69d189b7dc69cc26beb6a92 (patch)
tree86fe3204cfbe9b2a09fcd4d22b1ddf24f51e7269 /src/fileops.c
parent38068dc1d3cf4a0f0dc2ce8c488a1de4621c04b5 (diff)
downloadlibgit2-0c49ec2d3b5bfc32d69d189b7dc69cc26beb6a92.tar.gz
Implement p_rename
Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/src/fileops.c b/src/fileops.c
index 2030c786d..955bb1bf6 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -8,29 +8,6 @@
#include "fileops.h"
#include <ctype.h>
-int git_futils_mv_atomic(const char *from, const char *to)
-{
-#ifdef GIT_WIN32
- /*
- * Win32 POSIX compilance my ass. If the destination
- * file exists, the `rename` call fails. This is as
- * close as it gets with the Win32 API.
- */
- return MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) ? GIT_SUCCESS : GIT_EOSERR;
-#else
- /* Don't even try this on Win32 */
- if (!link(from, to)) {
- p_unlink(from);
- return GIT_SUCCESS;
- }
-
- if (!rename(from, to))
- return GIT_SUCCESS;
-
- return GIT_ERROR;
-#endif
-}
-
int git_futils_mkpath2file(const char *file_path, const mode_t mode)
{
int error = GIT_SUCCESS;
@@ -216,7 +193,7 @@ int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmod
if (git_futils_mkpath2file(to, dirmode) < GIT_SUCCESS)
return GIT_EOSERR; /* The callee already takes care of setting the correct error message. */
- return git_futils_mv_atomic(from, to); /* The callee already takes care of setting the correct error message. */
+ return p_rename(from, to); /* The callee already takes care of setting the correct error message. */
}
int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len)