📄 redir.a86
字号:
jc redir_lock20
xor ax,ax ; success
redir_lock20:
xchg ax,bx ; return result in BX
ret
eject
; EXPAND FILE
; +----+----+----+----+----+----+----+----+----+----+
; | 55 | old name | new name |
; +----+----+----+----+----+----+----+----+----+----+
; entry:
; ------
; old name: segmented address of ASCIIZ name
; new name: segmented address of ASCIIZ name
; exit:
; -----
; BX: 0000 or error code ( < 0)
; If we got here pri_pathname already contains expanded name - just copy it
; back to the users buffer.
redir_expand:
;------------
mov si,2[bp] ; SI -> parameter block
les di,10[si] ; ES:DI -> user supplied name
mov si,offset pri_pathname
call copy_asciiz
xor bx,bx ; no errors
ret
eject
; RENAME FILE
; +----+----+----+----+----+----+----+----+----+----+
; | 56 | old name | new name |
; +----+----+----+----+----+----+----+----+----+----+
; entry:
; ------
; old name: segmented address of ASCIIZ name
; new name: segmented address of ASCIIZ name
; exit:
; -----
; BX: 0000 or error code ( < 0)
; Note: R/O files can be renamed.
; ---
redir_move:
mov ax,I2F_REN ; it's a rename
jmp redir_unlink_move_common
eject
; GET/SET FILE DATE/TIME
; +----+----+----+----+----+----+----+----+----+----+
; | 57 | handle | mode | date | time |
; +----+----+----+----+----+----+----+----+----+----+
; entry:
; ------
; handle: open file handle
; mode: 0 = get date/time, 1 = set date/time
; date: date as in directory FCB
; time: time as in directory FCB
; exit:
; -----
; BX: 0000 or error code ( < 0)
; date: date of last modification if mode = 0
; time: date of last modification if mode = 0
redir_dattim:
;------------
mov si,2[bp] ; DS:SI -> param block
cmp ds:word ptr 4[si],1 ; is it set ?
ja redir_dattim30 ; if illegal say so
je redir_dattim10
mov ax,es:DHNDL_DATE[bx] ; we need to copy the file date
mov word ptr 6[si],ax ; into the parameter block
mov ax,es:DHNDL_TIME[bx]
mov word ptr 8[si],ax ; and the time
jmps redir_dattim20
redir_dattim10:
mov ax,word ptr 6[si] ; copy the date we are given
mov es:DHNDL_DATE[bx],ax ; into the DOSHNDL
mov ax,word ptr 8[si] ; and the time
mov es:DHNDL_TIME[bx],ax
or es:DHNDL_WATTR[bx],DHAT_TIMEOK
and es:DHNDL_WATTR[bx],not DHAT_CLEAN
redir_dattim20:
xor bx,bx ; all went OK
jmps redir_dattim40
redir_dattim30:
mov bx,ED_FUNCTION ; bad function number
redir_dattim40:
ret
Public redir_build_path
; AH contains state of path processing, and is normally zero
BP_DOT equ 1 ; we have had a DOT end are processing the .EXT
BP_WILD equ 2 ; we have encountered a wild card
BP_BSLASH equ 4 ; the last character was a BSLASH
; May be called with or without MXDisk
redir_build_path:
;----------------
; On Entry:
; DS:SI -> source name
; ES:DI -> destination name (in PCMODE data segment)
; current_ldt -> LDT_ for specified drive
; On Exit:
; CY clear if we could build the path
;
; firstly we discard any drive portion
lodsw ; get 1st two characters
cmp ah,':' ; is a drive specified ?
jne redir_bp10 ; discard "d:" if so
lodsw
redir_bp10:
; Is it a "\\server\sharename\subdir\filename.ext" format ?
call check_dslash ; if it is \\
je redir_bp20 ; then just copy the lot
; it's a normal "A:\subdir\filename.ext" pathname format
dec si ; we have swallowed the 1st two
dec si ; chars - now we change our mind
push ds ! push si
lds si,es:current_ldt
mov cx,ds:LDT_ROOTLEN[si] ; copy the root portion of the name
rep movsb ; copy the server stub name
mov dx,di ; ES:DX -> root position
call check_slash ; do we start from the root ?
je redir_bp11 ; yes, then that's all
call copy_asciiz ; no, copy the rest of the path
call redir_bp_append_slash ; append '\' for our path processing
redir_bp11:
pop si ! pop ds
jmps redir_bp_next_level ; continue processing given path
redir_bp20:
; It is a "\\server\sharename\subdir\filename.ext" format
stosw ; copy the "\\"
xor ax,ax ; clear "flags" in AH
redir_bp21:
lodsb ; work along the name
test al,al ; unexpected end of name ?
jz redir_bp_exit20 ; go with what we've got....
call check_slash ; have we found the root '\' ?
je redir_bp23
if KANJI
call dbcs_lead ; is it the 1st of a kanji pair
jne redir_bp22 ; no, onto next char
stosb ; copy the 1st character
movsb ; copy 2nd byte of KANJI pair
jmps redir_bp21 ; now we can move onto next char
redir_bp22:
endif
call toupper ; upper case the character
stosb ; copy the character
jmps redir_bp21 ; go and do another one
redir_bp23:
mov dx,di ; bodge root to the top
; mov al,'\'
stosb ; put in a '\'
jmps redir_bp_next_level ; yes, this is the new "root"
; We have reached the terminating NUL
redir_bp_exit:
test ah,BP_WILD ; did we get any wildcards ?
je redir_bp_exit10
mov si,2[bp] ; SS:SI -> parameter block
mov al,ss:[si] ; fdos code number
cmp al,MS_X_FIRST ; search first ?
je redir_bp_exit10
cmp al,FD_EXPAND ; expand pathname
je redir_bp_exit10
cmp ss:remote_call,0 ; should we wildcard REN/DEL ?
je redir_bp_ED_PATH ; reject as not allowed here
cmp al,MS_X_RENAME ; rename ?
je redir_bp_exit10
cmp al,MS_X_UNLINK ; delete ?
jne redir_bp_ED_PATH ; reject as not allowed here
redir_bp_exit10:
xor al,al ; make sure our string is zero
stosb ; terminated
call redir_bp_append_slash ; append a trailing '\' if we don't
dec di ; have one so we can remove it
cmp di,dx ; are we talking about the root ?
jne redir_bp_exit20
cmp es:byte ptr 0FFFFh[di],':'
jne redir_bp_exit20 ; if we have a trailing ':' allow
inc di ; a '\' at the root
redir_bp_exit20:
xor al,al ; KANJI aware way of removing trailing
stosb ; '\' from the path....
; clc
ret
redir_bp_next_level:
; DS:SI -> source pathname, ES:DI -> destination pathname, ES:DX -> root
; AH = current status
mov cx,8 ; expansion count ready
xor ax,ax
redir_bp_next_char:
lodsb
test al,al ; end of the line ?
jz redir_bp_exit ; do the exit
; Is it a '\' ?
redir_bp40:
call check_slash ; was it a seperator ?
jne redir_bp50
test ah,BP_WILD ; have we encountered wildcards ?
jnz redir_bp_ED_PATH ; reject as not allowed here
mov al,'\' ; make sure it's a BSLASH
stosb
jmps redir_bp_next_level ; start at a new level
; Is it a '.' ?
redir_bp50:
cmp al,'.' ; seperator ?
jne redir_bp60
lodsb ; get next letter
test al,al ; is it trailing '.' ?
je redir_bp_exit ; then exit now
cmp cx,8 ; check for '.' and '..'
je redir_bp52 ; if at start of field
redir_bp51: ; othewise it's a ".EXT"
mov bx,ED_FILE ; assume we have a problem
test ah,BP_DOT ; have we had an extention before ?
jnz redir_bp_err ; we've got a problem
dec si ; rewind a character
mov ax,'.'+256*BP_DOT ; so we are back to the '.'
stosb ; store the '.' in destination
mov cx,3 ; expand the extention
jmps redir_bp_next_char
redir_bp52: ; It might be a "." or ".."
call check_slash ; is it '.\'
je redir_bp_next_char ; discard them both
cmp al,'.' ; is it '..' ?
jne redir_bp51 ; no, must be an extention after all
call redir_bp_ddot ; rewind a level
jnc redir_bp_next_level ; onto next level
redir_bp_ED_PATH:
; set CY flag to indicate error then return
mov bx,ED_PATH ; return "invalid path" error
redir_bp_err:
stc
ret
; Is it a '*' ?
redir_bp60:
call check_delim ; is it a delimiter ?
jz redir_bp_ED_PATH ; thats illegal at this point
cmp al,'*' ; wildcards ?
jne redir_bp70
mov al,'?'
rep stosb ; expand it
; or ah,BP_WILD ; remember wild-card encountered
; jmps redir_bp_next_char ; check for wildcards
;
; ; we can just fall through
;
redir_bp70:
cmp al,'?' ; wild card is possibly OK
jne redir_bp80
or ah,BP_WILD ; remember wild-card encountered
redir_bp80:
; Normal Character
; AL contains a normal character for us to process.
; Uppercase the character, look out for KANJI etc
jcxz redir_bp_next_char ; discard if no space is left
dec cx ; one less to expand
if KANJI
call dbcs_lead ; is it the 1st of a kanji pair
jne redir_bp90
inc si ; skip 2nd byte
jcxz redir_bp_next_char ; discard if no room for kanji char
dec cx ; one less to expand
stosb ; store 1st byte of kanji character
dec si ; point at 2nd byte again
movsb ; copy 2nd byte of kanji character
jmps redir_bp_next_char
redir_bp90:
endif
call toupper ; make it upper case
stosb ; plant the character
jmps redir_bp_next_char
redir_bp_ddot:
; We have encountered a '..' in a pathname, so rewind up a level
; On Entry:
; DS:SI -> source position, ES:DI -> destination position
; ES:DX -> root position, AL = Character
; On Exit:
; ES:DI -> start of field one level up, unless we get an error when CY set.
lodsb ; look at char after '..'
call check_slash ; is it '..\'
je redir_bp_ddot10
test al,al ; is it a trailing '..'
jnz redir_bp_ED_PATH ; no, anything else is bad...
dec si ; trailing '..', rewind to NUL
redir_bp_ddot10:
dec di ; move back to last '\'
cmp di,dx ; are we at the root anyway ?
jle redir_bp_ED_PATH ; then don't discard any
; We now start at ES:DX and work along till ES:DI -> char after last '\'
push ds ! push si
push es ! pop ds
mov si,dx ; DS:SI -> char after root
mov cx,dx ; last '\' position in CX
redir_bp_ddot20:
lodsb
cmp si,di ; end of the line yet ?
jae redir_bp_ddot30 ; yes, stop now
if KANJI
call dbcs_lead ; is it 1st of a kanji pair ?
jne redir_bp_ddot25
lodsb ; skip the 2nd too
jmps redir_bp_ddot20 ; then go on to next char
redir_bp_ddot25:
endif
call check_slash ; is it a '\'
jne redir_bp_ddot20 ; no, do next
mov cx,si ; save position after the '\'
jmps redir_bp_ddot20
redir_bp_ddot30:
mov di,cx ; last '\' was here..
pop si ! pop ds
clc ; no errors
ret
redir_bp_append_slash:
; On Entry:
; ES:DX -> ASCIIZ string to append a '\' to
; On Exit:
; ES:DI -> terminating NUL
; All but AX preserved
;
xor ax,ax ; AH = 0, initially no previous char
mov di,dx ; start processing from here
redir_bp_append_slash10:
mov ah,al ; save previous char in AH
mov al,es:[di] ; get a character
inc di ; point to next
test al,al ; is it NUL ?
if KANJI
je redir_bp_append_slash20
call dbcs_lead ; is it 1st of a kanji pair ?
jne redir_bp_append_slash10
inc di ; skip the 2nd too
jmps redir_bp_append_slash10 ; (it might be '\')
redir_bp_append_slash20:
else
jnz redir_bp_append_slash10
endif
mov al,ah ; get previous char
call check_slash ; did we have a '\' ?
je redir_bp_append_slash30
dec di ; ES:DI -> existing NUL
mov ax,'\'
stosw ; new terminating '\'
redir_bp_append_slash30:
dec di ; ES:DI -> NUL
ret
get_attrib_mode:
;---------------
; On Entry:
; SS:2[BP] -> param block
; On Exit:
; AX = file mode
; CX = file attributes
;
mov si,2[bp] ; SI -> parameter block
mov ax,ds:6[si] ; get mode
mov cx,ds:8[si] ; get attribs
mov file_mode,ax ; save open mode
mov file_attrib,cx ; save file attribute
ret
int2f_ldt:
;---------
; On Entry:
; AX = Int2F command
; On Exit:
; CY clear, AX returned unchanged
; CY set, AX = Our Negative Error Code
;
les di,ss:current_ldt
jmps int2f_op
int2f_dhndl:
;----------
; On Entry:
; AX = Int2F command
; On Exit:
; CY clear, AX returned unchanged
; CY set, AX = Our Negative Error Code
;
les di,ss:current_dhndl
int2f_op:
push ds
push ss ! pop ds
push int2f_stack ; put word on stack
int 2fh ; get the info
pop int2f_stack ; clean up the stack
pop ds
jnc int2f_op10
neg ax ; AX = we keep error codes negative
; stc ; we have a problem
int2f_op10:
ret
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -