📄 rxdosfil.asm
字号:
TITLE 'fil - DOS Redirected File System Support'
PAGE 59, 132
.LALL
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; DOS Redirected File System Support ;
;...............................................................;
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Real Time Dos ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; This material was created as a published version of a DOS ;
; equivalent product. This program logically functions in ;
; the same way as MSDOS functions and it is internal data ;
; structure compliant with MSDOS 6.0 ;
; ;
; This product is distributed AS IS and contains no warranty ;
; whatsoever, including warranty of merchantability or ;
; fitness for a particular purpose. ;
; ;
; ;
; (c) Copyright 1990, 1997. Api Software and Mike Podanoffsky ;
; All Rights Reserved Worldwide. ;
; ;
; This product is protected under copyright laws and may not ;
; be reproduced in whole or in part, in any form or media, ;
; included but not limited to source listing, facsimile, data ;
; transmission, cd-rom, or floppy disk without the expressed ;
; written consent of the author. ;
; ;
; License for distribution for commercial use or resale ;
; required from: ;
; ;
; Api Software ;
; 12 South Walker Street ;
; Lowell, MA 01851 ;
; ;
; internet: mikep@world.std.com ;
; ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; Compile with MASM 5.1 ;
;...............................................................;
include rxdosmac.asm
include rxdosdef.asm
RxDOS SEGMENT PARA PUBLIC 'CODE'
assume cs:RxDOS, ds:RxDOS, es:RxDOS, ss:RxDOS
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; DOS Redirected File System Support ;
;...............................................................;
public initdiskAccess
public computeLogSectorNumber
public readLogicalBuffer
public writeLogicalBuffer
public fillLogicalBuffer
public readLine
public ExpandFileName
public LocateFile
public LocateFileByAttribute
public LocateFreeDirSlot
public blankinitDirName
public scanDirectory
public compareDirEntries
public GetActualDrive
public getCurrDirCluster
public getDevice
public getDrive
public getWhereInDir
extrn scanInvalidFilenameChars : near
extrn ifPathSeparator : near
extrn upperCase : near
extrn convFCBNametoASCIZ : near
extrn skipToNextName : near
extrn skipToLast : near
extrn getAddrDPB : near
extrn getDPB : near
extrn _div32 : near
extrn convFilenametoFCBString : near
extrn locateCCBPHeader : near
extrn CCBChanged : near
extrn selBuffer : near
extrn updateAllChangedCCBBuffers : near
extrn AppendCluster : near
extrn AllocateInitCluster : near
extrn _FATReadRandom : near
extrn updateClusterValue : near
extrn CompareString : near
extrn StringLength : near
extrn checkforDeviceName : near
extrn _RxDOS_pCDS : dword
extrn _RxDOS_bLastDrive : byte
extrn _RxDOS_CurrentDrive : byte
extrn pexterrInvalidFunction : near
extrn pexterrFileNotFound : near
extrn pexterrPathNotFound : near
extrn pexterrIllegalName : near
extrn pexterrNoHandlesAvailable : near
extrn pexterrAccessDenied : near
extrn pexterrInvalidHandle : near
extrn pexterrArenaTrashed : near
extrn pexterrNotEnoughMemory : near
extrn pexterrInvalidBlock : near
extrn pexterrInvalidAccess : near
extrn pexterrInvalidDrive : near
extrn pexterrCurrentDirectory : near
extrn pexterrNoMoreFiles : near
extrn pexterrFileExists : near
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Init System Access Block ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; dx cluster of dir to search ;
; ss:bx address of disk access structure ;
; ;
; Output: ;
; all registers preserved ;
;...............................................................;
initdiskAccess:
push es
push cx
push di
push ax
setES ss ; set segment
mov di, bx ; pointer to di
clearMemory sizeDISKACCESS
pop ax
xor ah, ah
mov word ptr es:[ diskAcDrive ][ bx ], ax
mov word ptr es:[ diskAcBegCluster ][ bx ], dx
pop di
pop cx
pop es
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Compute Logical Sector Number ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; dx cluster number ;
; ;
; Output: ;
; ax drive ;
; cx:dx logical sector number ;
;...............................................................;
computeLogSectorNumber:
push es
push bx
push ax ; drive
push dx ; cluster
call getAddrDPB ; get first sector address from DPB
mov dx, word ptr es:[ _dpbFirstDirSector ][ bx ]
xor cx, cx ; if cluster is zero
pop ax ; get cluster number
or ax, ax ; if reading cluster 0000
jz computeLogSectorNumber_12 ; LSN is zero -->
dec ax
dec ax
mov cx, 1
add cl, byte ptr es:[ _dpbClusterSizeMask ][ bx ]
mul cx ; compute sector
add ax, word ptr es:[ _dpbFirstDataSector ][ bx ]
adc dx, 0000
mov cx, dx ; high part
mov dx, ax ; low part
computeLogSectorNumber_12:
pop ax ; restore drive
pop bx
pop es
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Expand File Name ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax options: FILECANNOT_BEDIRECTORY ;
; arg ptr to filename passed ;
; arg ptr to expanded filename ;
; ;
; Output: ;
; es:di ptr to expanded filename ;
; dx current cluster, if search to begin here ;
; ax drive, or error ;
; cy if error detected ;
;...............................................................;
ExpandFileName:
Entry 4
darg _UnexpandedFileName
darg _ExpandBuffer
def _options, ax
xor ax, ax
def _drive, ax ; initialize to 0's
def _currCluster, ax
def _cds_SubstOffset, ax
def _NetworkPathName, ax ; False
def _startPointer
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; skip through any leading spaces
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
push ds
currSegment ds ; point to default segment
les si, dword ptr [ _UnexpandedFileName ][ bp ]
call getDrive
storarg _drive, ax ; save argument
ifc expandFileName_Error ; invalid drive -->
call scanInvalidFilenameChars ; make sure filename is ok
ifc expandFileName_Error ; if error -->
mov word ptr [ _UnexpandedFileName. _pointer ][ bp ], si
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; get selected drive current directory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getarg ax, _drive
mov cl, sizeCDS
mul cl ; ax contains offset to current drive
lds si, dword ptr ss:[ _RxDOS_pCDS ] ; actual address in CDS
add si, ax ; from
add si, _cdsActualDirectory ; proper offset
xor cx, cx
mov cl, byte ptr [ _cdsNonSubstOffset ][ si ]
mov word ptr [ _cds_SubstOffset ][ bp ], cx
mov dx, word ptr [ _cdsStartClusterDir ][ si ]
mov word ptr [ _currCluster ][ bp ], dx ; current starting cluster
push ds
push si
call StringLength ; length of source string
getdarg es, di, _ExpandBuffer ; address of expanded buffer
rep movsb ; copy buffer
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; does path end with a \ or / ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp byte ptr es:[ di - 1 ], '/' ; ends with trailing \ ?
jz expandFileName_18 ; yes, else add -->
cmp byte ptr es:[ di - 1 ], '\' ; ends with trailing \ ?
jz expandFileName_18 ; yes, else add -->
inc di ; add trailing \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -