Search code examples
c++std-filesystem

Can `std::filesystem` work on bare-metal?


Recently, I read How does std::filesystem work on every OS?

I know std::filesystem can be used on various OS.

In other words, std::filesystem is a cross-platform library which can be used for accessing files, because the file system has been implemented by the OS vendors.

But what about bare-metal?

AFAIK, bare-metal environment has no function (or very simple) for filesystem.

As the title, can std::filesystem work on bare-metal?


Solution

  • A freestanding implementation isn't required to provide <filesystem>.

    Having said that, if there isn't such thing as "a file" or "a directory" on the target, then e.g. exists is really easy to implement:

    namespace std {
        bool exists( const std::filesystem::path& p ) { return false; }
    }
    

    std::filesystem has been implemented by OS vendors.

    Not by vendors of OSs, but by vendors of C++ implementations. Microsoft is a special case, because they sell both, but the Visual C++ team is separate from the Windows team.