Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a filesystem file in C++ [closed]

Is there a way to create a filesystem file that can be mounted in C++? I want to make a file containing a NTFS filesystem and mount it to a new partition. I want this done in C++ in Windows. Is there a library and perhaps some code examples that does this? I know windows has the diskpart tool which does exactly that but does it have a C++ API or something like that?

like image 447
Ciprian Florin Avatar asked Sep 05 '25 03:09

Ciprian Florin


1 Answers

To really "mount" the filesystem (ie. to be able to just "fopen" something inside that filesystem) you need support from the kernel. Either you let your operating system take care of it completely (e.g the VHD commands on windows; example use on stackoverflow). Alternatively can use libfuse/winfsp to interact with the kernel more directly, but afaik that requires a custom kernel driver.

If you have an image file with some filesystem inside and you just want to look whats inside, but don't need the C/C++ standard library commands (fopen, ifstream, etc.) to work, then something that can specifically read/write that combination of image file format and filesystem would also suffice.

For C# there would be the DiscUtils library which might do what you want, but I'm not aware of a similar c/c++ library with NTFS support.

like image 72
kritzikratzi Avatar answered Sep 07 '25 19:09

kritzikratzi