Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2026.1

# FileSys::Rename( FileSys *, Error * )

Rename the file specified by the `path` protected `FileSys` member to the file specified by the target `FileSys` object.

Virtual? | Yes |
Class | `FileSys` |
Arguments | `FileSys *target` | name of target for rename
| `Error *error` | returned error status
Returns | `void` |

## Notes

On some operating systems, an unlink might be required before calling `Rename()`.

Your implementation must correctly report any system errors that might occur during the rename.

## Example

To use `Rename()` to rename `/usr/logs/log2` to `/usr/logs/log1`:

Copy

    FileSys *f1 = FileSys::Create( FST_TEXT );
    FileSys *f2 = FileSys::Create( FST_TEXT );
    Error e;

    f1-&gt;Set( "/usr/logs/log1" );
    f2-&gt;Set( "/usr/logs/log2" );

    f1-&gt;Rename( f2, &amp;e );

To reimplement `Rename()` to report errors with `Error::Sys()` and provide debugging output:

Copy

    void FileSysDemo::Rename( FileSys *target, Error *e )
    {
        if ( rename( Name(), target-&gt;Name() ) &lt; 0 )
            e-&gt;Sys( "rename", Name() );

        if ( DEBUG )
            printf( "Debug (Rename): %s to %s\n", Name(), target-&gt;Name() );
    }

Your search for returned results