purge remaining gpl code from clib, and make clib build again
[tangerine.git] / compiler / clib / stat.c
blob88a92ce2c7ce96048448432141f3992575159ee9
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dos.h>
7 #include <proto/dos.h>
9 #include <errno.h>
11 #include "__time.h"
12 #include "__errno.h"
13 #include "__stat.h"
14 #include "__upath.h"
16 #include <sys/stat.h>
18 int stat(const char *path, struct stat *sb)
20 int res = 0;
21 BPTR lock;
23 path = __path_u2a(path);
24 if (path == NULL)
25 return -1;
27 lock = Lock(path, SHARED_LOCK);
28 if (!lock)
30 if (IoErr() == ERROR_OBJECT_IN_USE)
32 /* the file is already locked exclusively, so the only way to get
33 info about it is to find it in the parent directoy with the ExNext() function
36 /* return an error for now */
37 errno = EACCES;
38 return -1;
41 errno = IoErr2errno(IoErr());
42 return -1;
44 else
45 res = __stat(lock, sb);
47 UnLock(lock);
49 return res;