mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-19 19:16:34 +00:00
Correct typo; check CRC.
This commit is contained in:
@@ -598,7 +598,7 @@
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>mood</string>
|
||||
<string>moof</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>floppy35</string>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "MOOF.hpp"
|
||||
|
||||
#include "Numeric/CRC.hpp"
|
||||
|
||||
using namespace Storage::Disk;
|
||||
|
||||
MOOF::MOOF(const std::string &file_name) :
|
||||
@@ -20,6 +22,14 @@ MOOF::MOOF(const std::string &file_name) :
|
||||
if(!file_.check_signature<SignatureType::Binary>(signature)) {
|
||||
throw Error::InvalidFormat;
|
||||
}
|
||||
|
||||
// Test the file's CRC32.
|
||||
const auto crc = file_.get_le<uint32_t>();
|
||||
post_crc_contents_ = file_.read(size_t(file_.stats().st_size - 12));
|
||||
const uint32_t computed_crc = CRC::CRC32::crc_of(post_crc_contents_);
|
||||
if(crc != computed_crc) {
|
||||
throw Error::InvalidFormat;
|
||||
}
|
||||
}
|
||||
|
||||
HeadPosition MOOF::maximum_head_position() const {
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
|
||||
private:
|
||||
mutable Storage::FileHolder file_;
|
||||
std::vector<uint8_t> post_crc_contents_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user