[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13882] trunk/blender/source/blender: should fix bug on win32 with user python menu's not loading because stat() didnt like the trailing slash and returned the dir as missing.
Campbell Barton
ideasman42 at gmail.com
Wed Feb 27 10:48:43 CET 2008
Revision: 13882
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13882
Author: campbellbarton
Date: 2008-02-27 10:48:43 +0100 (Wed, 27 Feb 2008)
Log Message:
-----------
should fix bug on win32 with user python menu's not loading because stat() didnt like the trailing slash and returned the dir as missing.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_blenlib.h
trunk/blender/source/blender/blenlib/intern/fileops.c
trunk/blender/source/blender/python/BPY_menus.c
Modified: trunk/blender/source/blender/blenlib/BLI_blenlib.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_blenlib.h 2008-02-27 03:23:17 UTC (rev 13881)
+++ trunk/blender/source/blender/blenlib/BLI_blenlib.h 2008-02-27 09:48:43 UTC (rev 13882)
@@ -313,6 +313,7 @@
int BLI_touch(const char *file);
char *BLI_last_slash(const char *string);
void BLI_add_slash(char *string);
+void BLI_del_slash(char *string);
/* BLI_rct.c */
/**
Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c 2008-02-27 03:23:17 UTC (rev 13881)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c 2008-02-27 09:48:43 UTC (rev 13882)
@@ -108,6 +108,21 @@
#endif
}
+/* removes a slash if there is one */
+void BLI_del_slash(char *string) {
+ int len = strlen(string);
+ while (len) {
+#ifdef WIN32
+ if (string[len-1]=='\\') {
+#else
+ if (string[len-1]=='/') {
+#endif
+ string[len-1] = '\0';
+ len--;
+ }
+ }
+}
+
/* gzip the file in from and write it to "to".
return -1 if zlib fails, -2 if the originating file does not exist
note: will remove the "from" file
Modified: trunk/blender/source/blender/python/BPY_menus.c
===================================================================
--- trunk/blender/source/blender/python/BPY_menus.c 2008-02-27 03:23:17 UTC (rev 13881)
+++ trunk/blender/source/blender/python/BPY_menus.c 2008-02-27 09:48:43 UTC (rev 13882)
@@ -933,13 +933,25 @@
return 0;
}
-static int bpymenu_GetStatMTime( char *name, int is_file, time_t * mtime )
+static int bpymenu_GetStatMTime( const char *name, int is_file, time_t * mtime )
{
struct stat st;
int result;
+#ifdef win32
+ if (is_file) {
+ result = stat( name, &st );
+ } else {
+ /* needed for win32 only, remove trailing slash */
+ char name_stat[FILE_MAX];
+ BLI_strncpy(name_stat, name, FILE_MAX);
+ BLI_del_slash(name_stat);
+ result = stat( name_stat, &st );
+ }
+#else
result = stat( name, &st );
-
+#endif
+
if( result == -1 )
return -1;
More information about the Bf-blender-cvs
mailing list