From 33127043b3ef8dd8dd695ba3613eaa104a80a56b Mon Sep 17 00:00:00 2001 From: Brodie Rao Date: Fri, 14 Oct 2011 14:18:02 -0700 Subject: fileops/posix: replace usage of "int mode" with "mode_t mode" Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t. --- src/posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/posix.c') diff --git a/src/posix.c b/src/posix.c index 1b85b053d..7cd0749b6 100644 --- a/src/posix.c +++ b/src/posix.c @@ -17,7 +17,7 @@ int p_open(const char *path, int flags) return open(path, flags | O_BINARY); } -int p_creat(const char *path, int mode) +int p_creat(const char *path, mode_t mode) { return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode); } -- cgit v1.2.1 From 0c49ec2d3b5bfc32d69d189b7dc69cc26beb6a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 7 Nov 2011 19:34:24 +0100 Subject: Implement p_rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto --- src/posix.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/posix.c') diff --git a/src/posix.c b/src/posix.c index 7cd0749b6..8c19588ee 100644 --- a/src/posix.c +++ b/src/posix.c @@ -39,6 +39,20 @@ int p_getcwd(char *buffer_out, size_t size) return GIT_SUCCESS; } +int p_rename(const char *from, const char *to) +{ + if (!link(from, to)) { + p_unlink(from); + return GIT_SUCCESS; + } + + if (!rename(from, to)) + return GIT_SUCCESS; + + return GIT_ERROR; + +} + #endif int p_read(git_file fd, void *buf, size_t cnt) -- cgit v1.2.1