Compare commits

...

3 commits

3 changed files with 12 additions and 1 deletions

View file

@ -45,6 +45,10 @@ auto BinaryReader::position() -> Long {
return _ftelli64(_file); return _ftelli64(_file);
} }
auto BinaryReader::seek(Long position) -> bool {
return _fseeki64(_file, position, SEEK_SET) == 0;
}
void BinaryReader::closeFile() { void BinaryReader::closeFile() {
std::fclose(_file); std::fclose(_file);
_file = nullptr; _file = nullptr;

View file

@ -36,6 +36,8 @@ class BinaryReader {
auto eof() -> bool; auto eof() -> bool;
auto position() -> Long; auto position() -> Long;
auto seek(Long position) -> bool;
void closeFile(); void closeFile();
auto readChar(char& value) -> bool; auto readChar(char& value) -> bool;
@ -51,6 +53,11 @@ class BinaryReader {
auto readDouble(Double& value) -> bool; auto readDouble(Double& value) -> bool;
auto readArray(Containers::Array<char>& array, std::size_t count) -> bool; auto readArray(Containers::Array<char>& array, std::size_t count) -> bool;
template<typename T>
auto readValue(T& value) -> bool {
return fread(&value, sizeof(T), 1, _file) == sizeof(T);
}
template<std::size_t S> template<std::size_t S>
auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool { auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool {
return std::fread(array.data(), sizeof(char), S, _file) == S; return std::fread(array.data(), sizeof(char), S, _file) == S;

View file

@ -40,7 +40,7 @@ struct Crc32 {
}; };
const Containers::StaticArray<256, UnsignedInt> Crc32::table = []{ const Containers::StaticArray<256, UnsignedInt> Crc32::table = []{
UnsignedInt polynomial = 0xEDB88320; UnsignedInt polynomial = 0xEDB88320u;
Containers::StaticArray<256, UnsignedInt> temp{ValueInit}; Containers::StaticArray<256, UnsignedInt> temp{ValueInit};
for(UnsignedInt i = 0; i < 256; i++) { for(UnsignedInt i = 0; i < 256; i++) {