include	clib.inc
include	dos.inc

PPROC rename, Oldname:DPTR, Newname:DPTR
	push	di
  ifdef __LFN__
	mov	al,_ifsmgr
	mov	bx,_osversion
  endif
	MPUSH	ds
	MLDS	dx,Oldname
	MLES	di,Newname
  ifdef __LFN__
	stc
	cmp	bx,0207h
	je	rename_0702
	test	al,al
  endif
	mov	ax,5600h	; DOS 2+ - RENAME FILE
  ifdef __LFN__
	jz      rename_21
	cmp	bl,7
	je	rename_0700
	cmp	bl,5
	jne	rename_21
    rename_0700:
	mov	ax,7156h	; Windows95 - RENAME FILE
	jmp	rename_21
    rename_0702:
	mov	ax,43FFh	; MS-DOS 7.20 (Win98)
	mov	cl,56h
  endif
    rename_21:
	int	21h
	MPOP	ds
	jc	rename_err
	xor	ax,ax
    rename_end:
	pop	di
	ret
    rename_err:
	call	@dosmaper
	mov	ax,-1
	jmp	rename_end
PEND	rename

	END
