Fixed handling for non existing files.
[reactos.git] / reactos / lib / msvcrt / sys_stat / stat.c
1 #include <msvcrt/sys/types.h>
2 #include <msvcrt/sys/stat.h>
3 #include <msvcrt/fcntl.h>
4 #include <msvcrt/io.h>
5
6
7 int _stat(const char *path, struct stat *buffer)
8 {
9 int fd = _open(path,_O_RDONLY);
10 int ret;
11
12 if (fd < 0)
13 return -1;
14
15 ret = fstat(fd,buffer);
16 _close(fd);
17
18 return ret;
19 }
20
21 __int64 _stati64 (const char *path, struct _stati64 *buffer)
22 {
23 int fd = _open(path,_O_RDONLY);
24 int ret;
25
26 ret = _fstati64(fd,buffer);
27 _close(fd);
28
29 return ret;
30 }
31
32 int _wstat (const wchar_t *path, struct stat *buffer)
33 {
34 int fd = _wopen(path,_O_RDONLY);
35 int ret;
36
37 ret = fstat(fd,buffer);
38 _close(fd);
39
40 return ret;
41 }
42
43 __int64 _wstati64 (const wchar_t *path, struct _stati64 *buffer)
44 {
45 int fd = _wopen(path,_O_RDONLY);
46 int ret;
47
48 ret = _fstati64(fd,buffer);
49 _close(fd);
50
51 return ret;
52 }