libdragon
Loading...
Searching...
No Matches
dir.h
Go to the documentation of this file.
1
8#ifndef __LIBDRAGON_DIR_H
9#define __LIBDRAGON_DIR_H
10
11#include <stdint.h>
12#include <stdbool.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
28#define DT_REG 1
30#define DT_DIR 2
36typedef struct
37{
39 char d_name[256];
41 int d_type;
50 int64_t d_size;
52 uint32_t d_cookie;
53} dir_t;
54
71int dir_findfirst( const char * const path, dir_t *dir );
72
88int dir_findnext( const char * const path, dir_t *dir );
89
91enum {
97};
98
121typedef int (*dir_walk_callback_t)(const char *fn, dir_t *dir, void *data);
122
140int dir_walk(const char *path, dir_walk_callback_t cb, void *data);
141
172bool dir_fnmatch(const char *pattern, const char *fullpath);
173
206int dir_glob(const char *pattern, const char *path, dir_walk_callback_t cb, void *data);
207
208
209#ifdef __cplusplus
210}
211#endif
212
213#endif
int(* dir_walk_callback_t)(const char *fn, dir_t *dir, void *data)
Callback function for directory walking.
Definition dir.h:121
bool dir_fnmatch(const char *pattern, const char *fullpath)
Check if a filename matches a pattern.
Definition dir.c:165
int dir_walk(const char *path, dir_walk_callback_t cb, void *data)
Walk a directory tree.
Definition dir.c:14
int dir_glob(const char *pattern, const char *path, dir_walk_callback_t cb, void *data)
Glob a directory tree using a pattern.
Definition dir.c:170
int dir_findnext(const char *const path, dir_t *dir)
Find the next file in a directory.
Definition system.c:1341
@ DIR_WALK_ERROR
Error walking the directory (errno will be set)
Definition dir.h:93
@ DIR_WALK_SKIPDIR
Do not recurse within the current directory.
Definition dir.h:95
@ DIR_WALK_GOUP
Stop walking the current directory, return up one level.
Definition dir.h:96
@ DIR_WALK_CONTINUE
Continue walking.
Definition dir.h:94
@ DIR_WALK_ABORT
Abort walking and exit immediately.
Definition dir.h:92
int dir_findfirst(const char *const path, dir_t *dir)
Find the first file in a directory.
Definition system.c:1315
int64_t d_size
Size of the file.
Definition dir.h:50
uint32_t d_cookie
Opaque cookie used to continue walking.
Definition dir.h:52
int d_type
The type of the directory entry. See DT_REG and DT_DIR.
Definition dir.h:41
Directory entry structure.
Definition dir.h:37