[Bf-blender-cvs] [a2a970c] gooseberry: Collapse image sequence feature now uses BLI_path_* functions to detect filenames.

Antony Riakiotakis noreply at git.blender.org
Thu Jun 4 21:16:13 CEST 2015


Commit: a2a970cbdd9f6a242250493243eec63d07a35414
Author: Antony Riakiotakis
Date:   Thu Jun 4 21:15:54 2015 +0200
Branches: gooseberry
https://developer.blender.org/rBa2a970cbdd9f6a242250493243eec63d07a35414

Collapse image sequence feature now uses BLI_path_* functions to detect
filenames.

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

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

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

diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index c9a54c3..c488856 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -133,7 +133,7 @@ bool BLI_path_abs(char *path, const char *basepath)  ATTR_NONNULL();
 bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL();
 bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL();
 bool BLI_path_frame_get(char *path, int *r_frame, int *numdigits) ATTR_NONNULL();
-void BLI_path_frame_strip(char *path, bool setsharp, char *ext) ATTR_NONNULL();
+bool BLI_path_frame_strip(char *path, bool setsharp, char *ext);
 bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL();
 bool BLI_path_cwd(char *path) ATTR_NONNULL();
 void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index d3352e2..f9c899a 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -912,7 +912,7 @@ bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits)
 	return false;
 }
 
-void BLI_path_frame_strip(char *path, bool setsharp, char *ext)
+bool BLI_path_frame_strip(char *path, bool setsharp, char *ext)
 {
 	if (path && *path) {
 		char *file = (char *)BLI_last_slash(path);
@@ -958,8 +958,12 @@ void BLI_path_frame_strip(char *path, bool setsharp, char *ext)
 			}
 			*c = 0;
 			if (ext) *ext = 0;
+
+			return true;
 		}
 	}
+
+	return false;
 }
 
 
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 7edfc32..a0213f0 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -469,42 +469,24 @@ static bool is_filtered_file(struct direntry *file, const char *UNUSED(root), Fi
 	}
 
 	if (is_filtered && filter->collapse_ima_seq) {
-		const char *filename, *filename_stripped;
-		filename = file->relname;
+		char filename[PATH_MAX];
 
-		filename_stripped = filename;
+		if (file->relname) {
+			struct direntry *ofile;
+			BLI_strncpy(filename, file->relname, sizeof(filename));
 
-		if (filename_stripped) {
-#define MAX_FRA_DIGITS 20
-			int numlen = 0;
 
-			/* strip numeric extensions */
-			while (*filename_stripped && isdigit(*filename_stripped)) {
-				filename_stripped++;
-				numlen++;
-			}
-
-			/* was the number really an extension? */
-			if (*filename_stripped == '.')
-				filename_stripped++;
-			else {
-				filename_stripped = filename;
-			}
-
-			if (numlen > 0 && numlen < MAX_FRA_DIGITS) {
-				struct direntry *ofile;
-
-				if ((ofile = BLI_ghash_lookup(filter->unique_image_list, filename_stripped))) {
+			if (BLI_path_frame_strip(filename, false, NULL)) {
+				if ((ofile = BLI_ghash_lookup(filter->unique_image_list, filename))) {
 					is_filtered = false;
 					ofile->selflag |= FILE_SEL_COLLAPSED;
 					file->selflag |= FILE_SEL_COLLAPSED;
 					BLI_addhead(&ofile->list, BLI_genericNodeN(file));
 				}
 				else {
-					BLI_ghash_insert(filter->unique_image_list, (void *)filename_stripped, file);
+					BLI_ghash_insert(filter->unique_image_list, (void *)filename, file);
 				}
 			}
-#undef MAX_FRA_DIGITS
 		}
 	}




More information about the Bf-blender-cvs mailing list