Fixed FCB directory searches after changing directories
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 20 Oct 2026 17:35:51 +0000 (18:35 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 20 Oct 2026 17:35:51 +0000 (18:35 +0100)
interrupts.c

index 9061cf0fcf020e128e98058d47825d736b9b0968..fa6b2725b78a800ca6512431effff3be04eb2828 100644 (file)
@@ -5279,7 +5279,24 @@ static void int_21 (CPU8086 *cpu) {
                     char dirpath[260];
                     
                     fcb_make_current_host_dir (dirpath, sizeof (dirpath));
-                    slot = fcb_find_slot_lifo (cpu->ds, fcb_off, dirpath);
+                    
+                    if ((slot = fcb_find_slot_lifo (cpu->ds, fcb_off, dirpath)) < 0) {
+                    
+                        int i;
+                        
+                        /* FindNext continues the original search even after CHDIR. */
+                        for (i = DOS_FCB_SEARCH_MAX - 1; i >= 0; i--) {
+                        
+                            if (dos_fcb_search[i].active && dos_fcb_search[i].dta_seg == cpu->ds && dos_fcb_search[i].dta_off == fcb_off) {
+                            
+                                slot = i;
+                                break;
+                            
+                            }
+                        
+                        }
+                    
+                    }
                 
                 }