]> git.proxmox.com Git - libgit2.git/blob - src/posix.h
Merge pull request #399 from carlosmn/free-null
[libgit2.git] / src / posix.h
1 /*
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.
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
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
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 */
36 extern int p_open(const char *path, int flags);
37 extern int p_creat(const char *path, int mode);
38 extern int p_read(git_file fd, void *buf, size_t cnt);
39 extern int p_write(git_file fd, const void *buf, size_t cnt);
40 extern int p_getcwd(char *buffer_out, size_t size);
41
42 #define p_lseek(f,n,w) lseek(f, n, w)
43 #define p_stat(p,b) stat(p, b)
44 #define p_fstat(f,b) fstat(f, b)
45 #define p_chdir(p) chdir(p)
46 #define p_rmdir(p) rmdir(p)
47 #define p_chmod(p,m) chmod(p, m)
48 #define p_close(fd) close(fd)
49
50 /**
51 * Platform-dependent methods
52 */
53 #ifdef GIT_WIN32
54 # include "win32/posix.h"
55 #else
56 # include "unix/posix.h"
57 #endif
58
59 #endif