fix file caching issue
This commit is contained in:
@@ -112,7 +112,7 @@ struct b3PluginManagerInternalData
|
|||||||
b3BulletDefaultFileIO m_defaultFileIO;
|
b3BulletDefaultFileIO m_defaultFileIO;
|
||||||
|
|
||||||
b3PluginManagerInternalData()
|
b3PluginManagerInternalData()
|
||||||
: m_rpcCommandProcessorInterface(0), m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1), m_activeCollisionPluginUid(-1), m_numNotificationPlugins(0), m_activeFileIOPluginUid(-1)
|
: m_physicsDirect(0), m_rpcCommandProcessorInterface(0), m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1), m_activeCollisionPluginUid(-1), m_numNotificationPlugins(0), m_activeFileIOPluginUid(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -388,35 +388,37 @@ struct WrapperFileIO : public CommonFileIOInterface
|
|||||||
int childHandle = childFileIO->fileOpen(fileName, mode);
|
int childHandle = childFileIO->fileOpen(fileName, mode);
|
||||||
if (childHandle>=0)
|
if (childHandle>=0)
|
||||||
{
|
{
|
||||||
int fileSize = childFileIO->getFileSize(childHandle);
|
|
||||||
char* buffer = 0;
|
|
||||||
if (fileSize)
|
|
||||||
{
|
|
||||||
buffer = m_cachedFiles.allocateBuffer(fileSize);
|
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
int readBytes = childFileIO->fileRead(childHandle, buffer, fileSize);
|
|
||||||
if (readBytes!=fileSize)
|
|
||||||
{
|
|
||||||
if (readBytes<fileSize)
|
|
||||||
{
|
|
||||||
fileSize = readBytes;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
printf("WrapperFileIO error: reading more bytes (%d) then reported file size (%d) of file %s.\n", readBytes, fileSize, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
fileSize=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//potentially register a zero byte file, or files that only can be read partially
|
|
||||||
if (m_enableFileCaching)
|
if (m_enableFileCaching)
|
||||||
{
|
{
|
||||||
|
int fileSize = childFileIO->getFileSize(childHandle);
|
||||||
|
char* buffer = 0;
|
||||||
|
if (fileSize)
|
||||||
|
{
|
||||||
|
buffer = m_cachedFiles.allocateBuffer(fileSize);
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
|
int readBytes = childFileIO->fileRead(childHandle, buffer, fileSize);
|
||||||
|
if (readBytes!=fileSize)
|
||||||
|
{
|
||||||
|
if (readBytes<fileSize)
|
||||||
|
{
|
||||||
|
fileSize = readBytes;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
printf("WrapperFileIO error: reading more bytes (%d) then reported file size (%d) of file %s.\n", readBytes, fileSize, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
fileSize=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//potentially register a zero byte file, or files that only can be read partially
|
||||||
|
|
||||||
m_cachedFiles.registerFile(fileName, buffer, fileSize);
|
m_cachedFiles.registerFile(fileName, buffer, fileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
childFileIO->fileClose(childHandle);
|
childFileIO->fileClose(childHandle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user