From b226eb925b7306486e55998c790a3376c177bbef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 27 Feb 2008 09:48:43 +0000 Subject: 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. --- source/blender/blenlib/BLI_blenlib.h | 1 + source/blender/blenlib/intern/fileops.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'source/blender/blenlib') 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 -- cgit v1.2.3