- if (cbm_opendir(lfn, (BYTE)8) != 0) {
- cprintf("could not open directory\r\n");
- return;
- }
- while (cbm_readdir(lfn, dirent) == 0) {
- if (strncmp(dirent->name, "log", 3) == 0)
- log_num++;
- if (strcasecmp(dirent->name, "items") == 0)
- items_exists = true;
- if (strcasecmp(dirent->name, "credits") == 0)
- credits_exists = true;
- }
- cbm_closedir(lfn);
-}
+ if (cbm_opendir(lfn, (BYTE)8) != 0) {
+ cprintf("could not open directory\r\n");
+ return;
+ }
+ while (cbm_readdir(lfn, &dirent) == 0) {
+ /* NOTE: You MUST NOT delete any logfiles. This does only work
+ * under the assumption that logfiles are named continuously */
+ if (strncmp(dirent.name, "log", 3) == 0)
+ log_num++;
+ if (strcasecmp(dirent.name, "items") == 0)
+ items_exists = true;
+ if (strcasecmp(dirent.name, "credits") == 0)
+ credits_exists = true;
+ }
+ cbm_closedir(lfn);
+
+ /* Try to find out how many lines the last logfile got to seamlessly
+ * append to it, if we got more than one logfile. */
+ if (log_num > 0) {
+ log_num--;