diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-07-04 11:43:34 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-07-05 02:04:03 +0200 |
commit | f79026b4912bcd2336667f4c1663c06e233f0b32 (patch) | |
tree | 645b776032e924b587fad986aa3f3dc08c98d4c5 /src/posix.h | |
parent | 678e9e045becdc5d75f2ce2259ed01c3531ee181 (diff) | |
download | libgit2-f79026b4912bcd2336667f4c1663c06e233f0b32.tar.gz |
fileops: Cleanup
Cleaned up the structure of the whole OS-abstraction layer.
fileops.c now contains a set of utility methods for file management used
by the library. These are abstractions on top of the original POSIX
calls.
There's a new file called `posix.c` that contains
emulations/reimplementations of all the POSIX calls the library uses.
These are prefixed with `p_`. There's a specific posix file for each
platform (win32 and unix).
All the path-related methods have been moved from `utils.c` to `path.c`
and have their own prefix.
Diffstat (limited to 'src/posix.h')
-rw-r--r-- | src/posix.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/posix.h b/src/posix.h new file mode 100644 index 000000000..eaa89383d --- /dev/null +++ b/src/posix.h @@ -0,0 +1,54 @@ +/* + * posix.h - OS agnostic POSIX calls + */ +#ifndef INCLUDE_posix_h__ +#define INCLUDE_posix_h__ + +#include "common.h" +#include <fcntl.h> +#include <time.h> + +#ifdef GIT_WIN32 +# include "win32/posix.h" +#else +# include "unix/posix.h" +#endif + +#define S_IFGITLINK 0160000 +#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK) + +#if !defined(O_BINARY) +#define O_BINARY 0 +#endif + +typedef int git_file; + + +/** + * Standard POSIX Methods + * + * All the methods starting with the `p_` prefix are + * direct ports of the standard POSIX methods. + * + * Some of the methods are slightly wrapped to provide + * saner defaults. Some of these methods are emulated + * in Windows platforns. + * + * Use your manpages to check the docs on these. + * Straightforward + */ +extern int p_open(const char *path, int flags); +extern int p_creat(const char *path, int mode); +extern int p_read(git_file fd, void *buf, size_t cnt); +extern int p_write(git_file fd, void *buf, size_t cnt); +extern int p_getcwd(char *buffer_out, size_t size); + +#define p_lseek(f,n,w) lseek(f, n, w) +#define p_stat(p,b) stat(p, b) +#define p_fstat(f,b) fstat(f, b) +#define p_chdir(p) chdir(p) +#define p_rmdir(p) rmdir(p) +#define p_chmod(p,m) chmod(p, m) +#define p_close(fd) close(fd) + +#endif |