mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-23 01:10:12 +00:00
Add the git_move_file() function
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
This commit is contained in:
parent
4319860c60
commit
ca481fc4f1
@ -105,6 +105,19 @@ void gitfo_free_buf(gitfo_buf *obj)
|
|||||||
obj->data = NULL;
|
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)
|
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)
|
if (git__mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin) < 0)
|
||||||
|
@ -69,6 +69,7 @@ extern off_t gitfo_size(git_file fd);
|
|||||||
|
|
||||||
extern int gitfo_read_file(gitfo_buf *obj, const char *path);
|
extern int gitfo_read_file(gitfo_buf *obj, const char *path);
|
||||||
extern void gitfo_free_buf(gitfo_buf *obj);
|
extern void gitfo_free_buf(gitfo_buf *obj);
|
||||||
|
extern int gitfo_move_file(char *from, char *to);
|
||||||
|
|
||||||
#define gitfo_unlink(p) unlink(p)
|
#define gitfo_unlink(p) unlink(p)
|
||||||
#define gitfo_rmdir(p) rmdir(p)
|
#define gitfo_rmdir(p) rmdir(p)
|
||||||
|
Loading…
Reference in New Issue
Block a user