{"id":13576659,"url":"https://github.com/tronkko/dirent","last_synced_at":"2025-04-05T08:32:42.250Z","repository":{"id":2261401,"uuid":"43087387","full_name":"tronkko/dirent","owner":"tronkko","description":"C/C++ library for retrieving information on files and directories","archived":false,"fork":false,"pushed_at":"2025-04-03T19:14:39.000Z","size":205,"stargazers_count":1095,"open_issues_count":2,"forks_count":514,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-04-03T20:25:38.903Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tronkko.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-24T19:10:20.000Z","updated_at":"2025-04-03T19:14:43.000Z","dependencies_parsed_at":"2024-02-18T09:22:18.674Z","dependency_job_id":"b5f6da3b-7da5-4419-9bda-bfe5f9c628ec","html_url":"https://github.com/tronkko/dirent","commit_stats":{"total_commits":105,"total_committers":16,"mean_commits":6.5625,"dds":0.5523809523809524,"last_synced_commit":"328e7fca1497f1d990d8b55b3cec39c869e3a6a8"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronkko%2Fdirent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronkko%2Fdirent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronkko%2Fdirent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronkko%2Fdirent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tronkko","download_url":"https://codeload.github.com/tronkko/dirent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247311896,"owners_count":20918339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:12.556Z","updated_at":"2025-04-05T08:32:41.957Z","avatar_url":"https://github.com/tronkko.png","language":"C","funding_links":[],"categories":["C","C++"],"sub_categories":[],"readme":"# Dirent\n\nDirent is a programming interface for retrieving information about files and\ndirectories in C and C++ languages.  This project provides a Dirent interface\nfor Microsoft Visual Studio.\n\n\n# Installation\n\nDownload the latest Dirent installation package from\n[GitHub](https://github.com/tronkko/dirent/releases) and\nunpack the installation file with 7-zip, for example.  The installation\npackage contains ``include/dirent.h`` file as well as a few example and test\nprograms.\n\nTo make Dirent available to all C/C++ projects in your machine, simply copy\n``include/dirent.h`` file to the system include directory, e.g.\n``C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include``.  Everything you\nneed is included in the single ``dirent.h`` file, and you can start using\nDirent immediately -- there is no need to add files to your Visual Studio\nproject.\n\nAlternatively, if you wish to distribute ``dirent.h`` alongside with your own\nproject, then copy ``include/dirent.h`` file to a new sub-directory within\nyour project and add that directory to include path on Windows while omitting\nthe directory under Linux/UNIX.  This allows your project to be compiled\nagainst native ``dirent.h`` on Linux/UNIX while substituting the functionality\non Microsoft Windows.\n\n\n# Example Programs\n\nThe installation package contains example programs:\n\nProgram  | Purpose\n-------- | -----------------------------------------------------------------\nls       | List files in a directory, e.g. ls \"c:\\Program Files\"\nfind     | Find files in subdirectories, e.g. find \"c:\\Program Files\\CMake\"\nupdatedb | Build database of files in a drive, e.g. updatedb c:\\\nlocate   | Locate a file from database, e.g. locate notepad\nscandir  | Printed sorted list of file names in a directory, e.g. scandir .\ndu       | Compute disk usage, e.g. du \"C:\\Program Files\"\ncat      | Print a text file to screen, e.g. cat include/dirent.h\n\nIn order to build the example programs, first install\n[CMake](https://cmake.org/) to your machine.  Then, open command prompt and\ncreate a temporary directory ``c:\\temp\\dirent`` for the build files as\n\n```\nc:\\\nmkdir temp\nmkdir temp\\dirent\ncd temp\\dirent\n```\n\nGenerate build files as\n\n```\ncmake d:\\dirent\n```\n\nwhere ``d:\\dirent`` is the root directory of the Dirent package containing\nthis README.md file.\n\nOnce CMake is finished, open Visual Studio, load the generated ``dirent.sln``\nfile from the build directory and build the whole solution.\n\nOnce the build completes, open command prompt and cd to the Debug directory to\nrun the example programs.  For example:\n\n```\ncd c:\\temp\\dirent\\Debug\n.\\ls .\n```\n\nVisual Studio project also contains a solution named ``check`` which can be\nused to verify that Dirent API works as expected.  Just build the solution\nfrom Visual Studio to run the test programs.\n\n\n# UTF-8 Support\n\nBy default, file and directory names in the Dirent API are expressed in the\ncurrently selected windows codepage.  If you wish to use UTF-8 character\nencoding, then replace the main function with \\_main function and convert\nwide-character arguments to UTF-8 strings as demonstrated in the snippet\nbelow.\n\n```\n/* This is your true main function */\nstatic int\n_main(int argc, char *argv[])\n{\n\t/* ... */\n}\n\n/* Convert arguments to UTF-8 */\n#ifdef _MSC_VER\nint\nwmain(int argc, wchar_t *argv[])\n{\n\t/* Select UTF-8 locale */\n\tsetlocale(LC_ALL, \".utf8\");\n\tSetConsoleCP(CP_UTF8);\n\tSetConsoleOutputCP(CP_UTF8);\n\n\t/* Allocate memory for multi-byte argv table */\n\tchar **mbargv;\n\tmbargv = (char**) malloc(argc * sizeof(char*));\n\tif (!mbargv) {\n\t\tputs(\"Out of memory\");\n\t\texit(3);\n\t}\n\n\t/* Convert each argument in argv to UTF-8 */\n\tfor (int i = 0; i \u003c argc; i++) {\n\t\tsize_t n;\n\t\twcstombs_s(\u0026n, NULL, 0, argv[i], 0);\n\n\t\t/* Allocate room for ith argument */\n\t\tmbargv[i] = (char*) malloc(n);\n\t\tif (!mbargv[i]) {\n\t\t\tputs(\"Out of memory\");\n\t\t\texit(3);\n\t\t}\n\n\t\t/* Convert ith argument to utf-8 */\n\t\twcstombs_s(NULL, mbargv[i], n, argv[i], n);\n\t}\n\n\t/* Pass UTF-8 converted arguments to the main program */\n\tint errorcode = _main(argc, mbargv);\n\n\t/* Release UTF-8 arguments */\n\tfor (int i = 0; i \u003c argc; i++) {\n\t\tfree(mbargv[i]);\n\t}\n\n\t/* Release the argument table */\n\tfree(mbargv);\n\treturn errorcode;\n}\n#else\nint\nmain(int argc, char *argv[])\n{\n\treturn _main(argc, argv);\n}\n#endif\n```\n\nFor more information on UTF-8 support, please see setlocale in Visual Studio\n[C runtime library reference](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160#utf-8-support).\n\n\n# Contributing\n\nWe love to receive contributions from you.  See the\n[CONTRIBUTING](CONTRIBUTING.md) file for details.\n\n\n# Copying\n\nDirent may be freely distributed under the MIT license.  See the\n[LICENSE](LICENSE) file for details.\n\n\n# Alternatives to Dirent\n\nI ported Dirent to Microsoft Windows in 1998 when only a few alternatives\nwere available.  However, the situation has changed since then and nowadays\nboth [Cygwin](http://www.cygwin.com) and [MingW](http://www.mingw.org)\nallow you to compile a great number of UNIX programs in Microsoft Windows.\nThey both provide a full Dirent API as well as many other UNIX APIs.  MingW\ncan even be used for commercial applications!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftronkko%2Fdirent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftronkko%2Fdirent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftronkko%2Fdirent/lists"}