blob: f0e914496c9922224921b89ab57d492b2dbbc325 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#ifndef __SLOTS__SEARCH_H__4612270218569
#define __SLOTS__SEARCH_H__4612270218569
#include <sys/types.h>
#include <dirent.h>
// Wrapper for stat's S_ISDIR(mode) macro. Implemented as: return S_ISDIR(mode)
int S_ISDIR_WRAPPER(mode_t mode);
// Wrapper for stat's S_ISREG(mode) macro. Implemented as: return S_ISREG(mode)
int S_ISREG_WRAPPER(mode_t mode);
// Sort out nodes in a scanned directory using one of stat's S_IS--- functions
int nodesort(const struct dirent *node, int (*S_IS_CALLBACK)(mode_t));
int foldersort(const struct dirent *node); // Only display folders when using scandir
int filesort(const struct dirent *node); // Only display files when using scandir
// Create a linked list of full paths to folders, using CMP to order them. Returns NULL on error
struct nodelist* scanfolders(const char *STARTPATH, int (*cmp)(const struct dirent **, const struct dirent **));
// Create a linked list of full paths to files, using CMP to order them. Returns NULL on error
struct nodelist* scanfiles(const char *STARTPATH, int (*cmp)(const struct dirent **, const struct dirent **));
#endif
|