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:
authorTon Roosendaal <ton@blender.org>2011-01-30 16:12:03 +0300
committerTon Roosendaal <ton@blender.org>2011-01-30 16:12:03 +0300
commitc7834e0e6e12cd613d645f2178ea0495a28592ab (patch)
treeeab66e65230f8f42c6910581fb244c9fb11cff8d /source/blender/editors/space_file
parent9d0b8486c89e70b59325b84107394990ae00c3cb (diff)
And here's a decent fix for correctly recognizing the the
.blend1 etc backups. Proves again that lazy coders only make bad code :) Implementation note: The filewindow now recoginizes .blend version backups as a special type, so filtering for .blend files themselves ignores it. However, they're recognized correctly as valid .blend files, and draw an icon as .blend file when filtering is off. Can become a distinct icon if we want...
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c2
-rw-r--r--source/blender/editors/space_file/filelist.c30
2 files changed, 31 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index e9e036a65cb..54a462ad84a 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -256,6 +256,8 @@ static int get_file_icon(struct direntry *file)
}
else if (file->flags & BLENDERFILE)
return ICON_FILE_BLEND;
+ else if (file->flags & BLENDERFILE_BACKUP)
+ return ICON_FILE_BLEND;
else if (file->flags & IMAGEFILE)
return ICON_FILE_IMAGE;
else if (file->flags & MOVIEFILE)
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index e16b2f650eb..ec4733c171c 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -722,10 +722,38 @@ void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob
BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob));
}
+static int file_is_blend_backup(const char *str)
+{
+ short a, b;
+ int retval= 0;
+
+ a= strlen(str);
+ b= 7;
+
+ if(a==0 || b>=a);
+ else {
+ char *loc;
+
+ if(a > b+1)
+ b++;
+
+ /* allow .blend1 .blend2 .blend32 */
+ loc= BLI_strcasestr(str+a-b, ".blend");
+
+ if(loc)
+ retval= 1;
+ }
+
+ return (retval);
+}
+
+
static int file_extension_type(char *relname)
{
if(BLO_has_bfile_extension(relname)) {
return BLENDERFILE;
+ } else if(file_is_blend_backup(relname)) {
+ return BLENDERFILE_BACKUP;
} else if(BLI_testextensie(relname, ".py")) {
return PYSCRIPTFILE;
} else if(BLI_testextensie(relname, ".txt")
@@ -757,7 +785,7 @@ int ED_file_extension_icon(char *relname)
{
int type= file_extension_type(relname);
- if (type == BLENDERFILE)
+ if (type == BLENDERFILE || type==BLENDERFILE_BACKUP)
return ICON_FILE_BLEND;
else if (type == IMAGEFILE)
return ICON_FILE_IMAGE;