diff options
author | Andrey Nazarov <skuller@skuller.net> | 2012-11-12 18:17:44 +0400 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2012-11-12 18:17:44 +0400 |
commit | 681f6dc2a30d7d24d7f9c40e5b4a6e2cd5b97c78 (patch) | |
tree | b6c5a3d13bf192044630cbb39c650aed132558b3 /inc/shared | |
parent | 5ae5fa3733e1291a88beb6413f771ee8c32f1c2b (diff) |
Move OS-specific defines into appropriate header.
Also define os_access() and its mode flags.
Diffstat (limited to 'inc/shared')
-rw-r--r-- | inc/shared/platform.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/inc/shared/platform.h b/inc/shared/platform.h index a7c8cb8..2f19deb 100644 --- a/inc/shared/platform.h +++ b/inc/shared/platform.h @@ -1,3 +1,35 @@ +/* +Copyright (C) 2012 Andrey Nazarov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +// +// platform.h -- platform-specific definitions +// + +#include <sys/types.h> +#include <sys/stat.h> + +#ifdef _WIN32 +#include <io.h> +#include <direct.h> +#else +#include <unistd.h> +#endif + #ifdef _WIN32 #define PRIz "Iu" #else @@ -18,6 +50,35 @@ #define PATH_SEP_STRING "/" #endif +#ifdef _WIN32 +#define os_mkdir(p) _mkdir(p) +#define os_unlink(p) _unlink(p) +#define os_stat(p, s) _stat(p, s) +#define os_fstat(f, s) _fstat(f, s) +#define os_fileno(f) _fileno(f) +#define os_access(p, m) _access(p, m) +#define Q_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#define Q_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#define Q_STATBUF struct _stat +#else +#define os_mkdir(p) mkdir(p, 0775) +#define os_unlink(p) unlink(p) +#define os_stat(p, s) stat(p, s) +#define os_fstat(f, s) fstat(f, s) +#define os_fileno(f) fileno(f) +#define os_access(p, m) access(p, m) +#define Q_ISREG(m) S_ISREG(m) +#define Q_ISDIR(m) S_ISDIR(m) +#define Q_STATBUF struct stat +#endif + +#ifndef F_OK +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#endif + #ifdef __GNUC__ #define q_printf(f, a) __attribute__((format(printf, f, a))) |