-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathrename
218 lines (218 loc) · 2.88 KB
/
rename
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
.PAGE 'COPY'
;
; COPY FILE(S) TO ONE FILE
;
COPY
JSR LOOKUP ; LOOK UP ALL FILES
LDA F2CNT
CMP #3
BCC COP10
LDA FILDRV
CMP FILDRV+1
BNE COP10
LDA ENTIND
CMP ENTIND+1
BNE COP10
LDA ENTSEC
CMP ENTSEC+1
BNE COP10
JSR CHKIN ; CONCAT
LDA #1
STA F2PTR
JSR OPIRFL
JSR TYPFIL
BEQ COP01 ; RELATIVE FILE
CMP #PRGTYP
BNE COP05
COP01
LDA #MISTYP
JSR CMDERR
COP05
LDA #IWSA
STA SA
LDA LINTAB+IRSA
STA LINTAB+IWSA
LDA #$FF
STA LINTAB+IRSA
JSR APPEND
LDX #2
JSR CY10
JMP ENDCMD
COP10
JSR CY
JMP ENDCMD
CY
JSR CHKIO ; CHECK FILES FOR EXISTENCE
LDA FILDRV
AND #1
STA DRVNUM
JSR OPNIWR ; OPEN INTERNAL WRITE CHNL
JSR ADDFIL ; ADD TO DIRECTORY
LDX F1CNT
CY10
STX F2PTR ; SET UP READ FILE
JSR OPIRFL
LDA #IRSA
STA SA
JSR FNDRCH
JSR TYPFIL
BNE CY10A
JSR CYEXT
CY10A
LDA #EOISND
STA EOIFLG
JMP CY20
CY15
JSR PIBYTE
CY20
JSR GIBYTE
LDA #LRF
JSR TSTFLG
BEQ CY15
JSR TYPFIL
BEQ CY30
JSR PIBYTE
CY30
LDX F2PTR
INX
CPX F2CNT
BCC CY10 ; MORE FILES TO COPY
LDA #IWSA
STA SA
JMP CLSCHN ; CLOSE COPY CHANNEL, FILE
OPIRFL
LDX F2PTR
LDA FILDRV,X
AND #1
STA DRVNUM
LDA DIRTRK
STA TRACK
LDA ENTSEC,X
STA SECTOR
JSR OPNIRD
LDX F2PTR
LDA ENTIND,X
JSR SETPNT
LDX F2PTR
LDA PATTYP,X
AND #TYPMSK
STA TYPE
LDA #0
STA REC
JSR OPREAD
LDY #1
JSR TYPFIL
BEQ OPIR10 ; REALTIVE FILE
INY
OPIR10
TYA
JMP SETPNT
GIBYTE
LDA #IRSA
STA SA
GCBYTE
JSR GBYTE
STA DATA
LDX LINDX
LDA CHNRDY,X
AND #EOISND
STA EOIFLG
BNE GIB20
JSR TYPFIL
BEQ GIB20 ; RELATIVE FILE
LDA #LRF
JSR SETFLG
GIB20
RTS
CYEXT
JSR SETDRN
JSR SSEND
JSR BIGREL ; BIG RELATIVE FILES?
BNE CYEXT1 ; NO
LDA GRPNUM ; YES, SAVE GROUP #
PHA
CYEXT1
LDA SSIND
PHA
LDA SSNUM
PHA
LDA #IWSA
STA SA
JSR FNDWCH
JSR ADRELS
STA RELPTR
PLA
STA SSNUM
PLA
STA SSIND
JSR BIGREL ; BIG RELATIVE FILES?
BNE CYEXT2
PLA
STA GRPNUM ; RESTORE GROUP #
CYEXT2
JMP ADDR1
.PAGE 'RENAME'
;
; RENAME FILE NAME IN DIRECTORY
;
RENAME
JSR ALLDRS ; SET BOTH DRIVE #'S
LDA FILDRV+1
AND #1
STA FILDRV+1
CMP FILDRV
BEQ RN10 ; SAME DRIVE #'S
ORA #$80 ; CHECK BOTH DRIVES FOR NAME
RN10
STA FILDRV
JSR LOOKUP ; LOOK UP BOTH NAMES
JSR CHKIO ; CHECK FOR EXISTENCE
LDA FILDRV+1
AND #1
STA DRVNUM
LDA ENTSEC+1
STA SECTOR
JSR RDAB ; READ DIRECTORY SECTOR
JSR WATJOB
LDA ENTIND+1
CLC ; SET SECTOR INDEX
ADC #3 ; ...+3
JSR SETPNT
JSR GETACT
TAY
LDX FILTBL
LDA #16
JSR TRNAME ; TRANSFER NAME
JSR WRTOUT ; WRITE SECTOR OUT
JSR WATJOB
JMP ENDCMD
;
; CHECK I/O FILE FOR EXIST
;
CHKIN
LDA PATTYP+1 ; 1ST FILE BEARS TYPE
AND #TYPMSK
STA TYPE
LDX F2CNT
CK10
DEX
CPX F1CNT
BCC CK20
LDA FILTRK,X
BNE CK10
LDA #FLNTFD ; INPUT FILE NOT FOUND
JMP CMDERR
CK20
RTS
CHKIO
JSR CHKIN
CK25
LDA FILTRK,X
BEQ CK30
LDA #FLEXST
JMP CMDERR
CK30
DEX
BPL CK25
RTS
.END