f_rename

Renames an object.

FRESULT f_rename (
  const XCHAR* OldName, /* Pointer to old object name */
  const XCHAR* NewName  /* Pointer to new object name */
);

Parameters

OldName
Pointer to a null-terminated string specifies the old object name to be renamed.
NewName
Pointer to a null-terminated string specifies the new object name without drive number.

Return Values

FR_OK (0)
The function succeeded.
FR_NO_FILE
Could not find the old name.
FR_NO_PATH
Could not find the path.
FR_INVALID_NAME
The file name is invalid.
FR_INVALID_DRIVE
The drive number is invalid.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_EXIST
The new name is colliding with an existing name.
FR_DENIED
The new name could not be created due to any reason.
FR_WRITE_PROTECTED
The medium is write protected.
FR_DISK_ERR
The function failed due to an error in the disk function.
FR_INT_ERR
The function failed due to a wrong FAT structure or an internal error.
FR_NOT_ENABLED
The logical drive has no work area.
FR_NO_FILESYSTEM
There is no valid FAT volume on the disk.

Description

Renames an object and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. Do not rename open objects.

QuickInfo

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

Example

    /* Rename an object */
    f_rename("oldname.txt", "newname.txt");

    /* Rename and move an object to other directory */
    f_rename("oldname.txt", "dir1/newname.txt");

Return