Cannot create Resource in Windows 8

Problems building or running the engine, queries about how to use features etc.
Post Reply
Dark_eye
Gnoblar
Posts: 21
Joined: Thu Jun 25, 2009 9:27 pm

Cannot create Resource in Windows 8

Post by Dark_eye » Wed Jun 05, 2013 2:16 pm

Hi all,

I came across a strange situation when I tried to call the function

Code: Select all

void Ogre::TerrainGroup::saveAllTerrains(bool onlyIfModified, bool replaceManualFilenames = true)
The problem is that it always throws the following exception:

Code: Select all

OGRE EXCEPTION(5:ItemIdentityException): Cannot find a writable location in group General in ResourceGroupManager::createResource at ..\..\..\..\OgreMain\src\OgreResourceGroupManager.cpp (line 845)
Doing some research I found that every project folder has the Read-Only attribute turned on. After some search, learned that is this something inherent to Windows 8 (and other versions), but not implemented as the ussual way, because MS Explorer completely ignores that flag, allowing to delete, rename and so... The flag is only used ¿To fool malware? ¿To indicate that is necessary to read the desktop.ini?, I dont know, but those are some ideas I got from reading some forums and MS pages.

Now the trouble comes, when reading the Ogre Source Code for that function:

Code: Select all

for (LocationList::iterator li = grp->locationList.begin(); 
			li != grp->locationList.end(); ++li)
		{
			Archive* arch = (*li)->archive;

			[b]if (!arch->isReadOnly() && [/b]
				(locationPattern.empty() || StringUtil::match(arch->getName(), locationPattern, false)))
			{
				if (!overwrite && arch->exists(filename))
					OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, 
						"Cannot overwrite existing file " + filename, 
						"ResourceGroupManager::createResource");
				
				// create it
				DataStreamPtr ret = arch->create(filename);
				grp->addToIndex(filename, arch);


				return ret;
			}
		}

		OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 
			"Cannot find a writable location in group " + groupName, 
			"ResourceGroupManager::createResource");
Ogre checks if the directory is Read-Only to allow the app write the resource, but, if ALL the folders are Read-Only in Windows 8 by default (though being possible to write in), Ogre will always fail to write such resource.

So, that's the point, its a Ogre's bug (not updated to work with Win8) or there is some way I can avoid this?

Thanks ;)
0 x

Dark_eye
Gnoblar
Posts: 21
Joined: Thu Jun 25, 2009 9:27 pm

Re: Cannot create Resource in Windows 8

Post by Dark_eye » Fri Jun 07, 2013 2:04 am

Nobody has even ran this on Window 8?
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Cannot create Resource in Windows 8

Post by masterfalcon » Fri Jun 07, 2013 5:42 am

Please file a bug so we don't lose track of it. https://ogre3d.atlassian.net
0 x

Dark_eye
Gnoblar
Posts: 21
Joined: Thu Jun 25, 2009 9:27 pm

Re: Cannot create Resource in Windows 8

Post by Dark_eye » Fri Jun 07, 2013 10:53 am

0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7152
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 19

Re: Cannot create Resource in Windows 8

Post by Kojack » Fri Jun 07, 2013 12:24 pm

What are the absolute paths of the resource groups you are trying to write to?
0 x

User avatar
Zonder
Ogre Magi
Posts: 1133
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 22

Re: Cannot create Resource in Windows 8

Post by Zonder » Fri Jun 07, 2013 12:30 pm

Does it work when you "Run as Administrator"?
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...

Dark_eye
Gnoblar
Posts: 21
Joined: Thu Jun 25, 2009 9:27 pm

Re: Cannot create Resource in Windows 8

Post by Dark_eye » Fri Jun 07, 2013 4:00 pm

The absolute paths are: C:\OgreSDK\OgreSDK_vc11_v1-9-0unstable\media and its subfolders.
And no, tried to run as Admin without result, wich is logical, since write permission is always granted, but Ogre rejects to write in a folder with RO flag.
0 x

User avatar
Zonder
Ogre Magi
Posts: 1133
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 22

Re: Cannot create Resource in Windows 8

Post by Zonder » Fri Jun 07, 2013 10:45 pm

As far as I know NTFS doesn't support "Read Only" flags on folders (FAT / FAT32 did). The code need checking this should be a paper cut I think.
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7152
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 19

Re: Cannot create Resource in Windows 8

Post by Kojack » Fri Jun 07, 2013 11:44 pm

Ogre checks if the directory is Read-Only to allow the app write the resource, but, if ALL the folders are Read-Only in Windows 8 by default (though being possible to write in), Ogre will always fail to write such resource.
Actually ogre doesn't check if a directory is read only.
The archive system assumes every folder is read only if you don't tell it otherwise when adding resource locations. Ogre never looks at the directory itself.

If you do a standard resource.cfg load like this:

Code: Select all

cf.load("resources.cfg");

	// Go through all sections & settings in the file
	Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

	Ogre::String secName;
	while (seci.hasMoreElements())
	{
		secName = seci.peekNextKey();
		Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
		for (Ogre::ConfigFile::SettingsMultiMap::iterator i = settings->begin(); i != settings->end(); ++i)
		{
			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(i->second, i->first, secName);
		}
	}
then every resource path is read only and you'll get your error when createResource is called (I just tested it on windows 7, it gives that error).

You need to pass a flag to addResourceLocation above to make it writable.
Like this:

Code: Select all

cf.load("resources.cfg");

	// Go through all sections & settings in the file
	Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

	Ogre::String secName;
	while (seci.hasMoreElements())
	{
		secName = seci.peekNextKey();
		Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
		for (Ogre::ConfigFile::SettingsMultiMap::iterator i = settings->begin(); i != settings->end(); ++i)
		{
			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(i->second, i->first, secName,false,i->second.find(".zip")!=std::string::npos);
		}
	}
The new 4th parameter is the recursive flag, the last parameter is the readonly flag, I give it false for any folder that's now a zip file (trying to open a zip archive as writable will crash ogre with a null dereference).
Now it works without the error.
0 x

Dark_eye
Gnoblar
Posts: 21
Joined: Thu Jun 25, 2009 9:27 pm

Re: Cannot create Resource in Windows 8

Post by Dark_eye » Sat Jun 08, 2013 5:47 pm

Aha! That surely will do the trick, will try it soon.
0 x

dirkmitt
Halfling
Posts: 40
Joined: Fri Sep 15, 2006 3:40 am
Contact:

Re: Cannot create Resource in Windows 8

Post by dirkmitt » Sat May 02, 2015 6:21 pm

Hello.

This exact problem happens to me under Windows 8.1 , when I try to get the Terrain Sample to work, using the RenderSystemGL3Plus.

I'm using MinGW32 to compile Ogre 1.10 from source, and CMake 3.1.3 , and have actually been having a surprising amount of success with that.

But where would you recommend that I should apply this patch you recommended? I don't think that it's been merged.

Dirk
0 x

Post Reply