C++/C 虚拟/可嵌入文件系统 [交叉兼容(库)]

C++/C Virtual/Embeddable File System [Cross Compatible (Library)]?

本文关键字:虚拟 文件系统 C++      更新时间:2023-10-16

我想尝试一些虚拟文件系统,例如拥有 1 个存储所有数据的文件(1 个文件 = 虚拟磁盘)。例如,我可以打开虚拟磁盘并将文件放入其中,将数据写入文件,从文件中读取数据,打开文件并使用fseek等。

有没有我可以使用的库?许可证等并不重要。我只是想在我的机器上测试它,因为我很无聊,所以我想在 C++/C 中尝试这个。

提前感谢! :)

如果库只是 windows,那也没关系,也许我会找到一个 linux 库,这样我就可以制作 2 个项目?


编辑:感谢BRPocock,我知道我的问题有点不清楚。我真正想要的是一个能够在库已经提供的 VFS 上存储文件、读取文件和执行文件操作的库。当然还有安装。所以,如果有一个库可以在C++中为我提供此功能,我会说:

OpenVirtualDrive(const name[]);//
CloseVirtualDrive(handle);//
fopen(const name[], mode);//open file, return handle
fclose(handle);//close handle
ftemp(); //open file as temporary file
fremove(const name[]);//delete file
fwrite(handle, array[]);//write array to file
fread(handle, array[], size = sizeof array, pack = false);//read from file
fputchar(handle, value, utf8 = true);//put char into file
fgetchar(handle, value, utf8 = true);//read char from file, move pointer
fblockwrite(handle, const buffer[], size = sizeof buffer);//write block
fblockread(handle, buffer[], size = sizeof buffer);//read block, move pointer
fseek(handle, position = 0, seek_whence: whence = seek_start);//move pointer
flength(handle);//size of file
fexist(const pattern[]);//check if file exists
fmatch(name[], const pattern[], index = 0, size = sizeof name);//search for file

这只是伪代码:P

Linux(以及许多BSD,我相信包括MacOSX)使用FUSE系统(http://fuse.sourceforge.net/)来提供这些类型的服务。你应该能够在"网上"上找到很多例子。

我相信在 Windows 上做同样事情的"接受"方法是将其编写为设备驱动程序可加载模块 ( .dll ) ...也许,快速的谷歌搜索指向 http://msdn.microsoft.com/en-us/windows/hardware/gg463062 作为起点。