mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Ensures final few bytes of a CAS file aren't dropped.
This commit is contained in:
parent
0a079b0f94
commit
cbba6a5595
@ -52,12 +52,18 @@ CAS::CAS(const char *file_name) {
|
||||
// Add a new chunk for the new incoming data.
|
||||
active_file->chunks.emplace_back();
|
||||
|
||||
// Keep going until another header arrives.
|
||||
// Keep going until another header arrives or the file ends.
|
||||
while(std::memcmp(lookahead, header_signature, sizeof(header_signature)) && !file.eof()) {
|
||||
active_file->chunks.back().push_back(lookahead[0]);
|
||||
get_next(file, lookahead, 1);
|
||||
}
|
||||
|
||||
// If the file ended, flush the lookahead.
|
||||
if(file.eof()) {
|
||||
for(int index = 0; index < 8; index++)
|
||||
active_file->chunks.back().push_back(lookahead[index]);
|
||||
}
|
||||
|
||||
switch(active_file->type) {
|
||||
case Block::ASCII:
|
||||
// ASCII files have as many chunks as necessary, the final one being back filled
|
||||
|
Loading…
x
Reference in New Issue
Block a user