Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
RenameFile
◄Example► ◄Back► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
;* RenameFile - Renames specified file.
;*
;* Shows: DOS Function - 56h (Rename File)
;*
;* Params: fspec1 - Pointer to old ASCIIZ file specification
;* fspec2 - Pointer to new ASCIIZ file specification
;*
;* The drive must be the same for both arguments, but the path
;* does not. This allows files to be moved between directories.
;*
;* Return: Short integer with error code
;* 0 if successful
;* 1 if error
RenameFile PROC \
USES ds di, \
fspec1:PTR BYTE, fspec2:PTR BYTE
LoadPtr ds, dx, fspec1 ; Point DS:DX to old file spec
LoadPtr es, di, fspec2 ; Point ES:DI to new file spec
mov ah, 56h ; AH = function number
int 21h ; Rename File
mov ax, 0 ; Clear error code, keep flags
jnc exit ; Return code = 0 if no error
inc ax ; Else set error code
exit: ret
RenameFile ENDP
-♦-