Added function to handle file or directories.

This commit is contained in:
n-a-c-h
2005-07-10 01:30:07 +00:00
parent 56b58a5efc
commit c78b889ade
2 changed files with 16 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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)
{