]>
git.proxmox.com Git - libgit2.git/blob - src/posix.c
2 * Copyright (C) 2009-2011 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.
13 int p_open(const char *path
, int flags
)
15 return open(path
, flags
| O_BINARY
);
18 int p_creat(const char *path
, int mode
)
20 return open(path
, O_WRONLY
| O_CREAT
| O_TRUNC
| O_BINARY
, mode
);
23 int p_read(git_file fd
, void *buf
, size_t cnt
)
27 ssize_t r
= read(fd
, b
, cnt
);
29 if (errno
== EINTR
|| errno
== EAGAIN
)
38 return (int)(b
- (char *)buf
);
41 int p_write(git_file fd
, const void *buf
, size_t cnt
)
45 ssize_t r
= write(fd
, b
, cnt
);
47 if (errno
== EINTR
|| errno
== EAGAIN
)
61 int p_getcwd(char *buffer_out
, size_t size
)
65 assert(buffer_out
&& size
> 0);
68 cwd_buffer
= _getcwd(buffer_out
, size
);
70 cwd_buffer
= getcwd(buffer_out
, size
);
73 if (cwd_buffer
== NULL
)
74 return git__throw(GIT_EOSERR
, "Failed to retrieve current working directory");
76 git_path_mkposix(buffer_out
);
78 git_path_join(buffer_out
, buffer_out
, ""); //Ensure the path ends with a trailing slash