https://github.com/tsoding/minirent
A subset of dirent interface for Windows.
https://github.com/tsoding/minirent
Last synced: 4 months ago
JSON representation
A subset of dirent interface for Windows.
- Host: GitHub
- URL: https://github.com/tsoding/minirent
- Owner: tsoding
- License: mit
- Created: 2021-01-26T19:18:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-09T11:19:45.000Z (almost 3 years ago)
- Last Synced: 2023-09-09T12:29:24.674Z (almost 3 years ago)
- Language: C
- Size: 17.6 KB
- Stars: 11
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/tsoding/minirent/actions)
# minirent
A subset of [dirent](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html) interface for Windows.
The code that works with minirent must work with the dirent.
Use minirent as a cross-platform replacement of dirent if you only need the subset interface.
## Usage
[minirent.h](./minirent.h) is an [stb-style](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt) header-only library. That means that when you just include it it does not include the implementations of the functions. You have to define `MINIRENT_IMPLEMENTATION` macro:
```c
#include
#include
#include
#define MINIRENT_IMPLEMENTATION
#include
int main(void)
{
DIR *dir = opendir(".");
assert(dir);
errno = 0;
struct dirent *dp = NULL;
while ((dp = readdir(dir))) {
printf("%s\n", dp->d_name);
}
assert(errno == 0);
int err = closedir(dir);
assert(err == 0);
return 0;
}
```
For more information see [./examples/](./examples/) folder.