{"id":27316889,"url":"https://github.com/scivision/ffilesystem","last_synced_at":"2026-02-19T07:27:01.527Z","repository":{"id":38951172,"uuid":"433875623","full_name":"scivision/ffilesystem","owner":"scivision","description":"Fast and simple filesystem and path manipulation library. OS, compiler, platform agnostic. Interfaces for C, C++, and Fortran.","archived":false,"fork":false,"pushed_at":"2026-02-17T21:52:42.000Z","size":3922,"stargazers_count":44,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-18T00:07:08.598Z","etag":null,"topics":["cpp17","filesystem","fortran","libc","path-manipulation"],"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/scivision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["scivision"],"ko_fi":"scivision"}},"created_at":"2021-12-01T15:12:08.000Z","updated_at":"2026-02-17T21:52:45.000Z","dependencies_parsed_at":"2025-09-04T23:40:13.599Z","dependency_job_id":"eef44981-ca9b-47c4-bb88-8fb297345ed0","html_url":"https://github.com/scivision/ffilesystem","commit_stats":null,"previous_names":["scivision/ffilesystem"],"tags_count":86,"template":false,"template_full_name":null,"purl":"pkg:github/scivision/ffilesystem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fffilesystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fffilesystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fffilesystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fffilesystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scivision","download_url":"https://codeload.github.com/scivision/ffilesystem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Fffilesystem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29606468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cpp17","filesystem","fortran","libc","path-manipulation"],"created_at":"2025-04-12T08:13:24.743Z","updated_at":"2026-02-19T07:27:01.505Z","avatar_url":"https://github.com/scivision.png","language":"C++","funding_links":["https://github.com/sponsors/scivision","https://ko-fi.com/scivision"],"categories":[],"sub_categories":[],"readme":"# Ffilesystem: platform-independent, compiler-agnostic path manipulation and filesystem library\n\n[![DOI](https://zenodo.org/badge/433875623.svg)](https://zenodo.org/badge/latestdoi/433875623)\n[![ci](https://github.com/scivision/ffilesystem/actions/workflows/ci.yml/badge.svg)](https://github.com/scivision/ffilesystem/actions/workflows/ci.yml)\n[![ci_windows](https://github.com/scivision/ffilesystem/actions/workflows/ci_windows.yml/badge.svg)](https://github.com/scivision/ffilesystem/actions/workflows/ci_windows.yml)\n[![oneapi-linux](https://github.com/scivision/ffilesystem/actions/workflows/oneapi-linux.yml/badge.svg)](https://github.com/scivision/ffilesystem/actions/workflows/oneapi-linux.yml)\n[![ci_fpm](https://github.com/scivision/ffilesystem/actions/workflows/ci_fpm.yml/badge.svg)](https://github.com/scivision/ffilesystem/actions/workflows/ci_fpm.yml)\n[![ci_meson](https://github.com/scivision/ffilesystem/actions/workflows/ci_meson.yml/badge.svg)](https://github.com/scivision/ffilesystem/actions/workflows/ci_meson.yml)\n\nPlatform independent (Linux, macOS, Windows, Cygwin, WSL, BSD, ...) and compiler-agnostic Ffilesystem path manipulation library.\nSimplicity and efficiency are focuses of Ffilesystem.\nFfilesystem backend is implemented in C++17 using `\u003cstring_view\u003e` for simplicity and speed.\nIf available,\n[C++ standard library `\u003cfilesystem\u003e`](https://en.cppreference.com/w/cpp/filesystem)\nis used.\nThe C++ backend accesses the\n[C standard library](https://en.wikipedia.org/wiki/C_standard_library)\nto access filesystem and system parameters.\nNetworked file systems and FUSE (e.g. SSHFS) are supported as well as local filesystems.\n\nFfilesystem supports\n[UTF-8](https://utf8everywhere.org/)\nvia C++ `std::string` or Fortran `character` as the path input / output argument types.\n\nFfilesystem does not throw or catch C++ exceptions itself.\n\nFfilesystem header\n[ffilesystem.h](./include/ffilesystem.h)\ncan be used from C and C++ project code--see\n[example](./example).\nThe C interface allows reuse of Ffilesystem functions in other code languages such as\n[Matlab](./example/matlab_ffilesystem.m).\n\nThe optional Fortran interface is built by default.\nDisable Fortran by\n\n```sh\ncmake -Dffilesystem_fortran=false -Bbuild\n# or\nmeson setup -Dfortran=false build\n```\n\nFfilesystem brings full, fast filesystem functionality to Fortran.\n\nThe language standards must be at least:\n\n* C++17 standard library [STL](./Readme_cpp_stl.md)\n* (optional) Fortran 2003\n\nFfilesystem works with popular C++ STL and C standard library implementations including:\n[glibc](https://sourceware.org/glibc/),\n[newlib](https://sourceware.org/newlib/),\n[musl](https://musl.libc.org/),\n[Cosmopolitan universal binaries](./Readme_cosmopolitan.md),\n[macOS universal binaries](./Readme_macos.md),\nBSD libc,\n[Microsoft CRT](https://en.wikipedia.org/wiki/Microsoft_Windows_library_files#CRT),\namong others.\nOn Linux, symbol\n[_DEFAULT_SOURCE](https://man7.org/linux/man-pages/man7/feature_test_macros.7.html)\nis defined if needed to enable C standard library functions.\n\nInspired by (and benchmarked against)\n[Python pathlib](https://docs.python.org/3/library/pathlib.html).\nImportant Ffilesystem functions are\n[benchmarked](./benchmark.md)\nto help improve performance.\nAdvanced / conceptual development takes place in\n[ffilesystem-concepts](https://github.com/scivision/ffilesystem-concepts).\n\n## Compiler support\n\nFfilesystem supports compilers including:\n\n* GCC \u0026ge; 7 (gcc/g++, gfortran)\n* LLVM Clang \u0026ge; 9 (clang/clang++, flang or gfortran)\n* Intel oneAPI \u0026ge; 2023.1 (icx, icpx, ifx)\n* Intel Classic \u0026ge; 2021.9 (icpc, ifort)\n* AMD AOCC (clang/clang++, flang)\n* NVIDIA HPC SDK (nvc++, nvfortran)\n* Visual Studio (C/C++)\n* Cray: using Cray compilers alone (cc, CC, ftn) or using GCC or Intel backend\n\nTo help debug with older compilers, disable C++ `\u003cfilesystem\u003e`:\n\n```sh\ncmake -Bbuild -Dffilesystem_cpp=off\n```\n\n### libstdc++\n\nSome systems have broken, obsolete, or incompatible libstdc++.\n\n**Intel**: If Intel compiler linker errors use GCC \u003e= 9.1.\nThis can be done by setting environment variable CXXFLAGS to the top level GCC \u003e= 9.1 directory.\nSet environment variable CXXFLAGS for\n[Intel GCC toolchain](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/compatibility-options/gcc-toolchain.html)\nlike:\n\n```sh\nexport CXXFLAGS=--gcc-toolchain=/opt/rh/gcc-toolset-10/root/usr/\n```\n\nwhich can be determined like:\n\n```sh\nscl enable gcc-toolset-10 \"which g++\"\n```\n\n## Build\n\nFfilesystem can be built with CMake, Meson, or Fortran Package Manager (FPM).\n\n\"libffilesystem.a\" is the library binary built that contains the Fortran \"filesystem\" module--it is the only binary you need to use in your project.\n\nPlease see the [API docs](./API.md) for extensive list of functions/subroutines.\n\nUse any one of these methods to build Ffilesystem.\nThe self-tests are optional and not built by default.\nSome of the tests use GoogleTest framework.\n\n### CMake\n\n```sh\ncmake -B build\ncmake --build build\n```\n\n\nOptionally, build and run the self-tests:\n\n```sh\ncmake -B build -Dffilesystem_BUILD_TESTING=on\ncmake --build build\nctest --test-dir build\n```\n\nThe default library with CMake is static; to build shared library:\n\n```sh\ncmake -B build -DBUILD_SHARED_LIBS=on\n...\n```\n\n### Meson\n\n```sh\nmeson setup build\nmeson compile -C build\n```\n\nOptionally, build and run the self-tests:\n\n```sh\nmeson setup -Dtest=true build --reconfigure\nmeson test -C build\n```\n\nThe default library with Meson is shared; to build static library:\n\n```sh\nmeson setup -Ddefault_library=static build\nmeson compile -C build\n```\n\n---\n\nFortran Package Manager (FPM):\n\n```sh\nfpm --cxx-flag=-std=c++17 build\n# c++17 is the minimum, can use newer\n```\n\n---\n\nGNU Make:\n\n```sh\nmake\n```\n\nWe provide Fortran REPL \"filesystem_cli\" and C++ REPL \"fs_cli\" for interactive testing of Ffilesystem routines.\n\n### Build options\n\nFortran \"filesystem\" module contains OPTIONAL (enabled by default) Fortran type \"path_t\" that contains properties and methods.\nThe \"path_t\" type uses getter and setter procedure to access the path as a string `character(:), allocatable`.\n\n```fortran\nuse filesystem, only : path_t\n\ntype(path_t) :: p\n\np = path_t(\"my/path\")  !\u003c setter\n\nprint *, \"path: \", p%path() !\u003c getter\n```\n\nThe CMake and Meson scripts detect if Fortran 2003 `type` is available and enable `path_t` by default.\nTo manually enable / disable `path_t` with CMake set command option `cmake -DHAVE_F03TYPE=1` or `cmake -DHAVE_F03TYPE=0` respectively.\n\nBy default `stat()` is used on non-Windows systems to get file information.\nOn glibc systems,\n[statx()](https://www.man7.org/linux/man-pages/man2/statx.2.html)\nmay be used if available by setting build option\n\n```sh\ncmake -Dffilesystem_statx=true -Bbuild\n\n# or\n\nmeson setup -Dstatx=true build\n```\n\n## Self test\n\nThe optional self-tests provide reasonable coverage of the Ffilesystem library.\nSeveral of the tests use `argv[0]` as a test file.\nWe are aware of the shortcomings of `argv[0]` to get the executable name.\nWe provide the function `fs_exepath()` to get the executable path reliably.\n\n## Usage from other projects\n\nThe [example](./example) directory contains a use pattern from external projects.\nOne can either `cmake --install build` ffilesystem or use CMake ExternalProject or\n[FetchContent](https://gist.github.com/scivision/245a1f32498d15a87a507051857327d9)\nfrom the other project.\nTo find ffilesystem in your CMake project:\n\n```cmake\nfind_package(ffilesystem CONFIG REQUIRED)\n```\n\nCMake package variables `ffilesystem_cpp` and `ffilesystem_fortran` indicate whether ffilesystem was built with C++ `\u003cfilesystem\u003e` and/or Fortran support.\n\n[ffilesystem.cmake](./cmake/ffilesystem.cmake)\nwould be included from the other project to find or build Ffilesystem automatically.\nIt provides the appropriate imported targets for shared or static builds, including Windows DLL handling.\n\n## Notes\n\nGCC 6.x and older aren't supported due to lack of C++17 string_view support.\n\n### Possible future features\n\nUse statx() if available to inquire if a file is encrypted or compressed, etc.\n\n### Other C++ filesystem libraries\n\nFfilesystem emphasizes simplicity and reasonable performance and reliability for scientific computing, particularly on HPC systems.\nA highly performance-oriented C++ low-level no TOCTOU filesystem library is\n[LLFIO](https://github.com/ned14/llfio).\nAn older C++ object-oriented interface is\n[CppFS](https://github.com/cginternals/cppfs).\n\nOther implementations of C++ filesystem include:\n\n* [Boost.Filesystem](https://www.boost.org/doc/libs/1_86_0/libs/filesystem/doc/index.htm) what the stdlib filesystem is based on, often tries newer features. [Boost.Filesystem source code](https://github.com/boostorg/filesystem)\n* [ghc-filesystem](https://github.com/gulrak/filesystem) for older compilers.\n* deprecated `\u003cexperimental/filesystem\u003e` is missing vital lexical operations.\n\n### Other Fortran filesystem libraries\n\nOther Fortran libraries that provide interfaces to filesystems include the following.\nGenerally they have noticeably fewer functions than Ffilesystem.\nThey typically implement many functions in Fortran, where with Ffilesystem we implement in C++ or C++ `\u003cfilesystem\u003e` if available.\nFfilesystem Fortran code is optional, and is just a thin wrapper around the C++ functions.\n\n* [stdlib_os](https://github.com/MarDiehl/stdlib_os)\n* [fortyxima](https://bitbucket.org/aradi/fortyxima/src/develop/)\n* [Fortran-stdlib](https://github.com/fortran-lang/stdlib/issues/201)\n* [M_system](https://github.com/urbanjost/M_system) focuses on interfaces to libc\n\n---\n\nThere is no \"is_musl()\" function due to MUSL designers\n[not providing](https://stackoverflow.com/questions/58177815/how-to-actually-detect-musl-libc)\na\n[MUSL feature macro](https://wiki.musl-libc.org/faq.html).\n\n### Windows\n\nLike\n[Microsoft STL](https://github.com/microsoft/STL/issues/2256),\nFfilesystem is not designed for UNC \"long\" paths.\nWe recommend using a UNC path to a mapped drive letter.\nWindows\n[long paths](https://github.com/microsoft/STL/issues/1921)\nare not implemented due to\n[limitations](https://www.boost.org/doc/libs/1_86_0/libs/filesystem/doc/reference.html#windows-path-prefixes).\n\nEnable Windows\n[developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)\nto use symbolic links if needed.\n\n### C++ filesystem discussion\n\nSecurity\n[research](https://www.reddit.com/r/cpp/comments/151cnlc/a_safety_culture_and_c_we_need_to_talk_about/?rdt=62365)\nled to\n[TOCTOU](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use)-related\npatches to the C++ filesystem library in various C++ standard library implementations noted in that discussion.\nFfilesystem does NOT use remove_all, which was the TOCTOU concern addressed above.\n\nSince the underlying C++ filesystem is not thread-safe, race conditions can occur if multiple threads are accessing the same filesystem object regardless of the code language used in the Ffilesystem library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscivision%2Fffilesystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscivision%2Fffilesystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscivision%2Fffilesystem/lists"}