Pyrogenesis  trunk
wfilesystem.h
Go to the documentation of this file.
1 /* Copyright (C) 2010 Wildfire Games.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef INCLUDED_WFILESYSTEM
24 #define INCLUDED_WFILESYSTEM
25 
26 //
27 // sys/stat.h
28 //
29 
30 #include <sys/stat.h> // for S_IFREG etc.
31 
32 #if MSC_VERSION
33 typedef unsigned int mode_t; // defined by MinGW but not VC
34 #define stat _stat64 // we need 64-bit st_size and time_t
35 #endif
36 
37 // permission masks when creating files (_wsopen_s doesn't distinguish
38 // between owner/user/group)
39 #define S_IRUSR _S_IREAD
40 #define S_IRGRP _S_IREAD
41 #define S_IROTH _S_IREAD
42 #define S_IWUSR _S_IWRITE
43 #define S_IWGRP _S_IWRITE
44 #define S_IWOTH _S_IWRITE
45 #define S_IXUSR 0
46 #define S_IXGRP 0
47 #define S_IXOTH 0
48 #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
49 #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
50 #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
51 
52 #define S_ISDIR(m) (m & S_IFDIR)
53 #define S_ISREG(m) (m & S_IFREG)
54 
55 
56 //
57 // <unistd.h>
58 //
59 
60 extern int read (int fd, void* buf, size_t nbytes); // thunk
61 extern int write(int fd, void* buf, size_t nbytes); // thunk
62 extern off_t lseek(int fd, off_t ofs, int whence); // thunk
63 
64 #endif // #ifndef INCLUDED_WFILESYSTEM
off_t lseek(int fd, off_t ofs, int whence)
Definition: wfilesystem.cpp:274
__int64 off_t
Definition: wposix_types.h:91
int read(int fd, void *buf, size_t nbytes)
Definition: wfilesystem.cpp:264
int write(int fd, void *buf, size_t nbytes)
Definition: wfilesystem.cpp:269