⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxdoscpy.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        TITLE   'Copy - RxDOS Command Shell Copy'
        PAGE 59, 132
        .LALL

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Shell Copy                                     ;
        ;...............................................................;

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  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                                        ;
        ;...............................................................;

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Shell                                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Programmer's Notes:                                          ;
        ;                                                               ;
        ;  Command Shell consists of  two parts bound  together into a  ;
        ;  single executable load.  There  exists  a  single  resident  ;
        ;  command shell which is accessible by an Int 2Eh.             ;
        ;                                                               ;
        ;...............................................................;

        include rxdosmac.asm
        include rxdosdef.asm
        include rxdoscin.asm

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Shell                                          ;
        ;...............................................................;

RxDOSCMD SEGMENT PUBLIC 'CODE'
         assume cs:RxDOSCMD, ds:RxDOSCMD, es:RxDOSCMD, ss:RxDOSCMD

        public _Copy

        extrn CmndError_BadSwitch                       : near
        extrn CmndError_CannotCopyUntoSelf              : near
        extrn CmndError_CannotCreateFile                : near
        extrn CmndError_ContentsLostBeforeCopy          : near
        extrn CmndError_InvalidNumberArguments          : near
        extrn CmndError_FileNotFound                    : near
        extrn _Copy_FilesCopied                         : near
        extrn CountArgs                                 : near
        extrn CRLF                                      : near
        extrn deleteArg                                 : near
        extrn DisplayErrorMessage                       : near
        extrn DisplayLine                               : near
        extrn RxDOS_DTA                                 : near
        extrn RxDOS_AllFiles                            : near

        extrn _AppendPathName                           : near
        extrn _CopyString                               : near
        extrn _Copy_FilesCopied                         : near
        extrn _CmndParse_SeparatorCheck                 : near
        extrn _makePath                                 : near
        extrn _lowerCase                                : near
        extrn _SwitchChar                               : near
        extrn _splitpath                                : near
        extrn _sprintf                                  : near

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Copy filenameA+filenameB+filenameC filenameDest              ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   ss:di  Arg Array                                            ;
        ;   ax     Number of arguments in array                         ;
        ;...............................................................;

_Copy:

        Entry
        def __argarray, di                              ; args array
        def __numArgs, ax                               ; # args
        def __Mode, 0000                                ; non-z if ascii/ z if binary
        def _overide, FALSE                             ; no automatic overide
        def __AddMode                                   ; 0000 not add mode
        def __NextAddMode                               ; 0000 next is add mode
        def __bytesRead                                 ; bytes actually read

        def _destfilenameSameAsSource, FALSE            ; if take names from source
        def _filesCopied, 0000
        def _srcHandle  , -1
        def _destHandle , -1
        ddef _destCluster
        ddef _srcCluster

        defbytes _destFilename  , 130
        defbytes _createFilename, 130
        defbytes _copyFilename  , 130
        defbytes _buffer, 128

        _tempFilename = _copyFilename                   ; equate temp filename

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  get/test destination filename
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        mov dx, offset CmndError_InvalidNumberArguments
        cmp ax, 2                                       ; must have at least two args
        ifc _copyDisplayError                           ; any less means error -->

        dec ax
        add ax, ax                                      ; args offset in words
        add di, ax                                      ; point to last arg
        push word ptr [ di ]                            ; get last arg address
        call deleteArg

        pop si
        lea di, offset [ _tempFilename ][ bp ]
        call _copyArgument                              ; copy argument

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  see if dest is just a directory name
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        mov cx, ATTR_DIRECTORY
        lea dx, offset [ _tempFilename ][ bp ]
        Int21 FindFirstFile                             ; locate file with name
        jc _Copy_18                                     ; not a directory -->

    ;  if . or .. handle special

_Copy_08:
        test byte ptr [ RxDOS_DTA. findFileAttribute ], ATTR_DIRECTORY
        jz _Copy_18                                     ; if not a dir entry -->

        cmp byte ptr [ RxDOS_DTA. findFileName ], '.'
        jnz _Copy_24                                    ; if dir and not . or .. -->

        Int21 FindNextFile                              ; locate next file
        jnc _Copy_08                                    ; see if also a dir -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  scan name for just directory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_18:
        lea di, offset [ _tempFilename ][ bp ]

_Copy_20:
        cmp byte ptr [ di ], 00                         ; null ?
        jz _Copy_26                                     ; yes, done -->
        inc di
        cmp byte ptr [ di-1 ], ':'                      ; only drive /colon entered ?
        jnz _Copy_20                                    ; no -->
        cmp byte ptr [ di ], 00                         ; 
        jnz _Copy_26

_Copy_24:
        mov si, offset RxDOS_AllFiles                   ; dummy path 
        call _AppendPathName                            ; append all files
        storarg _destfilenameSameAsSource, TRUE         ; \*.*

_Copy_26:
        lea si, offset [ _tempFilename ][ bp ]
        lea di, offset [ _destFilename ][ bp ]          ; expansion area
        mov byte ptr [ di ], '\'                        ; (in case no output generated)
        Int21 GetActualFileName                         ; expand name
        ifc _copyDisplayError                           ; destination doesn't exist -->

        xor ax, ax
        mov cx, 4
        lea di, offset [ _destCluster ][ bp ]           ; clusters
        rep stosw                                       ; clear clusters

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  main loop through all args
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_30:
        mov word ptr [ __AddMode  ][ bp ], 0000         ; not add mode
        mov word ptr [ __NextAddMode  ][ bp ], 0000     ; next is not add mode

_Copy_32:
        mov di, word ptr [ __argarray ][ bp ]           ; get arg pointer to next arg
        mov si, word ptr [ di ]                         ; point to text 
        or si, si                                       ; null entry ?
        ifz _Copy_Return                                ; yes, return -->

        add word ptr [ __argarray ][ bp ], 2            ; skip this argument next time

        mov al, byte ptr [ si ]
        cmp al, byte ptr [ _SwitchChar ]                ; switch ?
        ifz _Copy_TestSwitch                            ; yes, go test switch -->

        cmp al, '+'
        ifz _Copy_AddMode                               ; set add mode -->

        lea di, offset [ _copyFilename ][ bp ]
        call _copyArgument

        call _scanForwardArgArray                       ; see if followed by +
        mov word ptr [ __NextAddMode  ][ bp ], ax       ; next add mode

        mov dx, di                                      ; copy filename
        mov cx, ATTR_NORMAL   
        Int21 FindFirstFile                             ; locate file with name
        jnc _Copy_36                                    ; if file found -->

        mov dx, offset CmndError_FileNotFound
        call DisplayLine
        jmp _copyErrorCleanUp

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  open source file
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_36:
        lea di, offset [ _copyFilename ][ bp ]
        call _replaceWithRealName

        Int21 OpenFile, OPEN_ACCESS_READONLY            ; open source file
        ifc _copyDisplayError                           ; can't, display error -->

        mov bx, ax
        storarg _srcHandle, ax
        call GetClusterValue                            ; src cluster
        mov word ptr [ _srcCluster. _low  ][ bp ], ax   ; (cluster)
        mov word ptr [ _srcCluster. _high ][ bp ], dx   ; (drive )
        jz _Copy_38                                     ; if not a file -->

        call _compareClusters                           ; compare src and dest Clusters
        jnz _Copy_38                                    ; no -->

    ; error: file destroyed

        mov dx, offset CmndError_ContentsLostBeforeCopy
        call DisplayErrorMessage                        ; dest file same as source
        jmp _copyErrorCleanUp

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  attempt create file
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_38:
        getarg bx, _destHandle
        cmp bx, -1                                      ; any dest file ?
        jz _Copy_40                                     ; no, MUST create -->
        cmp word ptr [ __AddMode  ][ bp ], 0000         ; add mode ?
        ifnz _Copy_56                                   ; yes, append to existing file -->

_Copy_40:
        lea si, offset [ _destFilename ][ bp ]          ; destination filename
        lea di, offset [ _createFilename ][ bp ]        ; make destination name
        call _CopyString                                ; copy string

        cmp word ptr [ _destfilenameSameAsSource ][ bp ], TRUE
        jnz _Copy_48                                    ; name available -->

        lea si, offset [ _destFilename ][ bp ]          ; destination filename
        lea di, offset [ _createFilename ][ bp ]        ; make destination name
        mov byte ptr [ di ], '\'                        ; (in case no output generated)
        Int21 GetActualFileName                         ; expand name
        ifc _copyDisplayError                           ; destination doesn't exist -->

        lea di, offset [ _copyFilename ][ bp ]
        call _PtrTo_Filename                            ; get pointer to filename
        push di

        lea di, offset [ _createFilename ][ bp ]        ; make destination name
        call _PtrTo_Filename                            ; get pointer to filename

        pop si                                          ; source name
        call _CopyString                                ; copy string

_Copy_48:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -