Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/storage.c')
-rw-r--r--source/blender/blenlib/intern/storage.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 3315e9645d4..80310b1ef8a 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -237,8 +237,19 @@ void BLI_builddir(char *dirname, char *relname)
if (newnum){
- if (files) files=(struct direntry *)realloc(files,(totnum+newnum) * sizeof(struct direntry));
- else files=(struct direntry *)malloc(newnum * sizeof(struct direntry));
+ if(files) {
+ void *tmp= realloc(files, (totnum+newnum) * sizeof(struct direntry));
+ if(tmp) {
+ files= (struct direntry *)tmp;
+ }
+ else { /* realloc fail */
+ free(files);
+ files= NULL;
+ }
+ }
+
+ if(files==NULL)
+ files=(struct direntry *)malloc(newnum * sizeof(struct direntry));
if (files){
dlink = (struct dirlink *) dirbase->first;
@@ -250,6 +261,8 @@ void BLI_builddir(char *dirname, char *relname)
// Excluding other than current MSVC compiler until able to test.
#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500)
_stat64(dlink->name,&files[actnum].s);
+#elif defined(__MINGW32__)
+ _stati64(dlink->name,&files[actnum].s);
#else
stat(dlink->name,&files[actnum].s);
#endif
@@ -432,7 +445,7 @@ int BLI_filepathsize(const char *path)
int BLI_exist(char *name)
{
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
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
@@ -444,6 +457,15 @@ int BLI_exist(char *name)
if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0';
res = _stat(tmp, &st);
if (res == -1) return(0);
+#elif defined(__MINGW32__)
+ struct _stati64 st;
+ char tmp[FILE_MAXDIR+FILE_MAXFILE];
+ 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';
+ res = _stati64(tmp, &st);
+ if (res) return(0);
#else
struct stat st;
if (stat(name,&st)) return(0);