Simple Virtual Filesystem in C/C++

前端 未结 6 1872
一个人的身影
一个人的身影 2020-12-31 15:02

I would like to implement a very simple Virtual Filesystem (VFS) which supports some basic file system operation like fwrite, fopen, fput, etc. The VFS is an abstraction lay

6条回答
  •  孤城傲影
    2020-12-31 15:42

    If you're looking for a way to abstract yourself from the properties of the filesystem you're using (path separators etc.), and if you're happy with a C++-only solution, take a look at Boost.Filesystem.

    Paths can be specified in the portable generic path format (basically POSIX format) and are automatically converted to the native format:

    path my_path( "some_dir/file.txt" );
    

    Elements can be concatenated onto the path using the / operator, and the result can then directly be used to open a file:

    ifstream file1( my_path / "foo/bar" );
    

    What's more, this functionality is part of Technical Report 2, meaning that it will likely make its way into the standard library.

提交回复
热议问题