Simple Virtual Filesystem in C/C++

前端 未结 6 1900
一个人的身影
一个人的身影 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:38

    Standard C has no such feature. Notice that the notion of "concrete OS" is also a bit vague: are Windows XP and Windows Vista the same "concrete OS", or different ones? Are CentOS and Ubuntu the same OS, or different ones?

    Apparently, you are only looking for API differences, so in most cases, you can probably ignore version differences and distribution differences (although both Windows and Linux grow new system calls from time to time). In this case, it is best to preprocessor conditional compilation - since the code making Linux-specific calls won't even compile on Windows.

    Traditionally, the system compilers have various macros predefined. Here are a few such macros, on respective systems: _WIN32, __linux, __linux__, __AIX__, __hpux, ... If you need to identify a specific system, you should ask again on SO.

提交回复
热议问题