Ogre::FileSystemArchive::load() tries to create temporary file to determine is it created in readonly or readwrite mode. This mechanism is bad not only because it brokes Apple`s guidelines but also it is unreliable (RO/RW mode and access rights for subfolders could be different from RO/RW mode and access rights for parent folder) and still have unnecessary file creation overhead.
Additionally Ogre::FileSystemArchive::open() has bug in implementation that always open stream in readonly mode if location was determined to be read-write
Code: Select all
DataStreamPtr FileSystemArchive::open(const String& filename, bool readOnly) const
{
<...>
if (!readOnly && isReadOnly())
{
mode |= std::ios::out;
rwStream = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
rwStream->open(full_path.c_str(), mode);
baseStream = rwStream;
}
else
{
roStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)();
roStream->open(full_path.c_str(), mode);
baseStream = roStream;
}
Code: Select all
ResourceGroupManager::addResourceLocation(..., bool readOnly = true)
ArchiveManager::load(..., bool readOnly)
FileSystemArchiveFactory::createInstance(..., bool readOnly)
FileSystemArchive::FileSystemArchive(..., bool readOnly)
To fix bug in FileSystemArchive::open() code above should be replaced with
Code: Select all
DataStreamPtr FileSystemArchive::open(const String& filename, bool readOnly) const
{
<...>
if (!readOnly && isReadOnly())
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Cannot open a file in read-write mode in a read-only archive",
"FileSystemArchive::open");
}
if(!readOnly)
{
mode |= std::ios::out;
rwStream = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
rwStream->open(full_path.c_str(), mode);
baseStream = rwStream;
}
else
{
roStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)();
roStream->open(full_path.c_str(), mode);
baseStream = roStream;
}