🚧 Add debug message
This commit is contained in:
parent
12190f0ae8
commit
f64412ebfe
3 changed files with 20 additions and 7 deletions
|
@ -52,9 +52,15 @@ void getBytes(uint8_t* buffer, unsigned long numBytes, bool isLast) {
|
|||
remainingBytes -= availableBytes;
|
||||
|
||||
//If we've reached end of file, close file and open next file
|
||||
//Unless we've reached the end, in that case don't open next file in case we've reached the end of the last disk
|
||||
if (!isLast && file.offset == file.size) {
|
||||
openNextFile();
|
||||
if (file.offset == file.size) {
|
||||
closeCurrentFile();
|
||||
//Unless we've reached the end, in that case don't open next file in case we've reached the end of the last disk
|
||||
if (!isLast) {
|
||||
openNextFile();
|
||||
} else if (remainingBytes > 0) {
|
||||
fprintf(stderr, "Reached end of last disk but had to read %lu more bytes.\n", remainingBytes);
|
||||
errorAndExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,18 @@ void skipBytes(long numBytes) {
|
|||
}
|
||||
|
||||
|
||||
//Closes the currently opened file and opens the next file at its beginning.
|
||||
void openNextFile() {
|
||||
//Closes the currently opened file
|
||||
void closeCurrentFile() {
|
||||
const int closeResult = fclose(file.filePointer);
|
||||
if (closeResult != 0) {
|
||||
fprintf(stderr, "Could not close file: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
//Open next file
|
||||
|
||||
//Opens the next file at its beginning.
|
||||
void openNextFile() {
|
||||
const size_t fileNameLength = strlen(file.name);
|
||||
//We need to transfer carry if necessary (e.g. .z09 to .z10), otherwise just increase last digit
|
||||
if (file.name[fileNameLength - 1] == '9') {
|
||||
|
|
|
@ -21,5 +21,9 @@ void readBytesIntoBuffer(uint8_t* buffer, long numBytes);
|
|||
void skipBytes(long numBytes);
|
||||
|
||||
|
||||
//Closes the currently opened file and opens the next file at its beginning.
|
||||
//Closes the currently opened file
|
||||
void closeCurrentFile();
|
||||
|
||||
|
||||
//Opens the next file at its beginning.
|
||||
void openNextFile();
|
||||
|
|
Loading…
Reference in a new issue