* Use same BLI_exist() on all platforms.

* remove extra sys/types.h include.
This commit is contained in:
Nathan Letwory
2010-07-14 23:39:23 +00:00
parent aa15c8a5bf
commit 0980f2555f
2 changed files with 11 additions and 14 deletions

View File

@@ -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];

View File

@@ -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);