Jump to main content

##

# 1.2.7.4.34 SYS_FS_FileDirectoryRenameMove Function

## C

    SYS_FS_RESULT SYS_FS_FileDirectoryRenameMove
    (
        const char *oldPath,
        const char *newPath
    );

## Summary

Renames or moves a file or directory.

## Description

This function renames or moves a file or directory.

## Precondition

The file or directory to be renamed or moved must exist. This function cannot move files or directories from one drive to another. Do not rename or move files that are open.

## Parameters

Param | Description
--- | ---
oldPath | Path for the file/directory, which has to be renamed/moved.
newPath | New Path for the file/directory.

## Returns

SYS_FS_RES_SUCCESS - Rename/move operation was successful.

SYS_FS_RES_FAILURE - Rename/move operation was unsucessful. The reason for the failure can be retrieved with SYS_FS_Error.

## Example

    SYS_FS_RESULT res;

    // rename "file.txt" to "renamed_file.txt"
    res = SYS_FS_FileDirectoryRenameMove("file.txt", "renamed_file.txt");

    if( res != SYS_FS_RES_SUCCESS)
    {
        // Rename operation failed.
    }

    // Now, move "renamed_file.txt" inside directory "Dir1"
    res = SYS_FS_FileDirectoryRenameMove("renamed_file.txt", "Dir1/renamed_file.txt");

    if( res != SYS_FS_RES_SUCCESS)
    {
        // File move operation failed.
    }

## Remarks

This function cannot move files/ directory from one drive to another. Do not rename/ move files which are open.