{"id":17697676,"url":"https://github.com/krshrimali/cpp-file-manager","last_synced_at":"2025-10-25T08:44:46.473Z","repository":{"id":50784589,"uuid":"266469701","full_name":"krshrimali/CPP-File-Manager","owner":"krshrimali","description":"A C++ File Manager library, to load files in a directory with options to exclude extensions with patterns. Also available as cross platform binary.","archived":false,"fork":false,"pushed_at":"2022-12-05T07:23:30.000Z","size":396,"stargazers_count":17,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-28T17:51:00.563Z","etag":null,"topics":["cpp","file-manager"],"latest_commit_sha":null,"homepage":"","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/krshrimali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-24T04:32:02.000Z","updated_at":"2025-01-24T06:18:05.000Z","dependencies_parsed_at":"2022-09-14T22:51:34.466Z","dependency_job_id":null,"html_url":"https://github.com/krshrimali/CPP-File-Manager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/krshrimali/CPP-File-Manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krshrimali%2FCPP-File-Manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krshrimali%2FCPP-File-Manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krshrimali%2FCPP-File-Manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krshrimali%2FCPP-File-Manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krshrimali","download_url":"https://codeload.github.com/krshrimali/CPP-File-Manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krshrimali%2FCPP-File-Manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280929581,"owners_count":26415347,"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","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp","file-manager"],"created_at":"2024-10-24T14:48:12.800Z","updated_at":"2025-10-25T08:44:46.433Z","avatar_url":"https://github.com/krshrimali.png","language":"C++","readme":"# CPP-File-Manager\n\nC++ File Manager allows you to list files in C++, ignore extensions (or just list specified extensions) and write the whole directory structure into a fancy tree-like structure which can be integrated in Markdown files. This is the first release. Please file issues with `[FEATURE REQUEST]` in the title, and we'll be happy to take a look at it.\n\nThe C++ File Manager provides the following functions to users:\n\n1. `clear()` - Clears the memory allocated to corePath.\n2. `clear(std::string new_path)` - Assigns a new path to the corePath variable.\n3. `info()` - Prints the corePath assigned to the FileManager object to the console.\n4. `list_files(std::vector\u003cstd::string\u003e extensions, bool ignore_extensions)` - Lists the files and directories in corePath. The first argument is *extensions* which is a vector of file extensions to be ignored. These extensions are ignored only when the second argument i.e. `ignore_extensions` is set to `true`.\n5. `writeToFile(std::vector\u003cstring\u003e ignore_dirs, std::vector\u003cstd::string\u003e ignore_extension)` - Writes the tree structure for the files and directories in corePath into a `.txt` file. This functions iterates till the innermost files of all the directories. The first argument `ignore_dirs` contains a vector of directories to be ignored in the tree structures. Similarly, the second argument `ignore_extensions` contains a vector of files extensions to be ignored in the final tree structure.\n\n## Usage \n\n### Using Binary\n\nThe **fmanager** binary has the following options :\n\n```\n  -h  --help                        Print usage.\n  -p  --path filePath               Input path (to be iterated).\n  -l  --list_files                  Call the list files function.\n  -t  --tree                        Call the tree function.\n  -d --ignore_dirs dir1,dir2        Ignore dirs while creating tree\n  -e --ignore_extensions ext1,ext2  Ignore extensions while creating tree\n  -s --separator                    Separator you want for your tree output\n```\n\n**Listing files in a directory**\n\nCommand: `fmanager -p samples`\n\nBy default, it will list files in the given directory (here `samples`). Output will look like this:\n\n```bash\nGot path: samples\nsample.cpp\nREADME.md\nlibcpp-file-manager.a\nCMakeLists.txt\nFileManager.hpp\n```\n\n**Building tree of the given directory and ignoring directories and extensions**\n\n`./fmanager -p ./ -t -d include,.git -e .cpp`\\\n_OR_ \\\n`./fmanager --path ./ --tree --ignore_dirs include,.git --ignore_extensions .cpp`\n\n``` \nGot path: ./\ntree.txt\nCMakeLists.txt\nsamples\nsrc\n.github\nREADME.md\n.git\ninclude\n```\n\nThe `tree.txt` file stores the following directory structure:\n\n```\n|-- tree.txt\n|-- CMakeLists.txt\n|-- samples\n    |-- libcpp-file-manager.a\n    |-- CMakeLists.txt\n    |-- README.md\n    |-- FileManager.hpp\n|-- src\n|-- .github\n    |-- workflows\n        |-- build-filemanager.yml\n|-- README.md\n|-- .git\n|-- include\n```\n\nIn case you want to change the separator from default (`|--`) to something like `-` or `*`, do:\n\n```bash\n./fmanager -s '-' -t\n./fmanager --separator '-' --tree\n```\n\nThe generated `tree.txt` will now contain `-` instead of `|--`:\n\n```\n- tree.txt\n- CMakeLists.txt\n...\n```\n\n### Using the library in your C++ Code\n\nTo be able to use `FileManager` library, head over to the latest release and download `.a` (library file) and `.hpp` (header file). Copy these files in your current folder (or wherever you desire, just remember the path). To compile, use:\n\n```bash\ng++ filename.cpp -L . -lcpp-file-manager -o out\n```\n\nHere are a few steps on using the library in your code:\n\n1. Create an object of `Filemanager` class and initialize it with a path:\n\n``` \nstd::string path = \"/home/BuffetCodes/Documents/CPP-File-Manager\"; // Change this with your path, either relative or absolute\nFileManager file(path);\n```\n\n2. The `file.list_files()` function returns a vector containing names of files/directories with additional information. We can iterate through it as follows:\n\n```cpp\n// The type returned is a struct, head over to the header file for more details on it\nfor (auto const\u0026 item: file.list_files()) {\n    // Use item.rname if you want \"just\" the name of the file or folder\n    // item.name returns absolute path (with respect to the path given)\n    // item.is_dir returns true if it's a directory, else false\n    std::cout \u003c\u003c item.name \u003c\u003c \"\\n\";\n}\n```\n\nThe output will be as follows:\n\n```\n./tree.txt\n./CMakeLists.txt\n./samples\n./src\n./.github\n./README.md\n./.git\n./include\n```\n\n3. The `file.writeToFile()` call, creates a text file `tree.txt` representing the directory structure: \n\n```cpp\nstd::vector\u003cstd::string\u003e ignore_dirs = {\".git\", \".github\", \".vscode\", \"build\"};\nstd::vector\u003cstd::string\u003e ignore_extensions = {\".pyc\", \".swp\"};\nfile.writeToFile(/*ignore_folders=*/ ignore_dirs, /*ignore_extensions=*/ ignore_extensions);\n```\n\n## Build\n\nThe current release (1.0) only supports GNU/Linux Systems. Please head to the relevant opened issues to see the progress on Windows and MacOS. Use the following steps to build from source:\n\n```bash\ngit clone https://github.com/BuffetCodes/CPP-File-Manager.git \u0026\u0026 cd CPP-File-Manager\nmkdir build \u0026\u0026 cd build\ncmake .. \u0026\u0026 make\n```\n\nThe library file: `libcpp-file-manager.a` will be generated in `build/` directory. Copy the header file in `include/` and library file from `build/` directory to your folder to use it. Or, just head over to the `samples` folder in this project on how to compile using `CMake` or `g++`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrshrimali%2Fcpp-file-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrshrimali%2Fcpp-file-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrshrimali%2Fcpp-file-manager/lists"}