Blender V5.0
filelist_sort.cc File Reference
#include "AS_asset_catalog.hh"
#include "AS_asset_library.hh"
#include "AS_asset_representation.hh"
#include "BLI_listbase.h"
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "../filelist.hh"
#include "filelist_intern.hh"

Go to the source code of this file.

Classes

struct  FileSortData

Functions

static int compare_apply_inverted (int val, const FileSortData *sort_data)
static int compare_tiebreaker (const FileListInternEntry *entry1, const FileListInternEntry *entry2)
static int compare_direntry_generic (const FileListInternEntry *entry1, const FileListInternEntry *entry2)
static int compare_name (void *user_data, const void *a1, const void *a2)
static int compare_date (void *user_data, const void *a1, const void *a2)
static int compare_size (void *user_data, const void *a1, const void *a2)
static int compare_extension (void *user_data, const void *a1, const void *a2)
static int compare_asset_catalog (void *user_data, const void *a1, const void *a2)
void filelist_sort (FileList *filelist)
void filelist_setsorting (FileList *filelist, const short sort, bool invert_sort)

Function Documentation

◆ compare_apply_inverted()

int compare_apply_inverted ( int val,
const FileSortData * sort_data )
static

◆ compare_asset_catalog()

◆ compare_date()

int compare_date ( void * user_data,
const void * a1,
const void * a2 )
static

◆ compare_direntry_generic()

int compare_direntry_generic ( const FileListInternEntry * entry1,
const FileListInternEntry * entry2 )
static

Handles inverted sorting itself (currently there's nothing to invert), so if this returns non-0, it should be used as-is and not inverted.

Definition at line 80 of file filelist_sort.cc.

References FILE_TYPE_BLENDER, FILE_TYPE_BLENDER_BACKUP, FILE_TYPE_BLENDERLIB, FILE_TYPE_DIR, FILENAME_IS_CURRENT, FILENAME_IS_PARENT, FileListInternEntry::relpath, and FileListInternEntry::typeflag.

Referenced by compare_asset_catalog(), compare_date(), compare_extension(), compare_name(), and compare_size().

◆ compare_extension()

int compare_extension ( void * user_data,
const void * a1,
const void * a2 )
static

◆ compare_name()

int compare_name ( void * user_data,
const void * a1,
const void * a2 )
static

◆ compare_size()

int compare_size ( void * user_data,
const void * a1,
const void * a2 )
static

◆ compare_tiebreaker()

int compare_tiebreaker ( const FileListInternEntry * entry1,
const FileListInternEntry * entry2 )
static

If all relevant characteristics match (e.g. the file type when sorting by file types), this should be used as tiebreaker. It makes sure there's a well defined sorting even in such cases.

Multiple files with the same name can appear with recursive file loading and/or when displaying IDs of different types, so these cases need to be handled.

1) Sort files by name using natural sorting. 2) If not possible (file names match) and both represent local IDs, sort by ID-type. 3) If not possible and only one is a local ID, place files representing local IDs first.

TODO: (not actually implemented, but should be): 4) If no file represents a local ID, sort by file path, so that files higher up the file system hierarchy are placed first.

Definition at line 44 of file filelist_sort.cc.

References FileListInternEntry::blentype, BLI_strcasecmp_natural(), FileListInternEntry::id, FileListInternEntry::local_data, and FileListInternEntry::name.

Referenced by compare_asset_catalog(), compare_date(), compare_extension(), compare_name(), and compare_size().

◆ filelist_setsorting()

void filelist_setsorting ( FileList * filelist,
const short sort,
bool invert_sort )

◆ filelist_sort()