[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47502] branches/soc-2012-swiss_cheese/ source/blender/blenlib: In BLI_fileops.c, rewrite stat to _stat and fstat to _fstat on Windows so that the correct version for the bitness of the OS can be chosen .
Jason Wilkins
Jason.A.Wilkins at gmail.com
Wed Jun 6 09:10:02 CEST 2012
Revision: 47502
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47502
Author: jwilkins
Date: 2012-06-06 07:10:01 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
In BLI_fileops.c, rewrite stat to _stat and fstat to _fstat on Windows so that the correct version for the bitness of the OS can be chosen.
The changes to intern/storage.c are just whitespace.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/blender/blenlib/BLI_fileops.h
branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/storage.c
Modified: branches/soc-2012-swiss_cheese/source/blender/blenlib/BLI_fileops.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenlib/BLI_fileops.h 2012-06-06 07:03:15 UTC (rev 47501)
+++ branches/soc-2012-swiss_cheese/source/blender/blenlib/BLI_fileops.h 2012-06-06 07:10:01 UTC (rev 47502)
@@ -55,8 +55,15 @@
int BLI_delete(const char *path, int dir, int 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
+#undef stat
+#define stat _stat
+#define fstat _fstat
+#endif
+
+int BLI_stat(const char *path, struct stat *buffer);
+
/* Directories */
struct direntry;
Modified: branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/storage.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/storage.c 2012-06-06 07:03:15 UTC (rev 47501)
+++ branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/storage.c 2012-06-06 07:10:01 UTC (rev 47502)
@@ -446,22 +446,30 @@
size_t BLI_file_descriptor_size(int file)
{
- struct stat buf;
+ if (file > 0) {
+ struct stat buf;
- if (file <= 0) return (-1);
- fstat(file, &buf); /* CHANGE */
- return (buf.st_size);
+ fstat(file, &buf);
+
+ return (buf.st_size);
+ }
+ else {
+ return -1;
+ }
}
size_t BLI_file_size(const char *path)
{
int size, file = BLI_open(path, O_BINARY | O_RDONLY, 0);
-
- if (file == -1)
+
+ if (file == -1) {
return -1;
-
+ }
+
size = BLI_file_descriptor_size(file);
+
close(file);
+
return size;
}
More information about the Bf-blender-cvs
mailing list