26 # include <sys/ioctl.h>
41 #include "../imbuf/IMB_imbuf.h"
74 if ((entry1->
type & S_IFMT) < (entry2->
type & S_IFMT)) {
77 if ((entry1->
type & S_IFMT) > (entry2->
type & S_IFMT)) {
114 const struct dirent *fname;
115 bool has_current =
false, has_parent =
false;
155 if (dir_ctx->
files) {
172 if (dir_ctx->
files) {
187 file->type |= S_IFDIR;
195 printf(
"Couldn't get memory for dir\n");
200 if (dir_ctx->
files) {
201 qsort(dir_ctx->
files,
208 printf(
"%s empty directory\n",
dirname);
214 printf(
"%s non-existent directory\n",
dirname);
228 *r_filelist = dir_ctx.
files;
233 *r_filelist =
MEM_mallocN(
sizeof(**r_filelist), __func__);
242 const bool UNUSED(compact),
259 const bool UNUSED(compact),
264 const char *
types[8] = {
"---",
"--x",
"-w-",
"-wx",
"r--",
"r-x",
"rw-",
"rwx"};
271 const int mode =
st->st_mode;
277 if (((mode & S_ISGID) == S_ISGID) && (r_mode2[2] ==
'-')) {
281 if (mode & (S_ISUID | S_ISGID)) {
282 if (r_mode1[2] ==
'x') {
289 if (r_mode2[2] ==
'x') {
294 if (mode & S_ISVTX) {
295 if (r_mode3[2] ==
'x') {
306 const bool UNUSED(compact),
310 strcpy(r_owner,
"unknown");
312 struct passwd *pwuser = getpwuid(
st->st_uid);
329 bool *r_is_yesterday)
333 int yesterday_year = 0;
334 int yesterday_yday = 0;
336 if (r_is_today || r_is_yesterday) {
339 struct tm *today = localtime(&ts_now);
341 today_year = today->tm_year;
342 today_yday = today->tm_yday;
346 yesterday_year = today->tm_year;
347 yesterday_yday = today->tm_yday;
352 if (r_is_yesterday) {
353 *r_is_yesterday =
false;
357 const time_t ts_mtime = ts;
358 const struct tm *tm = localtime(
st ? &
st->st_mtime : &ts_mtime);
359 const time_t zero = 0;
363 tm = localtime(&zero);
373 compact ?
"%d/%m/%y" :
"%d %b %Y",
377 if (r_is_today && (tm->tm_year == today_year) && (tm->tm_yday == today_yday)) {
380 else if (r_is_yesterday && (tm->tm_year == yesterday_year) && (tm->tm_yday == yesterday_yday)) {
381 *r_is_yesterday =
true;
397 struct direntry *
const src_filelist,
398 const unsigned int nrentries)
402 *dest_filelist =
MEM_mallocN(
sizeof(**dest_filelist) * (
size_t)(nrentries), __func__);
403 for (i = 0; i < nrentries; i++) {
405 struct direntry *dst = &(*dest_filelist)[i];
423 for (i = 0; i < nrentries; i++) {
427 if (filelist !=
NULL) {
static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
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_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_free(struct direntry *filelist, const unsigned int nrentries)
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 st_size_fallback, const bool UNUSED(compact), char r_size[FILELIST_DIRENTRY_SIZE_LEN])
void BLI_filelist_entry_free(struct direntry *entry)
void BLI_filelist_entry_duplicate(struct direntry *dst, const struct direntry *src)
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_duplicate(struct direntry **dest_filelist, struct direntry *const src_filelist, const unsigned int nrentries)
static int bli_compare(struct direntry *entry1, struct direntry *entry2)
File and directory operations.
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_access(const char *filepath, int mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Some types for dealing with directories.
#define FILELIST_DIRENTRY_SIZE_LEN
#define FILELIST_DIRENTRY_MODE_LEN
#define FILELIST_DIRENTRY_OWNER_LEN
#define FILELIST_DIRENTRY_DATE_LEN
#define FILELIST_DIRENTRY_TIME_LEN
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_freelist(struct ListBase *listbase) ATTR_NONNULL(1)
#define FILENAME_IS_CURRENT(_n)
#define FILENAME_IS_CURRPAR(_n)
bool BLI_path_parent_dir(char *path) ATTR_NONNULL()
#define FILENAME_IS_PARENT(_n)
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLI_str_format_byte_unit(char dst[15], long long int bytes, bool base_10) ATTR_NONNULL()
Compatibility-like things for windows.
const char * dirname(char *path)
struct dirent * readdir(DIR *dp)
DIR * opendir(const char *path)
typedef double(DMatrix)[4][4]
These structs are the foundation for all linked lists in the library system.
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SyclQueue void void * src
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
unsigned __int64 uint64_t