]>
Commit | Line | Data |
---|---|---|
f79026b4 | 1 | /* |
bb742ede VM |
2 | * Copyright (C) 2009-2011 the libgit2 contributors |
3 | * | |
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. | |
f79026b4 VM |
6 | */ |
7 | #ifndef INCLUDE_posix_h__ | |
8 | #define INCLUDE_posix_h__ | |
9 | ||
10 | #include "common.h" | |
11 | #include <fcntl.h> | |
12 | #include <time.h> | |
13 | ||
f79026b4 VM |
14 | #define S_IFGITLINK 0160000 |
15 | #define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK) | |
16 | ||
17 | #if !defined(O_BINARY) | |
18 | #define O_BINARY 0 | |
19 | #endif | |
20 | ||
21 | typedef int git_file; | |
22 | ||
f79026b4 VM |
23 | /** |
24 | * Standard POSIX Methods | |
25 | * | |
26 | * All the methods starting with the `p_` prefix are | |
27 | * direct ports of the standard POSIX methods. | |
28 | * | |
29 | * Some of the methods are slightly wrapped to provide | |
30 | * saner defaults. Some of these methods are emulated | |
31 | * in Windows platforns. | |
32 | * | |
33 | * Use your manpages to check the docs on these. | |
34 | * Straightforward | |
35 | */ | |
7998ae5a | 36 | |
f79026b4 | 37 | extern int p_read(git_file fd, void *buf, size_t cnt); |
2ba222c5 | 38 | extern int p_write(git_file fd, const void *buf, size_t cnt); |
f79026b4 | 39 | |
7998ae5a | 40 | #define p_fstat(f,b) fstat(f, b) |
f79026b4 | 41 | #define p_lseek(f,n,w) lseek(f, n, w) |
7998ae5a PB |
42 | #define p_close(fd) close(fd) |
43 | ||
44 | extern int p_open(const char *path, int flags); | |
33127043 | 45 | extern int p_creat(const char *path, mode_t mode); |
7998ae5a PB |
46 | extern int p_getcwd(char *buffer_out, size_t size); |
47 | ||
48 | #ifndef GIT_WIN32 | |
49 | ||
f79026b4 | 50 | #define p_stat(p,b) stat(p, b) |
f79026b4 VM |
51 | #define p_chdir(p) chdir(p) |
52 | #define p_rmdir(p) rmdir(p) | |
53 | #define p_chmod(p,m) chmod(p, m) | |
dd44887a | 54 | #define p_access(p,m) access(p,m) |
7998ae5a PB |
55 | |
56 | #endif | |
f79026b4 | 57 | |
2fcf9c82 VM |
58 | /** |
59 | * Platform-dependent methods | |
60 | */ | |
61 | #ifdef GIT_WIN32 | |
62 | # include "win32/posix.h" | |
63 | #else | |
64 | # include "unix/posix.h" | |
65 | #endif | |
66 | ||
f79026b4 | 67 | #endif |