Skip to content
This repository has been archived by the owner on Feb 12, 2025. It is now read-only.

Add recursive search for files in a folder #46

Open
NexSqaud opened this issue Feb 22, 2023 · 0 comments
Open

Add recursive search for files in a folder #46

NexSqaud opened this issue Feb 22, 2023 · 0 comments

Comments

@NexSqaud
Copy link

NexSqaud commented Feb 22, 2023

That will be cool if library have a function to search for files in folders recursively

Maybe something like this:

typedef void(*fileHandler)(const char* folder, const char* file);

void foreachFileInDirectoryRecursive(const char* path, fileHandler handler)
{
    INFO("Looking for files in %s recursively", path);
    FOREACH_FILE_IN_DIR(file, path, {
        if (strcmp(".", file) && strcmp("..", file))
        {
            const char* fullpath = PATH(path, file);
            if (IS_DIR(fullpath))
            {
                foreachFileInDirectoryRecursive(fullpath, handler);
            }
            else
            {
                handler(path, file);
            }

             free(fullpath);
        }
    });
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant