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-06-05 17:02:00 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-06-05 17:02:00 +0400
commit4f601b478c99ef9d74086e73a9eb38c9c598791d (patch)
tree9a1818119eb1fdff5a5643592a15135199461595 /source/blender/blenlib/intern/util.c
parentcc0d7309234e0c5444a101ce414e322f917628dc (diff)
* python sys.cleanpath() used strstr incorrectly, resulting in paths containing a slash, always returning a path that ends with a slash.
* python Blender.GetPaths() - absolute=0 wasnt working * BLI_cleanup_file and BLI_cleanup_file were treating the // prefix as a duplicate path, now ignores // * BLI_convertstringcode was removing the trailing slash from a path (tested these path functions didnt mess up with some of the peach files and with pointcache)
Diffstat (limited to 'source/blender/blenlib/intern/util.c')
-rw-r--r--source/blender/blenlib/intern/util.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index 3610813f2da..ad34af05ac7 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -865,11 +865,8 @@ int BLI_strcaseeq(char *a, char *b) {
void BLI_cleanup_dir(const char *relabase, char *dir)
{
BLI_cleanup_file(relabase, dir);
-#ifdef WIN32
- strcat(dir, "\\");
-#else
- strcat(dir, "/");
-#endif
+ BLI_add_slash(dir);
+
}
void BLI_cleanup_file(const char *relabase, char *dir)
@@ -878,6 +875,13 @@ void BLI_cleanup_file(const char *relabase, char *dir)
char *start, *eind;
if (relabase) {
BLI_convertstringcode(dir, relabase);
+ } else {
+ if (dir[0]=='/' && dir[1]=='/') {
+ if (dir[2]== '\0') {
+ return; /* path is "//" - cant clean it */
+ }
+ dir = dir+2; /* skip the first // */
+ }
}
#ifdef WIN32
if(dir[0]=='.') { /* happens for example in FILE_MAIN */
@@ -1150,24 +1154,30 @@ int BLI_convertstringcode(char *path, const char *basepath)
BLI_char_switch(tmp, '\\', '/');
BLI_char_switch(base, '\\', '/');
+ /* Paths starting with // will get the blend file as their base,
+ * this isnt standard in any os but is uesed in blender all over the place */
if (tmp[0] == '/' && tmp[1] == '/') {
- char *filepart= BLI_strdup(tmp+2); /* skip code */
char *lslash= BLI_last_slash(base);
-
if (lslash) {
int baselen= (int) (lslash-base) + 1;
-
+ /* use path for for temp storage here, we copy back over it right away */
+ BLI_strncpy(path, tmp+2, FILE_MAX);
+
memcpy(tmp, base, baselen);
- strcpy(tmp+baselen, filepart);
+ strcpy(tmp+baselen, path);
+ strcpy(path, tmp);
} else {
- strcpy(tmp, filepart);
+ strcpy(path, tmp+2);
}
-
- MEM_freeN(filepart);
+ } else {
+ strcpy(path, tmp);
}
- BLI_cleanup_file(NULL, tmp);
- strcpy(path, tmp);
+ if (path[strlen(path)-1]=='/') {
+ BLI_cleanup_dir(NULL, path);
+ } else {
+ BLI_cleanup_file(NULL, path);
+ }
#ifdef WIN32
/* skip first two chars, which in case of