]> git.proxmox.com Git - libgit2.git/blame - src/posix.h
clar helper: don't dereference giterr_last() if it's NULL
[libgit2.git] / src / posix.h
CommitLineData
f79026b4 1/*
5e0de328 2 * Copyright (C) 2009-2012 the libgit2 contributors
bb742ede
VM
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
21typedef 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 37extern int p_read(git_file fd, void *buf, size_t cnt);
2ba222c5 38extern 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 42#define p_close(fd) close(fd)
ce8cd006 43#define p_umask(m) umask(m)
7998ae5a
PB
44
45extern int p_open(const char *path, int flags);
33127043 46extern int p_creat(const char *path, mode_t mode);
7998ae5a 47extern int p_getcwd(char *buffer_out, size_t size);
0c49ec2d 48extern int p_rename(const char *from, const char *to);
7998ae5a
PB
49
50#ifndef GIT_WIN32
51
f79026b4 52#define p_stat(p,b) stat(p, b)
f79026b4
VM
53#define p_chdir(p) chdir(p)
54#define p_rmdir(p) rmdir(p)
55#define p_chmod(p,m) chmod(p, m)
dd44887a 56#define p_access(p,m) access(p,m)
44ef8b1b
RB
57#define p_recv(s,b,l,f) recv(s,b,l,f)
58#define p_send(s,b,l,f) send(s,b,l,f)
59typedef int GIT_SOCKET;
60#define INVALID_SOCKET -1
61
62#else
63
64typedef SOCKET GIT_SOCKET;
7998ae5a
PB
65
66#endif
f79026b4 67
2fcf9c82
VM
68/**
69 * Platform-dependent methods
70 */
71#ifdef GIT_WIN32
72# include "win32/posix.h"
73#else
74# include "unix/posix.h"
75#endif
76
74fa4bfa
RB
77#define p_readdir_r(d,e,r) readdir_r(d,e,r)
78
f79026b4 79#endif