Add Sys_isdir.

This commit is contained in:
Bill Currie 2013-02-20 13:59:31 +09:00
parent ad7834631c
commit a611ad57de
2 changed files with 21 additions and 0 deletions

View file

@ -59,6 +59,7 @@ typedef struct date_s {
} date_t;
int Sys_FileExists (const char *path);
int Sys_isdir (const char *path);
int Sys_mkdir (const char *path);
typedef void (*sys_printf_t) (const char *fmt, va_list args);

View file

@ -66,6 +66,7 @@
#include <fcntl.h>
#include <stdarg.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
@ -160,6 +161,25 @@ Sys_MaskFPUExceptions (void)
}
#endif
int
Sys_isdir (const char *path)
{
int res;
#ifdef _WIN32
struct _stat st;
res = _stat (path, &st);
#else
struct stat st;
res = stat (path, &st);
#endif
if (res < 0) {
// assume any error means path does not refer to a directory. certainly
// true if errno == ENOENT
return 0;
}
return S_ISDIR (st.st_mode);
}
int
Sys_mkdir (const char *path)
{