198f7d5b1e3c985030003d7673a796c1c8317d7f
[tpg/acess2.git] / Usermode / Libraries / libposix.so_src / stat.c
1 /*
2  * Acess2 POSIX Emulation Lib
3  * - By John Hodge (thePowersGang)
4  *
5  * sys/stat.h
6  * - stat(2)
7  */
8 #include <sys/stat.h>
9 #include <acess/sys.h>
10
11 // === CODE ===
12 int stat(const char *path, struct stat *buf)
13 {
14         int fd = _SysOpen(path, 0);
15         if( !fd ) {
16                 // errno is set by _SysOpen
17                 return -1;
18         }
19         
20         int rv = fstat(fd, buf);
21         _SysClose(fd);
22         return rv;
23 }
24
25 int lstat(const char *path, struct stat *buf)
26 {
27         int fd = _SysOpen(path, OPENFLAG_NOLINK);
28         if( !fd ) {
29                 // errno is set by _SysOpen
30                 return -1;
31         }
32         
33         int rv = fstat(fd, buf);
34         _SysClose(fd);
35         return rv;
36 }
37
38 int fstat(int fd, struct stat *buf)
39 {
40         t_sysFInfo      info;
41         
42         int rv = _SysFInfo(fd, &info, 0);
43         if( !rv ) {
44                 return -1;
45         }
46
47         // TODO: Populate buf
48         buf->st_mode = 0;
49 //      memset(buf, 0, sizeof(*buf));
50         
51         return 0;
52 }
53

UCC git Repository :: git.ucc.asn.au