Page Menu
Home
Search
Configure Global Search
Log In
Files
F22206
path_util_cleanups.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Lawrence D'Oliveiro (ldo)
Nov 13 2013, 4:42 PM
Size
5 KB
Subscribers
None
path_util_cleanups.patch
View Options
commit c763c6705dcd67754647e4cdb6de164432516265
Author: Lawrence D'Oliveiro <ldo@geek-central.gen.nz>
Date: Tue Feb 19 23:24:38 2013 +0000
Better argument name for BLI_cleanup_path and BLI_cleanup_file
remove redundant BLI_add_slash already done by BLI_cleanup_dir
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 7d9a998..b380702 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -131,9 +131,9 @@ __attribute__((nonnull(1)))
* 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);
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 9014571..4be125c 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -334,19 +334,19 @@ void BLI_uniquename
* 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; /* leave the initial "//" untouched */
+ path += 2; /* leave the initial "//" untouched */
}
}
@@ -362,52 +362,52 @@ void BLI_cleanup_path(const char *relabase, char *dir)
/* 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;
}
- while ( (start = strstr(dir, "/../")) ) {
- a = start - dir - 1;
+ while ( (start = strstr(path, "/../")) ) {
+ a = start - path - 1;
if (a > 0)
{
/* <prefix>/<parent>/../<postfix> => <prefix>/<postfix> */
eind = start + (4 - 1) /* strlen("/../") - 1 */; /* strip "/.." and keep last "/" */
- while (a > 0 && dir[a] != '/') { /* find start of <parent> */
+ while (a > 0 && path[a] != '/') { /* find start of <parent> */
a--;
}
- memmove(dir + a, eind, strlen(eind) + 1);
+ memmove(path + a, eind, strlen(eind) + 1);
}
else
{
@@ -419,16 +419,16 @@ void BLI_cleanup_path(const char *relabase, char *dir)
which meant that the "/../home/me" example actually became "home/me".
Using offset of 3 gives behaviour consistent with the abovementioned
Python routine. */
- memmove(dir, dir + 3, strlen(dir + 3) + 1);
+ memmove(path, path + 3, strlen(path + 3) + 1);
} /*if*/
}
- 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);
}
@@ -442,10 +442,10 @@ void BLI_cleanup_dir(const char *relabase, char *dir)
}
-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);
}
bool BLI_path_is_rel(const char *path)
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 3ffd245..7d2675d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1229,7 +1229,6 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
}
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);
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5d/01/7a915e4c1da33772b9c794a9ba45
Event Timeline
Log In to Comment