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

📄 rxdoscpy.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        lea di, offset [ _createFilename ][ bp ]        ; make destination name
        call _makeUniqueName                            ; make unique name

        lea dx, offset [ _createFilename ][ bp ]        ; destination filename
        Int21 OpenFile, OPEN_ACCESS_READONLY            ; we'll try open first
        jc _Copy_52                                     ; MUST create -->

        mov bx, ax
        call GetClusterValue                            ; cluster of dest
        mov word ptr [ _destCluster. _low  ][ bp ], ax  ; (cluster)
        mov word ptr [ _destCluster. _high ][ bp ], dx  ; (drive )
        Int21 CloseFile                                 ; release file

        call _compareClusters                           ; compare src and dest Clusters
        ifz _copyCannotCopyOverSelf                     ; camnnot copy over self -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  create file
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_52:
        getarg ax, _overide                             ; previous overide
        lea dx, offset [ _createFilename ][ bp ]        ; destination filename
      ; call _copyOverideCheck                          ; see if overide is ok
      ; storarg _overide, ax                            ; store for future reference

        mov cx, ATTR_NORMAL
        Int21 CreateFile                                ; creates NULL file (after open try above)
        ifc _copyCannotCreateError                      ; if cannot be created or nulled -->

        mov bx, ax
        storarg _destHandle, ax
        call GetClusterValue                            ; cluster of dest
        mov word ptr [ _destCluster. _low  ][ bp ], ax  ; (cluster)
        mov word ptr [ _destCluster. _high ][ bp ], dx  ; (drive )

        call _compareClusters                           ; compare src and dest Clusters
        ifz _copyCannotCopyOverSelf                     ; camnnot copy over self -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  display filename
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_56:
        getarg bx, _srcHandle
        Int21 IoControl, 00                             ; is source a char device ?
        test dx, sftIsDevice                            ; test device flag
        jnz _Copy_66                                    ; if device, skip display filename -->

        mov dx, offset [ RxDOS_DTA. findFileName ]
        call DisplayLine                                ; display line
        call CRLF                                       ; cr/lf

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  copy loop
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_66:
        mov cx, 128
        getarg bx, _srcHandle
        lea dx, offset [ _buffer ][ bp ]
        Int21 ReadFile                                  ; read 
        ifc _copyDisplayError                           ; if error -->

        mov cx, ax                                      ; bytes read
        or cx, cx                                       ; null chars returned ?
        jz _Copy_82                                     ; must be end of file -->

        getarg bx, _destHandle
        lea dx, offset [ _buffer ][ bp ]
        Int21 WriteFile                                 ; write
        jmp _Copy_66                                    ; read more -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  close source file
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Copy_82:
        getarg bx, _srcHandle
        call _CopyCloseFile
        storarg _srcHandle, -1                          ; change handle to reflect this

        cmp word ptr [ __NextAddMode  ][ bp ], 0000     ; is next add mode ?
        jnz _Copy_92                                    ; yes, go to next -->

        getarg bx, _destHandle
        call _CopyCloseFile                             ; if no adds left ...
        storarg _destHandle, -1
        inc word ptr [ _filesCopied ][ bp ]             ; # files copied.

        Int21 FindNextFile                              ; see if more files to copy
        ifnc _Copy_36                                   ; if file found -->

_Copy_92:
        jmp _Copy_30

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_Copy_Return:
        getarg bx, _destHandle
        cmp bx, -1                                      ; destination still open ?
        jz _Copy_ReturnClose_08                         ; no, don't close -->
        call _CopyCloseFile
        storarg _destHandle, -1
        inc word ptr [ _filesCopied ][ bp ]             ; # files copied.

_Copy_ReturnClose_08:
        lea di, offset [ _filesCopied ][ bp ]
        push di                                         ; first arg encountered

        mov di, offset _Copy_FilesCopied
        push di
        lea di, offset [ _buffer ][ bp ]
        push di
        call _sprintf
        add sp, ax                                      ; # args passed
        call DisplayLine

        Return

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  add mode
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_Copy_AddMode:
        mov word ptr [ __AddMode  ][ bp ], -1           ; set add mode
        jmp _Copy_32

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  test switches
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_Copy_TestSwitch:
        mov al, byte ptr [ si+1 ]
        call _lowerCase                                 ; test switch option

        goto 'a', _copyAsciiSwitch
        goto 'b', _copyBinarySwitch

        push ax
        mov dx, offset CmndError_BadSwitch
        call DisplayLine                                ; show error message

        pop dx
        call DisplayLine                                ; show arg
        Return

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  if ascii switch
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_copyAsciiSwitch:
        storarg __Mode, 01                              ; ascii mode
        jmp _Copy_32

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  if binary switch
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_copyBinarySwitch:
        storarg __Mode, 00                              ; binary mode
        jmp _Copy_32

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  error in rename command
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_copyCannotCopyOverSelf:
        mov dx, offset CmndError_CannotCopyUntoSelf
        jmp short _copyDisplayError

_copyCannotCreateError:
        mov dx, offset CmndError_CannotCreateFile
      ; jmp short _copyDisplayError

_copyDisplayError:
        call DisplayErrorMessage
      ; jmp short _copyErrorCleanUp

_copyErrorCleanUp:
        getarg bx, _destHandle
        cmp bx, -1                                      ; if not assigned, 
        jz _copyErrorCleanUp_08                         ; don't delete -->
        call _CopyCloseFile

_copyErrorCleanUp_08:
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Do Not Close Device                                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Inputs:                                                      ;
        ;   bx     file Handle                                          ;
        ;                                                               ;
        ;...............................................................;

_CopyCloseFile:
        cmp bx, -1                                      ; if not assigned, 
        jz _CopyClose_Exit                              ; exit -->
        or bx, bx
        jz _CopyClose_Exit                              ; exit -->

        Int21 IoControl, 00                             ; is source a char device ?
        test dx, sftIsDevice                            ; test device flag
        jnz _CopyClose_Exit                             ; if device, skip close -->

        Int21 CloseFile                                 ; close source file

_CopyClose_Exit:
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get ptrto filename after drive and path info                 ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Inputs:                                                      ;
        ;   ss:di  pointer to null terminated path                      ;
        ;                                                               ;
        ;  Outputs:                                                     ;
        ;   di     returns pointer within name                          ;
        ;   cy     set if no filename found                             ;
        ;                                                               ;
        ;...............................................................;

_PtrTo_Filename:

        xor ax, ax
        mov cx, -1
        repnz scasb                                     ; scan for null terminator

        neg cx                                          ; actual size in cx

_PtrTo_Filename_08:
        cmp byte ptr ss:[ di - 1 ], '\'                 ; previous char a '\' ?
        jz _PtrTo_Filename_12                           ; if found -->

        dec di                                          ; scan prev
        loop _PtrTo_Filename_08                         ; continue until start -->

        stc

_PtrTo_Filename_12:
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Insure OK to overwrite file                                  ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Inputs:                                                      ;
        ;   ax     previous overide                                     ;
        ;   dx     filename pointer                                     ;
        ;                                                               ;
        ;  Outputs:                                                     ;
        ;   dx     filename pointer                                     ;
        ;   ax     action code                                          ;
        ;          'A'  overide all                                     ;
        ;          0000 no                                              ;
        ;          0001 yes                                             ;
        ;                                                               ;
        ;...............................................................;

_copyOverideCheck:
        cmp al, 'A'                                     ; all ?
        jnz _copyOverideCheck_06                        ; no -->
        ret

_copyOverideCheck_06:
        push dx

        mov cx, ATTR_NORMAL                             ; normal
        Int21 FindFirstFile                             ; see if file exists
        ifc _copyOverideCheck_OK                        ; doesn't, so exit with OK to overide


      ; display message, get overide ..  





_copyOverideCheck_OK:
        mov ax, TRUE

_copyOverideCheck_Exit:
        pop dx
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Copy Argument                                                ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   si     points to argument start                             ;
        ;   di     points to destination                                ;
        ;...............................................................;

_copyArgument:

⌨️ 快捷键说明

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