[Bf-blender-cvs] [0e1c1b6] master: Code cleanup: remove BLI_has_parent

Campbell Barton noreply at git.blender.org
Thu Jan 30 17:31:56 CET 2014


Commit: 0e1c1b61960ba520cc624ed7bd769aa524ecc1db
Author: Campbell Barton
Date:   Fri Jan 31 03:28:53 2014 +1100
https://developer.blender.org/rB0e1c1b61960ba520cc624ed7bd769aa524ecc1db

Code cleanup: remove BLI_has_parent

===================================================================

M	source/blender/blenlib/BLI_path_util.h
M	source/blender/blenlib/intern/path_util.c
M	source/blender/editors/space_file/file_ops.c

===================================================================

diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 2b06b8b..2a4efd1 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -145,9 +145,6 @@ void BLI_cleanup_path(const char *relabase, char *path) ATTR_NONNULL(2);
 /* go back one directory */
 bool BLI_parent_dir(char *path) ATTR_NONNULL();
 
-/* return whether directory is root and thus has no parent dir */
-bool BLI_has_parent(char *path);
-
 /**
  * Blender's path code replacement function.
  * Bases \a path strings leading with "//" by the
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 58ff67a..e56ac6f 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -576,31 +576,12 @@ void BLI_path_rel(char *file, const char *relfile)
 }
 
 /**
- * Cleans path and makes sure it ends with a slash.
- * \return  true if \a path has more than one other path separator in it.
- */
-bool BLI_has_parent(char *path)
-{
-	int len;
-	int slashes = 0;
-	BLI_clean(path);
-	len = BLI_add_slash(path) - 1;
-
-	while (len >= 0) {
-		if ((path[len] == '\\') || (path[len] == '/'))
-			slashes++;
-		len--;
-	}
-	return slashes > 1;
-}
-
-/**
  * Replaces path with the path of its parent directory, returning true if
  * it was able to find a parent directory within the pathname.
  */
 bool BLI_parent_dir(char *path)
 {
-	static char parent_dir[] = {'.', '.', SEP, '\0'}; /* "../" or "..\\" */
+	const char parent_dir[] = {'.', '.', SEP, '\0'}; /* "../" or "..\\" */
 	char tmp[FILE_MAX + 4];
 
 	BLI_join_dirfile(tmp, sizeof(tmp), path, parent_dir);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 3d5ae8c..523383a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -849,8 +849,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
 	SpaceFile *sfile = CTX_wm_space_file(C);
 	
 	if (sfile->params) {
-		if (BLI_has_parent(sfile->params->dir)) {
-			BLI_parent_dir(sfile->params->dir);
+		if (BLI_parent_dir(sfile->params->dir)) {
 			BLI_cleanup_dir(G.main->name, sfile->params->dir);
 			file_change_dir(C, 0);
 			WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);




More information about the Bf-blender-cvs mailing list