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:
authorCampbell Barton <ideasman42@gmail.com>2008-02-27 12:48:43 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-02-27 12:48:43 +0300
commitb226eb925b7306486e55998c790a3376c177bbef (patch)
treef1775830fd326876292744a4ee2038de3c0e933c
parent7d310f4e5c9059a7e734d852424915e8aac7319e (diff)
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.
-rw-r--r--source/blender/blenlib/BLI_blenlib.h1
-rw-r--r--source/blender/blenlib/intern/fileops.c15
-rw-r--r--source/blender/python/BPY_menus.c16
3 files changed, 30 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index 39b679144d5..551b6732333 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -313,6 +313,7 @@ int BLI_move(char *file, char *to);
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 */
/**
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index fa76f2023eb..ad102bea80f 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -108,6 +108,21 @@ void BLI_add_slash(char *string) {
#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
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c
index ebbe301f453..44c2157ad3b 100644
--- a/source/blender/python/BPY_menus.c
+++ b/source/blender/python/BPY_menus.c
@@ -933,13 +933,25 @@ static int bpymenu_ParseDir(char *dirname, char *parentdir, int is_userdir )
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;