Jump to content

dynamically adding umount in C++


photo

Recommended Posts

Hello,

I want to dynamically add in my project an external folder using a mountpoint in runtime (without creating a .umount file).
I tried using Unigine::Filesystem::addMount, but it didn't seem to work.
Can you provide an example of a use case in C++ for this use of mountpoints

Thanks!
Pierre

Link to comment
Hello Pierre,

you need to add a blob file with the desired path and the umount extension.
Calling createMount on the desired path will work then without creating an additional file.

1. umount_filepath = virtual_path + ".umount"
2. FileSystem::addBlobFile(umount_filepath)
3. FileSystem::createMount(absolute_path, virtual_path, access)

Best regards

Link to comment

Hello Devrom, thanks for your answer!

I tried using blob file, but I still can't get the result I want.
In fact, I don't want to create a .umount file on disk, but dynamically load an external folder that is specified during runtime depending on the path I'm giving to my program.

Thanks!
Pierre

Link to comment
Quote

I tried using blob file, but I still can't get the result I want.

Can you share a code sample?
 

Quote

In fact, I don't want to create a .umount file on disk, but dynamically load an external folder that is specified during runtime depending on the path I'm giving to my program.

That is our use case, too. A blob file is a binary representation of a file in memory. If you add a blob file without a counterpart existing on disk the file will only exist in memory. As soon as you call createMount the engine will write to the specified path with blob files having a higher priority than files on disk. Therefore, no file will be written to disk. At least thats my understanding of the engine internals.

 

Link to comment
Quote

Can you share a code sample?

std::string absolute_path = "D:/absolute/path";
auto virtual_path  = folderName + "/";
auto umount_filepath = virtual_path + folderName + ".umount";
auto blob = Unigine::FileSystem::addBlobFile(umount_filepath.c_str());
auto mount = Unigine::FileSystem::createMount(absolute_path.c_str(), virtual_path.c_str(), Unigine::FileSystemMount::ACCESS_READONLY);

According to your description of blob files, the .umount file will be created in memory and FileSystem::createMount will return nullptr because the "file" is already created.
Is there is way to dynamically specify the content (json) of the umount blobFile?

Thank you
Pierre

Link to comment
auto virtual_path  = folderName + "/";
auto umount_filepath = virtual_path + folderName + ".umount";

These paths need to be identical except for the extension. The root of your mount starts from the umount file. I think your virtual_path should be: folderName + "/" + folderName

Edited by devrom
  • Thanks 1
Link to comment

We found the issue, we just replaced the virtual_path by the umount_filepath to have the same path like you said.

Thanks!

Link to comment
×
×
  • Create New...