Update MemoryIOWrapper.h

Make code more readable.
pull/2306/head^2
Kim Kulling 2019-01-22 20:47:24 +01:00 committed by GitHub
parent ad18cd9660
commit f8a23e128b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdint.h>
namespace Assimp {
#define AI_MEMORYIO_MAGIC_FILENAME "$$$___magic___$$$"
#define AI_MEMORYIO_MAGIC_FILENAME_LENGTH 17
@ -78,9 +79,11 @@ public:
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
ai_assert(nullptr != pvBuffer);
ai_assert(0 != pSize);
const size_t cnt = std::min(pCount,(length-pos)/pSize), ofs = pSize*cnt;
memcpy(pvBuffer,buffer+pos,ofs);
const size_t cnt = std::min( pCount, (length-pos) / pSize);
const size_t ofs = pSize * cnt;
::memcpy(pvBuffer,buffer+pos,ofs);
pos += ofs;
return cnt;
@ -161,7 +164,7 @@ public:
// -------------------------------------------------------------------
/** Tests for the existence of a file at the given path. */
bool Exists(const char* pFile) const override {
if (!strncmp(pFile,AI_MEMORYIO_MAGIC_FILENAME,AI_MEMORYIO_MAGIC_FILENAME_LENGTH)) {
if (0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
return true;
}
return existing_io ? existing_io->Exists(pFile) : false;
@ -177,7 +180,7 @@ public:
// -------------------------------------------------------------------
/** Open a new file with a given path. */
IOStream* Open(const char* pFile, const char* pMode = "rb") override {
if (!strncmp(pFile,AI_MEMORYIO_MAGIC_FILENAME,AI_MEMORYIO_MAGIC_FILENAME_LENGTH)) {
if ( 0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) {
created_stream = new MemoryIOStream(buffer, length);
return created_stream;
}