File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -707,6 +707,26 @@ zproc bdos_RENAMEFILE
707707 ; Old name: param+0
708708 ; New name: param+16
709709
710+ ; Ensure the destination is closed, or else bad things happen.
711+
712+ clc
713+ lda param+0
714+ pha
715+ adc #16
716+ sta param+0
717+ lda param+1
718+ pha
719+ adc #0
720+ sta param+1
721+ jsr get_closed_file_table_entry
722+ pla
723+ sta param+1
724+ pla
725+ sta param+0
726+
727+ ; Get the file table entry of the source (which might overwrite the entry
728+ ; fetched above, but that's fine because it's closed).
729+
710730 jsr get_closed_file_table_entry
711731 txa
712732 clc
@@ -716,14 +736,16 @@ zproc bdos_RENAMEFILE
716736 adc #0
717737 sta CP_PARAM+1
718738
739+ ; Now convert the destination filename, but _don't_ create a file table
740+ ; entry for it.
741+
719742 clc
720743 lda param+0
721744 adc #16
722745 sta param+0
723746 zif cs
724747 inc param+1
725748 zendif
726-
727749 jsr convert_filename
728750
729751 lda #<(temp_file_entry+FT_FILENAMELEN)
@@ -1207,21 +1229,25 @@ file_table_offsets:
12071229; Note that closed files get be preempted in the file table at any point, so if
12081230; you call get_file_table_entry after this the filename may become overwritten!
12091231
1232+ ; Returns the offset into the file table in X.
12101233zproc get_closed_file_table_entry
12111234 jsr get_file_table_entry
12121235
12131236 lda file_table+FT_ATTRIBS, x
12141237 zif ne
12151238 ; This table entry is open.
12161239
1240+ phx
12171241 lda #FUNC_FILE_CLOSE
12181242 jsr neo_file_func
1243+ plx
12191244
1220- stz file_table+FT_ATTRIBS
1245+ stz file_table+FT_ATTRIBS, x
12211246 zendif
12221247 rts
12231248zendproc
12241249
1250+ ; Returns the offset into the file table in X.
12251251zproc get_opened_file_table_entry
12261252 jsr get_file_table_entry
12271253zendproc
You can’t perform that action at this time.
0 commit comments