[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55041] trunk/blender/source/blender: patch [#34103] path_util_cleanups.patch
Campbell Barton
ideasman42 at gmail.com
Tue Mar 5 05:35:14 CET 2013
Revision: 55041
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55041
Author: campbellbarton
Date: 2013-03-05 04:35:14 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
patch [#34103] path_util_cleanups.patch
from Lawrence D'Oliveiro (ldo)
- Better argument name for BLI_cleanup_path and BLI_cleanup_file
- remove redundant BLI_add_slash already done by BLI_cleanup_dir
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_path_util.h
trunk/blender/source/blender/blenlib/intern/path_util.c
trunk/blender/source/blender/editors/space_file/file_ops.c
Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h 2013-03-05 04:24:53 UTC (rev 55040)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h 2013-03-05 04:35:14 UTC (rev 55041)
@@ -132,9 +132,9 @@
* converts it to a regular full path.
* Also removes garbage from directory paths, like /../ or double slashes etc
*/
-void BLI_cleanup_file(const char *relabase, char *dir); /* removes trailing slash */
+void BLI_cleanup_file(const char *relabase, char *path); /* removes trailing slash */
void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
-void BLI_cleanup_path(const char *relabase, char *dir); /* doesn't touch trailing slash */
+void BLI_cleanup_path(const char *relabase, char *path); /* doesn't touch trailing slash */
/* go back one directory */
bool BLI_parent_dir(char *path);
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2013-03-05 04:24:53 UTC (rev 55040)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2013-03-05 04:35:14 UTC (rev 55041)
@@ -350,19 +350,19 @@
* If relbase is NULL then its ignored
*/
-void BLI_cleanup_path(const char *relabase, char *dir)
+void BLI_cleanup_path(const char *relabase, char *path)
{
ptrdiff_t a;
char *start, *eind;
if (relabase) {
- BLI_path_abs(dir, relabase);
+ BLI_path_abs(path, relabase);
}
else {
- if (dir[0] == '/' && dir[1] == '/') {
- if (dir[2] == '\0') {
+ if (path[0] == '/' && path[1] == '/') {
+ if (path[2] == '\0') {
return; /* path is "//" - cant clean it */
}
- dir = dir + 2; /* skip the first // */
+ path = path + 2; /* skip the first // */
}
}
@@ -378,70 +378,70 @@
/* Note, this should really be moved to the file selector,
* since this function is used in many areas */
- if (strcmp(dir, ".") == 0) { /* happens for example in FILE_MAIN */
- get_default_root(dir);
+ if (strcmp(path, ".") == 0) { /* happens for example in FILE_MAIN */
+ get_default_root(path);
return;
}
- while ( (start = strstr(dir, "\\..\\")) ) {
+ while ( (start = strstr(path, "\\..\\")) ) {
eind = start + strlen("\\..\\") - 1;
- a = start - dir - 1;
+ a = start - path - 1;
while (a > 0) {
- if (dir[a] == '\\') break;
+ if (path[a] == '\\') break;
a--;
}
if (a < 0) {
break;
}
else {
- memmove(dir + a, eind, strlen(eind) + 1);
+ memmove(path + a, eind, strlen(eind) + 1);
}
}
- while ( (start = strstr(dir, "\\.\\")) ) {
+ while ( (start = strstr(path, "\\.\\")) ) {
eind = start + strlen("\\.\\") - 1;
memmove(start, eind, strlen(eind) + 1);
}
- while ( (start = strstr(dir, "\\\\")) ) {
+ while ( (start = strstr(path, "\\\\")) ) {
eind = start + strlen("\\\\") - 1;
memmove(start, eind, strlen(eind) + 1);
}
#else
- if (dir[0] == '.') { /* happens, for example in FILE_MAIN */
- dir[0] = '/';
- dir[1] = 0;
+ if (path[0] == '.') { /* happens, for example in FILE_MAIN */
+ path[0] = '/';
+ path[1] = 0;
return;
}
/* support for odd paths: eg /../home/me --> /home/me
* this is a valid path in blender but we cant handle this the usual way below
* simply strip this prefix then evaluate the path as usual. pythons os.path.normpath() does this */
- while ((strncmp(dir, "/../", 4) == 0)) {
- memmove(dir, dir + 4, strlen(dir + 4) + 1);
+ while ((strncmp(path, "/../", 4) == 0)) {
+ memmove(path, path + 4, strlen(path + 4) + 1);
}
- while ( (start = strstr(dir, "/../")) ) {
+ while ( (start = strstr(path, "/../")) ) {
eind = start + (4 - 1) /* strlen("/../") - 1 */;
- a = start - dir - 1;
+ a = start - path - 1;
while (a > 0) {
- if (dir[a] == '/') break;
+ if (path[a] == '/') break;
a--;
}
if (a < 0) {
break;
}
else {
- memmove(dir + a, eind, strlen(eind) + 1);
+ memmove(path + a, eind, strlen(eind) + 1);
}
}
- while ( (start = strstr(dir, "/./")) ) {
+ while ( (start = strstr(path, "/./")) ) {
eind = start + (3 - 1) /* strlen("/./") - 1 */;
memmove(start, eind, strlen(eind) + 1);
}
- while ( (start = strstr(dir, "//")) ) {
+ while ( (start = strstr(path, "//")) ) {
eind = start + (2 - 1) /* strlen("//") - 1 */;
memmove(start, eind, strlen(eind) + 1);
}
@@ -455,10 +455,10 @@
}
-void BLI_cleanup_file(const char *relabase, char *dir)
+void BLI_cleanup_file(const char *relabase, char *path)
{
- BLI_cleanup_path(relabase, dir);
- BLI_del_slash(dir);
+ BLI_cleanup_path(relabase, path);
+ BLI_del_slash(path);
}
/**
Modified: trunk/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_ops.c 2013-03-05 04:24:53 UTC (rev 55040)
+++ trunk/blender/source/blender/editors/space_file/file_ops.c 2013-03-05 04:35:14 UTC (rev 55041)
@@ -1228,7 +1228,6 @@
}
BLI_cleanup_dir(G.main->name, sfile->params->dir);
- BLI_add_slash(sfile->params->dir);
file_change_dir(C, 1);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
More information about the Bf-blender-cvs
mailing list