📄 rxdosfil.asm
字号:
expandFileName_18:
mov byte ptr es:[ di - 1 ], '\' ; insure ends with \ char
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; does path start with root reference ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lds si, dword ptr [ _UnexpandedFileName ][ bp ]
cmp byte ptr [ si ], '\'
jz expandFileName_20
cmp byte ptr [ si ], '/'
jz expandFileName_20
cmp byte ptr [ si ], ' '+1
ifc expandFileName_Error ; null strings not parsed -->
jmp short expandFileName_30 ; continue -->
expandFileName_20:
mov di, word ptr [ _ExpandBuffer. _pointer ][ bp ]
add di, word ptr [ _cds_SubstOffset ][ bp ]
xor ax, ax
mov byte ptr es:[ di ], al ; append terminator
mov word ptr [ _currCluster ][ bp ], ax ; path name info supplied
inc si ; skip starting '\'
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; scan for only valid characters
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
expandFileName_30:
storarg _startPointer, si
expandFileName_32:
lodsb
call upperCase
stosb ; save at es:di
cmp al, ' '+1 ; end of string ?
jc expandFileName_36 ; yes -->
call ifPathSeparator ; path separator ?
jnz expandFileName_32 ; not yet -->
mov byte ptr es:[ di - 1 ], al ; make sure separator is \
mov word ptr [ _currCluster ][ bp ], 0000 ; path name info supplied
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; validate path separator
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
expandFileName_36:
mov byte ptr es:[ di ], 0 ; null terminate
mov cx, si
sub cx, word ptr [ _startPointer ][ bp ] ; length of string
dec cx ; excluding last \ ...
jg expandFileName_38 ; if more than one character -->
cmp al, '\' ; terminates with a \ ?
ifz expandFileName_Error ; \\ combination not permitted ->
cmp al, '/' ; terminates with a / ?
ifz expandFileName_Error ; // combination not permitted ->
expandFileName_38:
cmp cx, 2 ;
jg expandFileName_56 ; if not . or .., go get next -->
test word ptr [ _options ][ bp ], FILECANNOT_BEDIRECTORY
jz expandFileName_44
cmp byte ptr es:[ di - 1 ], '\' ; will always be \ in expansion string
jnz expandFileName_56 ; no, don't test for . and .. entries -->
expandFileName_44:
cmp word ptr es:[ di - 3 ], '..' ; back subdirectory
jz expandFileName_50 ; go backup to previous -->
cmp word ptr es:[ di - 3 ], '.\' ; current subdirectory
jz expandFileName_48 ; all set -->
cmp word ptr es:[ di - 3 ], './' ; current subdirectory
jnz expandFileName_56 ; all set -->
expandFileName_48:
sub di, cx ;
dec di ; fix current
jmp short expandFileName_56 ; go process next -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; backup to previous directory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
expandFileName_50:
mov word ptr [ _currCluster ][ bp ], 0000 ; no longer current cluster
sub di, cx ;
dec di ; fix to current,
mov cx, di
sub cx, word ptr [ _ExpandBuffer. _pointer ][ bp ]
sub cx, word ptr [ _cds_SubstOffset ][ bp ]
jle expandFileName_56
expandFileName_52:
dec di
cmp byte ptr es:[ di - 1 ], '\'
jz expandFileName_56
cmp byte ptr es:[ di - 1 ], '/'
jz expandFileName_56
loop expandFileName_52
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; more to go ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
expandFileName_56:
mov cx, di
sub cx, word ptr [ _ExpandBuffer. _pointer ][ bp ]
cmp cx, word ptr [ _cds_SubstOffset ][ bp ]
jge expandFileName_60
mov di, word ptr [ _cds_SubstOffset ][ bp ]
add di, word ptr [ _ExpandBuffer. _pointer ][ bp ]
expandFileName_60:
cmp byte ptr [ si - 1 ], ' '+1 ; was null ?
ifnc expandFileName_30 ; no, go get next -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; clean up string at end
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xor ax, ax
mov byte ptr es:[ di ], al ; add terminator
mov di, word ptr [ _ExpandBuffer. _pointer ][ bp ]
mov cx, 128
repnz scasb ; scan for null terminator
dec di
mov cx, di
sub cx, word ptr [ _ExpandBuffer. _pointer ][ bp ]
cmp cx, word ptr [ _cds_SubstOffset ][ bp ]
jle expandFileName_66 ; if minimal string -->
cmp byte ptr es:[ di - 1 ], '\' ; string ends with \ ?
jz expandFileName_64 ; no, ignore fix up -->
cmp byte ptr es:[ di - 1 ], '/' ; string ends with / ?
jnz expandFileName_66 ; no, ignore fix up -->
expandFileName_64:
mov byte ptr es:[ di - 1 ], 0 ; kill any terminating (needless \)
expandFileName_66:
getarg ax, _drive
or ax, ax ; return drive.
jmp short expandFileName_84
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if error
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
expandFileName_Error:
stc
mov ax, offset pexterrPathNotFound
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
expandFileName_84:
les di, dword ptr [ _ExpandBuffer ][ bp ] ; set return pointer.
mov dx, word ptr [ _currCluster ][ bp ] ; where to start search.
pop ds
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Locate/Validate File ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; This function takes a FCB pointer or ASCIZ path name and ;
; determines whether the name and path are valid, and whether ;
; the file exists. It returns a pointer to the file entry ;
; in a directory buffer. ;
; ;
; Input: ;
; es:si pointer to input filename or fcb. ;
; ss:di pointer to directory work area. ;
; ax options, as follows: ;
; ;
; FILEIS_FCB name is an FCB ;
; FILE_NODEVICENAME no device name allowed ;
; FILEHAS_WILDCHARS allowed in name ;
; FILEHAS_NOFILENAME no filename expected ;
; FILECANNOT_BEDEFINED filename must not exist ;
; FILECANNOT_BEDIRECTORY filename cannot be directory ;
; FILEMAY_EXIST file may exist (cluster not -1 ) ;
; FILE_ORDEVICE file or device must exist ;
; ;
; Output: ;
; ss:di pointer to directory work area. ;
; dx cluster address of located file ;
; cx cluster address of dir in which located file found ;
; ax drive ;
; cy means path/filename is not valid. ;
; ;
; Assumes ss == ds ;
;...............................................................;
LocateFile:
Entry
def _drive
def _cluster, 0000
def _dirCluster, 0000
def _terminatingChar
def _begfilenamePointer
ddef _endfilenamePointer
def _options, ax
ddef _filename, es, si
ddef _dirLocate, ss, di
defbytes _tempFileName, sizeTempFILENAME
defbytes _diskAccess, sizeDISKACCESS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; clear/ init dir access block
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
push es
push ds
push es
setES ss
clearMemory sizeDIRACCESS
pop es ; restore source segment
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; expand name to a usable form
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setDS ss
mov di, word ptr [ _dirLocate. _pointer ][ bp ]
lea di, offset fileAcExpandedName [ di ] ; expand name to store
test word ptr _options [ bp ], FILEIS_FCB
jz locateFile_12 ; if not fcb -->
getarg ax, _options
saveRegisters es, si, ss, di ; arguments
call convFCBNametoASCIZ ; build asciz name
locateFile_12:
saveRegisters es, si, ss, di ; arguments
call ExpandFileName ; expanded filename
mov word ptr [ _cluster ][ bp ], dx ; where to start search
ifc locateFile_PathNotFound ; if path invalid -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; get disk parameters
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
locateFile_16:
les si, dword ptr [ _dirLocate ][ bp ] ; point to expanded filename
lea si, offset fileAcExpandedName [ si ] ; expanded name store
call getDrive ; extract drive name (es:si)
mov word ptr [ _drive ][ bp ], ax ; get drive.
stordarg _endfilenamePointer, es, si ; save ptr to working dir
ifc locateFile_PathNotFound ; if illegal drive -->
call getDPB ; make sure drive is initialized
; call initDriveParameters ; get drive parameters
ifc locateFile_PathNotFound ; if illegal drive -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if search only current directory, skip to name
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp word ptr [ _cluster ][ bp ], 0000 ; if NOT search in subdirectory
jz locateFile_20 ; ok as name is -->
les si, dword ptr [ _endfilenamePointer ][ bp ]
call skipToLast ; skip to starting name
stordarg _endfilenamePointer, es, si
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -