[Bf-blender-cvs] [973f95f] master: Fix T40157: Loading movies larger than 4GB in size fails

Sergey Sharybin noreply at git.blender.org
Wed May 28 19:27:12 CEST 2014


Commit: 973f95fa9dfb21e4347a510f119c55b9673f6076
Author: Sergey Sharybin
Date:   Wed May 28 22:50:40 2014 +0600
https://developer.blender.org/rB973f95fa9dfb21e4347a510f119c55b9673f6076

Fix T40157: Loading movies larger than 4GB in size fails

Issue was caused by _wstat returning EOVERFLOW error because
of file size didn't fit into stat structure which was using
long datatype.

The idea of this patch is to use _wstat64 and _stat64 structure
which is capable storing 64bit file sizes.

Made it a typedef for stat structure used by BLI_stat function
in order to make code easier to follow and avoid ifdefs all
over the place.

Additionally solved issue with BLI_exists which was wrongly
returning False in cases destination file is larger then 4GB.

===================================================================

M	source/blender/blenkernel/intern/bpath.c
M	source/blender/blenkernel/intern/packedFile.c
M	source/blender/blenkernel/intern/text.c
M	source/blender/blenlib/BLI_fileops.h
M	source/blender/blenlib/intern/storage.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/editors/space_text/text_ops.c
M	source/blender/imbuf/intern/thumbs.c
M	source/blender/imbuf/intern/util.c

===================================================================

diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index d088372..3fca58b 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -210,7 +210,7 @@ static int findFileRecursive(char *filename_new,
 	/* file searching stuff */
 	DIR *dir;
 	struct dirent *de;
-	struct stat status;
+	BLI_stat_t status;
 	char path[FILE_MAX];
 	int size;
 	bool found = false;
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index dafe5ca..d186b42 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -368,7 +368,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
 
 int checkPackedFile(const char *filename, PackedFile *pf)
 {
-	struct stat st;
+	BLI_stat_t st;
 	int ret_val, i, len, file;
 	char buf[4096];
 	char name[FILE_MAX];
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index b6d7e89..90687ef 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -667,7 +667,7 @@ void BKE_text_write(Text *text, const char *str) /* called directly from rna */
 
 int BKE_text_file_modified_check(Text *text)
 {
-	struct stat st;
+	BLI_stat_t st;
 	int result;
 	char file[FILE_MAX];
 
@@ -696,7 +696,7 @@ int BKE_text_file_modified_check(Text *text)
 
 void BKE_text_file_modified_ignore(Text *text)
 {
-	struct stat st;
+	BLI_stat_t st;
 	int result;
 	char file[FILE_MAX];
 
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 7c10e50..c032b60 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -59,7 +59,18 @@ int    BLI_rename(const char *from, const char *to);
 int    BLI_delete(const char *path, bool dir, bool recursive);
 int    BLI_move(const char *path, const char *to);
 int    BLI_create_symlink(const char *path, const char *to);
-int    BLI_stat(const char *path, struct stat *buffer);
+
+#ifdef WIN32
+#  ifndef __MINGW64__
+typedef struct _stat64 BLI_stat_t;
+#  else
+typedef struct stat BLI_stat_t;
+#endif
+#else
+typedef struct stat BLI_stat_t;
+#endif
+
+int    BLI_stat(const char *path, BLI_stat_t *buffer);
 
 /* Directories */
 
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 2c6fc9f..a5de107 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -460,7 +460,7 @@ size_t BLI_file_descriptor_size(int file)
  */
 size_t BLI_file_size(const char *path)
 {
-	struct stat stats;
+	BLI_stat_t stats;
 	if (BLI_stat(path, &stats) == -1)
 		return -1;
 	return stats.st_size;
@@ -474,7 +474,7 @@ int BLI_exists(const char *name)
 {
 #if defined(WIN32) 
 #ifndef __MINGW32__
-	struct _stat64i32 st;
+	struct _stat64 st;
 #else
 	struct _stati64 st;
 #endif
@@ -507,7 +507,7 @@ int BLI_exists(const char *name)
 	old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
 
 #ifndef __MINGW32__
-	res = _wstat(tmp_16, &st);
+	res = _wstat64(tmp_16, &st);
 #else
 	res = _wstati64(tmp_16, &st);
 #endif
@@ -525,14 +525,14 @@ int BLI_exists(const char *name)
 
 
 #ifdef WIN32
-int BLI_stat(const char *path, struct stat *buffer)
+int BLI_stat(const char *path, BLI_stat_t *buffer)
 {
 	int r;
 	UTF16_ENCODE(path);
 
 	/* workaround error in MinGW64 headers, normally, a wstat should work */
 #ifndef __MINGW64__
-	r = _wstat(path_16, buffer);
+	r = _wstat64(path_16, buffer);
 #else
 	r = _wstati64(path_16, buffer);
 #endif
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index e8371d7..81ab276 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -656,7 +656,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v))
 				}
 				else {
 					char path[FILE_MAX];
-					struct stat status;
+					BLI_stat_t status;
 					
 					BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
 
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 0263b6c..fcd6fb3 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -458,7 +458,7 @@ static void txt_write_file(Text *text, ReportList *reports)
 {
 	FILE *fp;
 	TextLine *tmp;
-	struct stat st;
+	BLI_stat_t st;
 	char filepath[FILE_MAX];
 	
 	BLI_strncpy(filepath, text->name, FILE_MAX);
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index b4c97a2..236d410 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -305,7 +305,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im
 	short tsize = 128;
 	short ex, ey;
 	float scaledx, scaledy;
-	struct stat info;
+	BLI_stat_t info;
 
 	switch (size) {
 		case THB_NORMAL:
@@ -472,7 +472,7 @@ ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
 {
 	char thumb[FILE_MAX];
 	char uri[URI_MAX];
-	struct stat st;
+	BLI_stat_t st;
 	ImBuf *img = NULL;
 	
 	if (BLI_stat(path, &st)) {
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index fbb2884..b912c3e 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -187,7 +187,7 @@ int IMB_ispic_type(const char *name)
 
 	unsigned char buf[HEADER_SIZE];
 	ImFileType *type;
-	struct stat st;
+	BLI_stat_t st;
 	int fp;
 
 	if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
@@ -391,7 +391,7 @@ static int isredcode(const char *filename)
 int imb_get_anim_type(const char *name)
 {
 	int type;
-	struct stat st;
+	BLI_stat_t st;
 
 	if (UTIL_DEBUG) printf("in getanimtype: %s\n", name);




More information about the Bf-blender-cvs mailing list