[Overview][Constants][Types][Procedures and functions][Index] | Reference for unit 'BaseUnix' (#rtl)

# FpRename

Rename file

## Declaration

Source position: line 0

`function FpRename(`
`old: PChar;`
`newpath: PChar`
`):cint; function FpRename(`
`old: AnsiString;`
`newpath: AnsiString`
`):cint;`

## Description

FpRename renames the file Old to NewPath. NewPath can be in a different directory than Old, but it cannot be on another partition (device). Any existing file on the new location will be replaced.

If the operation fails, then the Old file will be preserved.

The function returns zero on succes, a nonzero value indicates failure.

Note: There exist a portable alterative to fpRename: system.rename. Please use fpRename only if you are writing Unix specific code. System.rename will work on all operating systems.

## Errors

Extended error information can be retrieved using fpGetErrno.

sys_eisdir
  NewPath exists and is a directory, but Old is not a directory.
sys_exdev
  NewPath and Old are on different devices.
sys_enotempty or sys_eexist
  NewPath is an existing, non-empty directory.
sys_ebusy
  Old or NewPath is a directory and is in use by another process.
sys_einval
  NewPath is part of Old.
sys_emlink
  OldPath or NewPath already have tha maximum amount of links pointing to them.
sys_enotdir
  part of Old or NewPath is not directory.
sys_efault
  For the pchar case: One of the pointers points to an invalid address.
sys_eaccess
  access is denied when attempting to move the file.
sys_enametoolong
  Either Old or NewPath is too long.
sys_enoent
  a directory component in Old or NewPath didn't exist.
sys_enomem
  not enough kernel memory.
sys_erofs
  NewPath or Old is on a read-only file system.
sys_eloop
  too many symbolic links were encountered trying to expand Old or NewPath
sys_enospc
  the filesystem has no room for the new directory entry.

## See also

FpUnLink |  | Unlink (i.e. remove) a file.

Documentation generated on: Feb 26 2014