Last active
August 26, 2015 04:58
-
-
Save Fedjmike/093de3ff96afc9be7fd2 to your computer and use it in GitHub Desktop.
A macro for iterating over the contents of a directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dirent.h> | |
#define for_dir(entry, dirname, continuation) \ | |
do { \ | |
DIR* for_dir_dir__ = opendir(dirname); \ | |
for (struct dirent* (entry); \ | |
((entry) = readdir(for_dir_dir__));) { \ | |
continuation \ | |
} \ | |
closedir(for_dir_dir__); \ | |
} while (0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment