| 211 | |
| 212 | |
| 213 | FORCEINLINE void ReadBytes(lua_State* L, int32 TryReadNumber) |
| 214 | { |
| 215 | if (0 >= TryReadNumber) |
| 216 | { |
| 217 | //if current is the end of file |
| 218 | if (FILE->AtEnd()) |
| 219 | { |
| 220 | lua_pushnil(L); |
| 221 | } |
| 222 | else |
| 223 | {//return an empty lua_string |
| 224 | lua_pushliteral(L, ""); |
| 225 | } |
| 226 | } |
| 227 | else |
| 228 | { |
| 229 | //if current is the end of file |
| 230 | if (FILE->AtEnd()) |
| 231 | { |
| 232 | lua_pushnil(L); |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | //try read number of bytes (string buffer) |
| 237 | TArray<uint8> Buffer; |
| 238 | int32 ReadNumber = this->ReadSize(Buffer, TryReadNumber); |
| 239 | if (0 >= ReadNumber) |
| 240 | { |
| 241 | lua_pushnil(L); |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | lua_pushlstring(L, (const char*)Buffer.GetData(), ReadNumber); |
| 246 | } |
| 247 | |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | private: |
| 252 | bool HelperCheckFileMode(const FString& Mode, uint32& OutFlags, bool& OutIsWrite) |
| 253 | { |
no test coverage detected