home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn17h.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  2.2 KB  |  40 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;         Function 17H: Rename File(s), FCB-based            ;
  4.         ;                                                            ;
  5.         ;         int FCB_rename(uXFCBold,uXFCBnew)                  ;
  6.         ;             char *uXFCBold,*uXFCBnew;                      ;
  7.         ;                                                            ;
  8.         ;         Returns 0 if file(s) renamed OK, otherwise         ;
  9.         ;         returns -1.                                        ;
  10.         ;                                                            ;
  11.         ;         Note: Both uXFCB's must have the drive and         ;
  12.         ;         filename fields (bytes 07H through 12H) and        ;
  13.         ;         the extension flag (byte 00H) set before           ;
  14.         ;         the call to FCB_rename (see Function 29H).         ;
  15.         ;                                                            ;
  16.         ;************************************************************;
  17.  
  18. cProc   FCB_rename,PUBLIC,<ds,si,di>
  19. parmDP  puXFCBold
  20. parmDP  puXFCBnew
  21. cBegin
  22.         loadDP  es,di,puXFCBold ; ES:DI = Pointer to uXFCBold.
  23.         mov     dx,di           ; Save offset in DX.
  24.         add     di,7            ; Advance pointer to start of regular
  25.                                 ; FCBold.
  26.         loadDP  ds,si,puXFCBnew ; DS:SI = Pointer to uXFCBnew.
  27.         add     si,8            ; Advance pointer to filename field
  28.                                 ; FCBnew.
  29.                                 ; Copy name from FCBnew into FCBold
  30.                                 ; at offset 11H:
  31.         add     di,11h          ; DI points 11H bytes into old FCB.
  32.         mov     cx,0bh          ; Copy 0BH bytes, moving new
  33.         rep     movsb           ; name into old FCB.
  34.         push    es              ; Set DS to segment of FCBold.
  35.         pop     ds
  36.         mov     ah,17h          ; Ask MS-DOS to rename old
  37.         int     21h             ; file(s) to new name(s).
  38.         cbw                     ; Set return flag to 0 or -1.
  39. cEnd
  40.