diff options
| author | Ramsay Jones <ramsay@ramsay1.demon.co.uk> | 2009-06-04 16:46:54 +0100 |
|---|---|---|
| committer | Andreas Ericsson <ae@op5.se> | 2009-06-05 10:21:52 +0200 |
| commit | ca481fc4f12cec56b71bd50ae72e3f088b69021f (patch) | |
| tree | d0fdf2dcff2f548952eec536ccc6d266550041bc /src/fileops.c | |
| parent | 4319860c60d84ec2513be34ee1a65dec5eceb6c4 (diff) | |
| download | libgit2-ca481fc4f12cec56b71bd50ae72e3f088b69021f.tar.gz | |
Add the git_move_file() function
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/fileops.c b/src/fileops.c index 581dc350d..3d35c193f 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -105,6 +105,19 @@ void gitfo_free_buf(gitfo_buf *obj) obj->data = NULL; } +int gitfo_move_file(char *from, char *to) +{ + if (!link(from, to)) { + gitfo_unlink(from); + return GIT_SUCCESS; + } + + if (!rename(from, to)) + return GIT_SUCCESS; + + return git_os_error(); +} + int gitfo_map_ro(git_map *out, git_file fd, off_t begin, size_t len) { if (git__mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin) < 0) |
