* Use same BLI_exist() on all platforms.
* remove extra sys/types.h include.
This commit is contained in:
@@ -205,6 +205,10 @@ int BLI_touch(const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BLI_exists(char *file) {
|
||||
return BLI_exist(file);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
static char str[MAXPATHLEN+12];
|
||||
@@ -282,10 +286,6 @@ int BLI_link(char *file, char *to) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BLI_exists(char *file) {
|
||||
return (GetFileAttributes(file) != 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void BLI_recurdir_fileops(char *dirname) {
|
||||
char *lslash;
|
||||
char tmp[MAXPATHLEN];
|
||||
@@ -326,10 +326,10 @@ int BLI_rename(char *from, char *to) {
|
||||
return rename(from, to);
|
||||
}
|
||||
|
||||
#else /* The sane UNIX world */
|
||||
#else /* The weirdo UNIX world */
|
||||
|
||||
/*
|
||||
* but the sane UNIX world is tied to the interface, and the system
|
||||
* but the UNIX world is tied to the interface, and the system
|
||||
* timer, and... We implement a callback mechanism. The system will
|
||||
* have to initialise the callback before the functions will work!
|
||||
* */
|
||||
@@ -374,10 +374,6 @@ int BLI_link(char *file, char *to) {
|
||||
return system(str);
|
||||
}
|
||||
|
||||
int BLI_exists(char *file) {
|
||||
return BLI_exist(file);
|
||||
}
|
||||
|
||||
void BLI_recurdir_fileops(char *dirname) {
|
||||
char *lslash;
|
||||
char tmp[MAXPATHLEN];
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <sys/types.h>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include "BLI_winstuff.h"
|
||||
@@ -433,18 +432,20 @@ int BLI_filepathsize(const char *path)
|
||||
|
||||
int BLI_exist(char *name)
|
||||
{
|
||||
struct stat st;
|
||||
#ifdef WIN32
|
||||
struct _stat64i32 st;
|
||||
/* in Windows stat doesn't recognize dir ending on a slash
|
||||
To not break code where the ending slash is expected we
|
||||
don't mess with the argument name directly here - elubie */
|
||||
char tmp[FILE_MAXDIR+FILE_MAXFILE];
|
||||
int len;
|
||||
int len, res;
|
||||
BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE);
|
||||
len = strlen(tmp);
|
||||
if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
|
||||
if (stat(tmp,&st)) return(0);
|
||||
res = _stat(tmp, &st);
|
||||
if (res == -1) return(0);
|
||||
#else
|
||||
struct stat st;
|
||||
if (stat(name,&st)) return(0);
|
||||
#endif
|
||||
return(st.st_mode);
|
||||
|
||||
Reference in New Issue
Block a user