🚧 Add debug message

This commit is contained in:
C-3PO 2018-09-14 05:30:22 +02:00
parent 12190f0ae8
commit f64412ebfe
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
3 changed files with 20 additions and 7 deletions

View file

@ -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
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 && file.offset == file.size) {
if (!isLast) {
openNextFile();
} else if (remainingBytes > 0) {
fprintf(stderr, "Reached end of last disk but had to read %lu more bytes.\n", remainingBytes);
errorAndExit();
}
}
}
}

View file

@ -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') {

View file

@ -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();