How gulrak/filesystem works
Main Components
• Library Core (API and Implementation): The “include/ghc” directory contains the key header files (e.g., filesystem.hpp, fs_impl.hpp, fs_fwd.hpp, and others). This is the library’s interface in the ghc::filesystem namespace.
• Build System & Configuration: The top-level CMakeLists.txt along with additional CMake modules in the “cmake” directory shows how the project is configured, built, and installed. Build scripts (both in .ci and GitHub workflows) illustrate integration with CI systems.
• Testing & Examples: The “test” directory holds unit tests (with Catch2 and special handling for both ghc::filesystem and std::filesystem tests). The “examples” directory contains simple demo programs (like du.cpp) to demonstrate usage.
• Continuous Integration (CI/CD): Files like .appveyor.yml, .cirrus.yml, .drone.yml-disabled, and GitHub Actions workflows define automated build/test processes across multiple platforms.
• Documentation & Release Management: The README file gives a detailed description, while LICENSE and versioning information are in the root and within Git tags.
Out Relationships and Interactions
• The CMake build system ties together compiling examples, unit tests, and optionally installing the header-only library.
• The CI/CD configurations directly trigger the build and test processes using CMake, thus showing dependency on the build system.
• Users incorporate the library by either adding the “include/ghc” directory to their project or by using the provided forwarding/implementation headers. This mechanism is diagrammed as the “Public API” leading into their application code.
• The tests and examples depend on the library core to confirm interface conformance and performance across different platforms.
Architectural Patterns and Design Principles
• Header-only library design: The core functionality is contained in the header files and is compiled into the client application (while optional separation into forwarding and implementation headers helps hide system includes).
• Cross-platform abstraction: The library adapts to differences among operating systems (Windows, macOS, Linux, FreeBSD, Solaris, and even Haiku or Android in some cases). CI/CD files illustrate how multiple platform builds are handled.
• Conditional compilation and dynamic inclusion: The intricate usage of preprocessor definitions (e.g., GHC_USE_STD_FS, GHC_FILESYSTEM_ENFORCE_CPP17_API, etc.) is key in selecting between native std::filesystem and the fallback implementation.
Relevant Technologies and Tools
• C++ (with support from C++11 to C++20).
• CMake as the build system.
• Catch2 for unit testing.
• Various CI/CD systems (GitHub Actions, AppVeyor, Cirrus CI, Drone).
• Git submodules for integration into client projects.
• Optional integration with Bazel (as mentioned in the README).
– Infrastructure components (CI/CD, Build System)
– Code artifacts (API, tests, examples)
– External systems and platforms (Windows, Linux, macOS)