Resource file deletion and creation Topic is solved

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 339
Joined: Fri May 23, 2025 5:04 pm
x 24

Resource file deletion and creation

Post 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...

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 339
Joined: Fri May 23, 2025 5:04 pm
x 24

Re: Resource file deletion and creation

Post 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.