]>
git.proxmox.com Git - libgit2.git/blob - src/posix.c
2 * Copyright (C) 2009-2012 the libgit2 contributors
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
15 int p_open(const char *path
, int flags
)
17 return open(path
, flags
| O_BINARY
);
20 int p_creat(const char *path
, mode_t mode
)
22 return open(path
, O_WRONLY
| O_CREAT
| O_TRUNC
| O_BINARY
, mode
);
25 int p_getcwd(char *buffer_out
, size_t size
)
29 assert(buffer_out
&& size
> 0);
31 cwd_buffer
= getcwd(buffer_out
, size
);
33 if (cwd_buffer
== NULL
)
36 git_path_mkposix(buffer_out
);
37 git_path_string_to_dir(buffer_out
, size
); //Ensure the path ends with a trailing slash
42 int p_rename(const char *from
, const char *to
)
44 if (!link(from
, to
)) {
49 if (!rename(from
, to
))
57 int p_read(git_file fd
, void *buf
, size_t cnt
)
61 ssize_t r
= read(fd
, b
, cnt
);
63 if (errno
== EINTR
|| errno
== EAGAIN
)
72 return (int)(b
- (char *)buf
);
75 int p_write(git_file fd
, const void *buf
, size_t cnt
)
79 ssize_t r
= write(fd
, b
, cnt
);
81 if (errno
== EINTR
|| errno
== EAGAIN
)