/////FUNCTIONS FOR LUA LIB////////////////////// * @param Size is Size is Zero Means Read All From Current Offset,else means read SizeBytes from current Offset */
| 128 | @param Size is Size is Zero Means Read All From Current Offset,else means read SizeBytes from current Offset |
| 129 | */ |
| 130 | FORCEINLINE int ReadSize(TArray<uint8>& Buffer, uint32 Size = 0) |
| 131 | { |
| 132 | TArray<uint8> DataBuffer; |
| 133 | static const int64 DataBufferSize = 10 * 1024; |
| 134 | //when file is valid and is read mode or FILEWRITE_AllowRead flag is set |
| 135 | if (this->IsReadable()) |
| 136 | { |
| 137 | DataBuffer.AddUninitialized(DataBufferSize);//10K |
| 138 | //get file size |
| 139 | int64 FileSize = FILE->TotalSize(); |
| 140 | //get current offset |
| 141 | int64 CurPos = FILE->Tell(); |
| 142 | //compute readable target size(size left to be read from current offset) |
| 143 | int64 TargetSize = FileSize - CurPos; |
| 144 | int64 ReadSize = 0; |
| 145 | if (0 < Size) |
| 146 | { |
| 147 | TargetSize = FMath::Min(TargetSize, (int64)Size); |
| 148 | } |
| 149 | while (TargetSize) |
| 150 | { |
| 151 | CurPos = FILE->Tell(); |
| 152 | FILE->Serialize(DataBuffer.GetData(), FMath::Min(TargetSize, DataBufferSize)); |
| 153 | ReadSize = FILE->Tell() - CurPos; |
| 154 | TargetSize -= ReadSize; |
| 155 | Buffer.Append(DataBuffer.GetData(), ReadSize); |
| 156 | } |
| 157 | } |
| 158 | return Buffer.Num(); |
| 159 | } |
| 160 | |
| 161 | //ReadLine |
| 162 | FORCEINLINE void ReadLine(lua_State *L, bool bWithNewLineCh = false) |
no test coverage detected