FpRename
Rename file
Declaration
Source position: line 0
function FpRename( |
old: pChar; |
newpath: pChar |
):cInt;
function FpRename( |
old: AnsiString; |
newpath: AnsiString |
):cInt; |
Description
FpRenamerenames the file Oldto NewPath. NewPathcan 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 Oldfile 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
- NewPathexists and is a directory, but Oldis not a directory.
- sys_exdev
- NewPathand Oldare on different devices.
- sys_enotempty or sys_eexist
- NewPathis an existing, non-empty directory.
- sys_ebusy
- Oldor NewPathis a directory and is in use by another process.
- sys_einval
- NewPathis part of Old.
- sys_emlink
- OldPathor NewPathalready have tha maximum amount of links pointing to them.
- sys_enotdir
- part of Oldor NewPathis not directory.
- sys_efault
- For the pcharcase: One of the pointers points to an invalid address.
- sys_eaccess
- access is denied when attempting to move the file.
- sys_enametoolong
- Either Oldor NewPathis too long.
- sys_enoent
- a directory component in Oldor NewPathdidn't exist.
- sys_enomem
- not enough kernel memory.
- sys_erofs
- NewPathor Oldis on a read-only file system.
- sys_eloop
- too many symbolic links were encountered trying to expand Oldor NewPath
- sys_enospc
- the filesystem has no room for the new directory entry.
See also