浏览代码

File: unsigned char to u8

1vanK 3 年之前
父节点
当前提交
a52bb0892f
共有 2 个文件被更改,包括 10 次插入10 次删除
  1. 8 8
      Source/Urho3D/IO/File.cpp
  2. 2 2
      Source/Urho3D/IO/File.h

+ 8 - 8
Source/Urho3D/IO/File.cpp

@@ -179,13 +179,13 @@ unsigned File::Read(void* dest, unsigned size)
         // If not using a compressed package file, buffer file reads on Android for better performance
         // If not using a compressed package file, buffer file reads on Android for better performance
         if (!readBuffer_)
         if (!readBuffer_)
         {
         {
-            readBuffer_ = new unsigned char[READ_BUFFER_SIZE];
+            readBuffer_ = new u8[READ_BUFFER_SIZE];
             readBufferOffset_ = 0;
             readBufferOffset_ = 0;
             readBufferSize_ = 0;
             readBufferSize_ = 0;
         }
         }
 
 
         unsigned sizeLeft = size;
         unsigned sizeLeft = size;
-        unsigned char* destPtr = (unsigned char*)dest;
+        u8* destPtr = (u8*)dest;
 
 
         while (sizeLeft)
         while (sizeLeft)
         {
         {
@@ -211,13 +211,13 @@ unsigned File::Read(void* dest, unsigned size)
     if (compressed_)
     if (compressed_)
     {
     {
         unsigned sizeLeft = size;
         unsigned sizeLeft = size;
-        auto* destPtr = (unsigned char*)dest;
+        u8* destPtr = (u8*)dest;
 
 
         while (sizeLeft)
         while (sizeLeft)
         {
         {
             if (!readBuffer_ || readBufferOffset_ >= readBufferSize_)
             if (!readBuffer_ || readBufferOffset_ >= readBufferSize_)
             {
             {
-                unsigned char blockHeaderBytes[4];
+                u8 blockHeaderBytes[4];
                 ReadInternal(blockHeaderBytes, sizeof blockHeaderBytes);
                 ReadInternal(blockHeaderBytes, sizeof blockHeaderBytes);
 
 
                 MemoryBuffer blockHeader(&blockHeaderBytes[0], sizeof blockHeaderBytes);
                 MemoryBuffer blockHeader(&blockHeaderBytes[0], sizeof blockHeaderBytes);
@@ -226,8 +226,8 @@ unsigned File::Read(void* dest, unsigned size)
 
 
                 if (!readBuffer_)
                 if (!readBuffer_)
                 {
                 {
-                    readBuffer_ = new unsigned char[unpackedSize];
-                    inputBuffer_ = new unsigned char[LZ4_compressBound(unpackedSize)];
+                    readBuffer_ = new u8[unpackedSize];
+                    inputBuffer_ = new u8[LZ4_compressBound(unpackedSize)];
                 }
                 }
 
 
                 /// \todo Handle errors
                 /// \todo Handle errors
@@ -294,7 +294,7 @@ unsigned File::Seek(unsigned position)
         // Skip bytes
         // Skip bytes
         else if (position >= position_)
         else if (position >= position_)
         {
         {
-            unsigned char skipBuffer[SKIP_BUFFER_SIZE];
+            u8 skipBuffer[SKIP_BUFFER_SIZE];
             while (position > position_)
             while (position > position_)
                 Read(skipBuffer, Min(position - position_, SKIP_BUFFER_SIZE));
                 Read(skipBuffer, Min(position - position_, SKIP_BUFFER_SIZE));
         }
         }
@@ -372,7 +372,7 @@ unsigned File::GetChecksum()
     Seek(0);
     Seek(0);
     while (!IsEof())
     while (!IsEof())
     {
     {
-        unsigned char block[1024];
+        u8 block[1024];
         unsigned readBytes = Read(block, 1024);
         unsigned readBytes = Read(block, 1024);
         for (unsigned i = 0; i < readBytes; ++i)
         for (unsigned i = 0; i < readBytes; ++i)
             checksum_ = SDBMHash(checksum_, block[i]);
             checksum_ = SDBMHash(checksum_, block[i]);

+ 2 - 2
Source/Urho3D/IO/File.h

@@ -105,9 +105,9 @@ private:
     SDL_RWops* assetHandle_;
     SDL_RWops* assetHandle_;
 #endif
 #endif
     /// Read buffer for Android asset or compressed file loading.
     /// Read buffer for Android asset or compressed file loading.
-    SharedArrayPtr<unsigned char> readBuffer_;
+    SharedArrayPtr<u8> readBuffer_;
     /// Decompression input buffer for compressed file loading.
     /// Decompression input buffer for compressed file loading.
-    SharedArrayPtr<unsigned char> inputBuffer_;
+    SharedArrayPtr<u8> inputBuffer_;
     /// Read buffer position.
     /// Read buffer position.
     unsigned readBufferOffset_;
     unsigned readBufferOffset_;
     /// Bytes in the current read buffer.
     /// Bytes in the current read buffer.