diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-29 01:50:13 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-29 01:50:13 +0400 |
commit | 2f46a2cbf7a80c85734bd2b7d7cd0b5dc178f43b (patch) | |
tree | c4aa635f4de8482fc069308a14d238349d403a6a /source/blender/editors/space_file/filelist.c | |
parent | bcf18878a2ed18f16f5f9a4a8896644a3a3ddaae (diff) |
Fix #36595: file browser sorting with link/append would mix together .blend files
and directories instead of keeping them separate like regular file browse.
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 8f25ac38963..b427555d1a7 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -152,17 +152,27 @@ static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX]; /* ******************* SORT ******************* */ +static bool compare_is_directory(const struct direntry *entry) +{ + /* for library browse .blend files may be treated as directories, but + * for sorting purposes they should be considered regular files */ + if (S_ISDIR(entry->type)) + return !(entry->flags & (BLENDERFILE|BLENDERFILE_BACKUP)); + + return false; +} + static int compare_name(const void *a1, const void *a2) { const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type) == 0) return (-1); + if (compare_is_directory(entry1)) { + if (compare_is_directory(entry2) == 0) return (-1); } else { - if (S_ISDIR(entry2->type)) return (1); + if (compare_is_directory(entry2)) return (1); } if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type) == 0) return (-1); @@ -188,11 +198,11 @@ static int compare_date(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type) == 0) return (-1); + if (compare_is_directory(entry1)) { + if (compare_is_directory(entry2) == 0) return (-1); } else { - if (S_ISDIR(entry2->type)) return (1); + if (compare_is_directory(entry2)) return (1); } if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type) == 0) return (-1); @@ -221,11 +231,11 @@ static int compare_size(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type) == 0) return (-1); + if (compare_is_directory(entry1)) { + if (compare_is_directory(entry2) == 0) return (-1); } else { - if (S_ISDIR(entry2->type)) return (1); + if (compare_is_directory(entry2)) return (1); } if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type) == 0) return (-1); @@ -262,11 +272,11 @@ static int compare_extension(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type) == 0) return (-1); + if (compare_is_directory(entry1)) { + if (compare_is_directory(entry2) == 0) return (-1); } else { - if (S_ISDIR(entry2->type)) return (1); + if (compare_is_directory(entry2)) return (1); } if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type) == 0) return (-1); |