Blender  V2.93
Classes | Functions
BLI_filelist.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <pwd.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
#include "BLI_fileops.h"
#include "BLI_fileops_types.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "../imbuf/IMB_imbuf.h"

Go to the source code of this file.

Classes

struct  BuildDirCtx
 

Functions

static int bli_compare (struct direntry *entry1, struct direntry *entry2)
 
static void bli_builddir (struct BuildDirCtx *dir_ctx, const char *dirname)
 
unsigned int BLI_filelist_dir_contents (const char *dirname, struct direntry **r_filelist)
 
void BLI_filelist_entry_size_to_string (const struct stat *st, const uint64_t sz, const bool UNUSED(compact), char r_size[FILELIST_DIRENTRY_SIZE_LEN])
 
void BLI_filelist_entry_mode_to_string (const struct stat *st, const bool UNUSED(compact), char r_mode1[FILELIST_DIRENTRY_MODE_LEN], char r_mode2[FILELIST_DIRENTRY_MODE_LEN], char r_mode3[FILELIST_DIRENTRY_MODE_LEN])
 
void BLI_filelist_entry_owner_to_string (const struct stat *st, const bool UNUSED(compact), char r_owner[FILELIST_DIRENTRY_OWNER_LEN])
 
void BLI_filelist_entry_datetime_to_string (const struct stat *st, const int64_t ts, const bool compact, char r_time[FILELIST_DIRENTRY_TIME_LEN], char r_date[FILELIST_DIRENTRY_DATE_LEN], bool *r_is_today, bool *r_is_yesterday)
 
void BLI_filelist_entry_duplicate (struct direntry *dst, const struct direntry *src)
 
void BLI_filelist_duplicate (struct direntry **dest_filelist, struct direntry *const src_filelist, const unsigned int nrentries)
 
void BLI_filelist_entry_free (struct direntry *entry)
 
void BLI_filelist_free (struct direntry *filelist, const unsigned int nrentries)
 

Function Documentation

◆ bli_builddir()

static void bli_builddir ( struct BuildDirCtx dir_ctx,
const char *  dirname 
)
static

◆ bli_compare()

static int bli_compare ( struct direntry entry1,
struct direntry entry2 
)
static

◆ BLI_filelist_dir_contents()

unsigned int BLI_filelist_dir_contents ( const char *  dirname,
struct direntry **  r_filelist 
)

Scans the contents of the directory named *dirname, and allocates and fills in an array of entries describing them in *filelist.

Returns
The length of filelist array.

Definition at line 238 of file BLI_filelist.c.

References bli_builddir(), dirname(), BuildDirCtx::files, MEM_mallocN, BuildDirCtx::nrfiles, and NULL.

Referenced by BKE_appdir_app_templates(), filelist_readjob_list_dir(), fsmenu_read_system(), image_get_udim(), init_iconfile_list(), seq_disk_cache_get_files(), and studiolight_add_files_from_datafolder().

◆ BLI_filelist_duplicate()

void BLI_filelist_duplicate ( struct direntry **  dest_filelist,
struct direntry *const  src_filelist,
const unsigned int  nrentries 
)

Deep-duplicate of an array of direntries, including the array itself.

Definition at line 437 of file BLI_filelist.c.

References BLI_filelist_entry_duplicate(), and MEM_mallocN.

◆ BLI_filelist_entry_datetime_to_string()

void BLI_filelist_entry_datetime_to_string ( const struct stat *  st,
const int64_t  ts,
const bool  compact,
char  r_time[FILELIST_DIRENTRY_TIME_LEN],
char  r_date[FILELIST_DIRENTRY_DATE_LEN],
bool *  r_is_today,
bool *  r_is_yesterday 
)

Convert given entry's time into human-readable strings.

Parameters
r_is_todayoptional, returns true if the date matches today's.
r_is_yesterdayoptional, returns true if the date matches yesterday's.

Definition at line 358 of file BLI_filelist.c.

References FILELIST_DIRENTRY_DATE_LEN, FILELIST_DIRENTRY_TIME_LEN, NULL, and time.

◆ BLI_filelist_entry_duplicate()

void BLI_filelist_entry_duplicate ( struct direntry dst,
const struct direntry src 
)

Deep-duplicate of a single direntry.

Definition at line 423 of file BLI_filelist.c.

References MEM_dupallocN, direntry::path, and direntry::relname.

Referenced by BLI_filelist_duplicate().

◆ BLI_filelist_entry_free()

void BLI_filelist_entry_free ( struct direntry entry)

frees storage for a single direntry, not the direntry itself.

Definition at line 454 of file BLI_filelist.c.

References MEM_freeN, direntry::path, and direntry::relname.

Referenced by BLI_filelist_free().

◆ BLI_filelist_entry_mode_to_string()

void BLI_filelist_entry_mode_to_string ( const struct stat *  st,
const bool   UNUSEDcompact,
char  r_mode1[FILELIST_DIRENTRY_MODE_LEN],
char  r_mode2[FILELIST_DIRENTRY_MODE_LEN],
char  r_mode3[FILELIST_DIRENTRY_MODE_LEN] 
)

Convert given entry's modes into human-readable strings.

Definition at line 284 of file BLI_filelist.c.

References BLI_strncpy(), FILELIST_DIRENTRY_MODE_LEN, and types.

◆ BLI_filelist_entry_owner_to_string()

void BLI_filelist_entry_owner_to_string ( const struct stat *  st,
const bool   UNUSEDcompact,
char  r_owner[FILELIST_DIRENTRY_OWNER_LEN] 
)

Convert given entry's owner into human-readable strings.

Definition at line 334 of file BLI_filelist.c.

References BLI_snprintf(), BLI_strncpy(), and FILELIST_DIRENTRY_OWNER_LEN.

◆ BLI_filelist_entry_size_to_string()

void BLI_filelist_entry_size_to_string ( const struct stat *  st,
const uint64_t  sz,
const bool   UNUSEDcompact,
char  r_size[FILELIST_DIRENTRY_SIZE_LEN] 
)

Convert given entry's size into human-readable strings.

Definition at line 262 of file BLI_filelist.c.

References BLI_str_format_byte_unit(), double(), and size().

◆ BLI_filelist_free()

void BLI_filelist_free ( struct direntry filelist,
const unsigned int  nrentries 
)

frees storage for an array of direntries, including the array itself.

Definition at line 467 of file BLI_filelist.c.

References BLI_filelist_entry_free(), MEM_freeN, and NULL.

Referenced by BKE_appdir_app_templates(), filelist_readjob_list_dir(), fsmenu_read_system(), image_get_udim(), init_iconfile_list(), seq_disk_cache_get_files(), and studiolight_add_files_from_datafolder().