Added function to handle file or directories.
This commit is contained in:
@@ -61,3 +61,18 @@ bool parse_dir(const char *dir_loc, void (*func)(const char *, struct stat&))
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool parse_path(const char *path, void (*func)(const char *, struct stat&))
|
||||
{
|
||||
struct stat stat_buffer;
|
||||
if (!stat(path, &stat_buffer))
|
||||
{
|
||||
if (S_ISDIR(stat_buffer.st_mode))
|
||||
{
|
||||
return(parse_dir(path, func));
|
||||
}
|
||||
func(path, stat_buffer);
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ This is part of a toolkit used to assist in ZSNES development
|
||||
#include <sys/stat.h>
|
||||
|
||||
bool parse_dir(const char *, void (*func)(const char *, struct stat&));
|
||||
bool parse_path(const char *, void (*func)(const char *, struct stat&));
|
||||
|
||||
inline bool extension_match(const char *filename, const char *ext)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user