Page 1 of 1
Resource file deletion and creation
Posted: Sat Dec 06, 2025 9:38 pm
by slapin
Hi, all!
For simple editor purposes I need to edit some files in Ogre resource system. I found a way to find file path,
but I found no way to delete/unlink the file to overwrite it. Is there Ogre helpers for that or I should do that on my own?
That also needed for game save system too...
Re: Resource file deletion and creation
Posted: Sat Dec 06, 2025 11:36 pm
by slapin
Ogre::FileSystemLayer is perfect for file operations. Found it again. Sorry for all the noise.
Code: Select all
Ogre::FileSystemLayer::removeFile("world_map.png");
Full code to save png from image img finding the path in resource system:
Code: Select all
Ogre::String group =
Ogre::ResourceGroupManager::getSingleton()
.findGroupContainingResource("world_map.png");
Ogre::FileInfoListPtr fileInfoList(
Ogre::ResourceGroupManager::getSingleton()
.findResourceFileInfo(group, "world_map.png"));
OgreAssert(fileInfoList->size() == 1,
"worpd_map.png should be there and only once");
Ogre::String path = fileInfoList->at(0).archive->getName() +
"/" + "world_map.png";
Ogre::FileSystemLayer::removeFile(path);
img.save(path);
So I'm fully packed now.