2 ; SCCSID = @(#)copypr2.asm 1.1 85/05/14
3 ; SCCSID = @(#)copypr2.asm 1.1 85/05/14
15 TRANDATA
SEGMENT PUBLIC BYTE ;AC000;
16 EXTRN FulDir_ptr
:word ;AN052;
19 TRANSPACE
SEGMENT PUBLIC BYTE ;AC000;
44 TRANCODE
SEGMENT PUBLIC BYTE
46 EXTRN BADPATH_ERR
:NEAR ;AN022;
47 EXTRN COPERR
:NEAR ;AN052;
48 EXTRN EXTEND_SETUP
:NEAR ;AN022;
54 ASSUME
CS:TRANGROUP
,DS:TRANGROUP
,ES:TRANGROUP
,SS:NOTHING
58 ; Given switch vector in AX,
59 ; Set ASCII switch if A is set
60 ; Clear ASCII switch if B is set
61 ; BINARY set if B specified
62 ; Leave ASCII unchanged if neither or both are set
63 ; Also sets INEXACT if ASCII is ever set. AL = ASCII on exit, flags set
65 AND AL,SwitchA
+SwitchB
66 JPE LOADSW
; PE means both or neither are set
83 jnz KNOWABOUTDEST
; Already done the figuring
84 MOV DI,OFFSET TRANGROUP
:USERDIR1
85 mov bp,offset trangroup
:DESTVARS
89 ; Now know all about the destination
99 mov si,[DESTTAIL
] ; Create an FCB of the original DEST
100 mov di,offset trangroup
:DESTFCB
101 mov ax,PARSE_FILE_DESCRIPTOR
SHL 8
105 ;AD052; MOV BYTE PTR [DI+1],"|" ; must be illegal file name character
106 mov dx,offset trangroup
:fuldir_ptr
;AN052; Issue "File creation error"
110 mov ax,word ptr [DESTBUF
] ; Get drive
116 MOV CL,[ASCII
] ; Save current ASCII setting
129 inc [MELCOPY
] ; ambig source, ambig dest, and pluses
134 xor al,2 ; al=2 if unambig dest, =0 if ambig dest
136 shr al,1 ; al=1 if unambig dest AND ambig sorce
137 ; Implies concatenation
139 or al,[PLUS
] ; al=1 if concat
143 mov [INEXACT
],al ; Concat -> inexact copy
145 jnz NOTFIRSTDEST
; Binary explicitly given, all OK
146 mov [ASCII
],al ; Concat -> ASCII
148 jnz NOTFIRSTDEST
; ASCII flag set before, DATA read correctly
150 JZ NOTFIRSTDEST
; ASCII flag did not change states
152 ; At this point there may already be binary read data in the read buffer.
153 ; We need to find the first ^Z (if there is one) and trim the amount
154 ; of data in the buffer correctly.
157 JCXZ NOTFIRSTDEST
; No data, everything OK
162 REPNE SCASB ; Scan for EOF
164 JNZ NOTFIRSTDEST
; No ^Z in buffer, everything OK
166 MOV [NXTADD
],DI ; New buffer
169 mov bx,offset trangroup
:DIRBUF
+1 ; Source of replacement chars
171 jz GOTCHRSRC
; Not a concat
172 mov bx,offset trangroup
:SDIRBUF
+1 ; Source of replacement chars
175 mov si,offset trangroup
:DESTFCB
+1 ; Original dest name
176 mov di,[DESTTAIL
] ; Where to put result
199 jz ENDDEST
; No extension
219 stosb ; NUL terminate
224 jnz NOTPFILE
; If ambig don't bother with open
226 add dx,BUF
; Set DX to spec
229 MOV AX,EXTOPEN
SHL 8 ;AC000; open the file
230 mov bx,read_open_mode
;AN000; get open mode for COPY
231 xor cx,cx ;AN000; no special files
232 mov si,dx ;AN030; get file name offset
233 mov di,-1 ;AN030; no parm list
234 mov dx,read_open_flag
;AN000; set up open flags
237 jnc pure_file
;AN022; is pure file
238 invoke get_ext_error_number
;AN022; get the extended error
239 cmp ax,error_file_not_found
;AN022; if file not found - okay
241 cmp ax,error_path_not_found
;AN022; if path not found - okay
243 cmp ax,error_access_denied
;AN022; if access denied - okay
245 jmp extend_setup
;AN022; exit with error
248 mov bx,ax ; Is pure file
254 jnz ISADEV
; If device, done
256 jz ISSIMPFILE
; If no path seps, done
259 mov dx,word ptr [BP.BUF
]
260 cmp dl,0 ;AN034; If no drive specified, get
261 jz set_drive_spec
;AN034; default drive dir
265 set_drive_spec: ;AN034;
272 jnc curdir_ok
;AN022; if error - exit
273 invoke get_ext_error_number
;AN022; get the extended error
274 jmp extend_setup
;AN022; exit with error
278 add dx,BUF
; Set DX for upcomming CHDIRs
281 cmp bh,6 ; Ambig and path ?
282 jnz CHECKAMB
; jmp if no
285 cmp byte ptr [si-2],bl
287 mov [BP.ISDIR
],2 ; Know is d:/file
291 mov [BP.ISDIR
],1 ; Know is path/file
292 dec si ; Point to the /
295 jmp DOPCD
;AC022; need long jump
303 mov [BP.ISDIR
],0 ; Know is file since ambig but no path
316 Kloop: ;AN000; 3/3/KK
317 MOV AL,ES:[DI] ;AN000; 3/3/KK
318 INC DI ;AN000; 3/3/KK
319 OR AL,AL ;AN000; 3/3/KK
320 JZ Done
;AN000; 3/3/KK
321 xor ah,ah ;AN000; 3/3/KK
322 invoke Testkanj
;AN000; 3/3/KK
323 JZ Kloop
;AN000; 3/3/KK
324 INC DI ;AN000; 3/3/KK
325 INC AH ;AN000; 3/3/KK
326 jmp Kloop
;AN000; 3/3/KK
331 mov [bp.ISDIR
],2 ; assume d:/file
332 OR AH, AH ;AN000; 3/3/KK
333 JNZ Store_pchar
;AN000; 3/3/KK this is the trailing byte of ECS code
337 Store_pchar: ;AN000; 3/3/KK
339 mov [bp.ISDIR
],1 ; know path/file
348 invoke get_ext_error_number
;AN022; get the extended error
349 cmp ax,error_path_not_found
;AN022; if path not found - okay
350 jz notpdir_try
;AN022;
351 cmp ax,error_access_denied
;AN022; if access denied - okay
352 jnz extend_setupj
;AN022; otherwise - exit error
355 mov [bp.ISDIR
],0 ; assume pure file
358 retz
; Know pure file, no path seps
359 mov [bp.ISDIR
],2 ; assume d:/file
362 jz BADCDERRJ2
; Trailing '/'
365 jz BADCDERRJ2
; If . or .. pure cd should have worked
367 cmp byte ptr [si-2],bl
368 jz DOPCD
; Know d:/file
369 mov [bp.ISDIR
],1 ; Know path/file
370 dec si ; Point at last '/'
374 xchg bl,[SI] ; Stick in a NUL
376 CMP DX,SI ;AN000; 3/3/KK
377 JAE LookBack
;AN000; 3/3/KK
378 PUSH SI ;AN000; 3/3/KK
379 PUSH CX ;AN000; 3/3/KK
380 MOV CX,SI ;AN000; 3/3/KK
381 MOV SI,DX ;AN000; 3/3/KK
383 Kloop2: ;AN000; 3/3/KK
385 invoke TestKanj
;AN000; 3/3/KK
386 jz NotKanj4
;AN000; 3/3/KK
388 CMP SI,CX ;AN000; 3/3/KK
389 JB Kloop2
;AN000; 3/3/KK
390 POP CX ;AN000; 3/3/KK
391 POP SI ;AN000; 3/3/KK
392 JMP SHORT DoCdr
;AN000; 3/3/KK Last char is ECS code, don't check for
394 NotKanj4: ;AN000; 3/3/KK
395 CMP SI,CX ;AN000; 3/3/KK
396 JB Kloop2
;AN000; 3/3/KK
397 POP CX ;AN000; 3/3/KK
398 POP SI ;AN000; 3/3/KK
400 LookBack: ;AN000; 3/3/KK
401 CMP BL,[SI-1] ; if double slash, then complain.
404 DoCdr: ;AN000; 3/3/KK
409 invoke get_ext_error_number
;AN022; get the extended error
411 EXTEND_SETUPJ: ;AN022;
412 JMP EXTEND_SETUP
;AN022; go issue the error message
415 jmp badpath_err
;AC022; go issue path not found message
435 mov si,offset trangroup
:DESTBUF
;g do name translate of target
436 mov di,offset trangroup
:TRGXNAME
;g save for name comparison
440 MOV si,offset trangroup
:SRCXNAME
;g get name translate of source
441 MOV di,offset trangroup
:TRGXNAME
;g get name translate of target