f_rename

Rename file or directory.

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

Parameter

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. Existing name cannot be used.

Return Values

FR_OK (0)
The function succeeded.
FR_NO_FILE
Could not find the file or directory.
FR_NO_PATH
Could not find the path.
FR_INVALID_NAME
The file name is invalid.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_DENIED
The new name could not be created due to any reason.
FR_WRITE_PROTECTED
The medium is write protected.
FR_RW_ERROR
Any error occured in low level disk I/O.
FR_INCORRECT_DISK_CHANGE
Incorrect disk removal/change has occured.
FR_NOT_ENABLED
FatFs module is not enabled.
FR_NO_FILESYSTEM
There is no valid FAT partition on the disk.

Description

Rename a file or directory and can move it to other directory. This function is not supported in read-only configuration or minimization level of >= 1.

Note: In this revision, moving any directory to other directory collapses the file system.

Example

    // Rename file or directory
    f_rename("oldname.txt", "newname.txt");

    // Rename and move file to other directory simultaneously
    f_rename("oldname.txt", "dir1/newname.txt");

Return