mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
Add Sys_isdir.
This commit is contained in:
parent
ad7834631c
commit
a611ad57de
2 changed files with 21 additions and 0 deletions
|
@ -59,6 +59,7 @@ typedef struct date_s {
|
||||||
} date_t;
|
} date_t;
|
||||||
|
|
||||||
int Sys_FileExists (const char *path);
|
int Sys_FileExists (const char *path);
|
||||||
|
int Sys_isdir (const char *path);
|
||||||
int Sys_mkdir (const char *path);
|
int Sys_mkdir (const char *path);
|
||||||
|
|
||||||
typedef void (*sys_printf_t) (const char *fmt, va_list args);
|
typedef void (*sys_printf_t) (const char *fmt, va_list args);
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef HAVE_SYS_TIME_H
|
#ifdef HAVE_SYS_TIME_H
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -160,6 +161,25 @@ Sys_MaskFPUExceptions (void)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
int
|
||||||
Sys_mkdir (const char *path)
|
Sys_mkdir (const char *path)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue