GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cxong/tinydir: Lightweight, portable and easy to integrate C directory and file reader

BranchesTags
Open more actions menu

Latest commit

 

History

182 Commits
182 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
samples
samples
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
COPYING
COPYING
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
package.json
package.json
 
 
tinydir.h
tinydir.h
 
 

Repository files navigation

TinyDir

CMake Release

Lightweight, portable and easy to integrate C directory and file reader. TinyDir wraps dirent for POSIX and FindFirstFile for Windows.

Windows unicode is supported by defining UNICODE and _UNICODE before including tinydir.h.

Example

There are two methods. Error checking omitted:

tinydir_dir dir;
tinydir_open(&dir, "/path/to/dir");

while (dir.has_next)
{
	tinydir_file file;
	tinydir_readfile(&dir, &file);

	printf("%s", file.name);
	if (file.is_dir)
	{
		printf("/");
	}
	printf("\n");

	tinydir_next(&dir);
}

tinydir_close(&dir);
tinydir_dir dir;
int i;
tinydir_open_sorted(&dir, "/path/to/dir");

for (i = 0; i < dir.n_files; i++)
{
	tinydir_file file;
	tinydir_readfile_n(&dir, &file, i);

	printf("%s", file.name);
	if (file.is_dir)
	{
		printf("/");
	}
	printf("\n");
}

tinydir_close(&dir);

See the /samples folder for more examples, including an interactive command-line directory navigator.

Language

ANSI C, or C90.

Platforms

POSIX and Windows supported. Open to the possibility of supporting other platforms.

License

Simplified BSD; if you use tinydir you can comply by including tinydir.h or COPYING somewhere in your package.

Known Limitations

  • Limited path and filename sizes
  • Possible race condition bug if folder being read has changing content
  • Does not support extended-length path lengths in Windows - paths are limited to 260 characters. See https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry

About

Lightweight, portable and easy to integrate C directory and file reader

Topics

cdirectoryfilesystemheader-onlyportableposix

Resources

Readme
License

Security policy

Security policy
Activity

Stars

875 stars

Watchers

34 watching

Forks

132 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.