Skip to content

FpRename

Rename file

Declaration

Source position: bunxh.inc line 79

  function FpRename(old: pChar; newpath: pChar) : cint;
  function FpRename(const old: RawByteString; 
                   const newpath: RawByteString) : 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 success, a nonzero value indicates failure.

Note: There exist a portable alternative 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 the 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 file system has no room for the new directory entry.

See also

Name Description
FpUnLink Unlink (i.e. remove) a file.