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

C/C++ API Documentation | 2025.2

# FileSys::Close( Error * )

Close the file specified by the `path` protected `FileSys` member and release any OS resources associated with the open file.

Virtual? | Yes |
Class | `FileSys` |
Arguments | `Error *error` | returned error status
Returns | `void` |

## Notes

The default implementation of `Close()` is called every time a file that is currently `Open()` is no longer required. Typically, the handle that was returned for the `Open()` call is used to free up the resource.

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

## Example

To use `Close()` to close an open file:

Copy

    FileSys *f = FileSys::Create( FST_ATEXT );
    Error e;

    f-&gt;Set( "c:\\configfile.txt" );
    f-&gt;Open( FOM_WRITE, &amp;e );
    f-&gt;Close( &amp;e );

To reimplement `Close()` to report errors using `Error::Sys()` and provide debugging output:

Copy

    void FileSysDemo::Close( Error *e )
    {
        if ( close( fd ) == -1 )
            e-&gt;Sys( "close", Name() );

        if ( DEBUG )
            printf( "Debug (Close): %s\n", Name() );
    }

Your search for returned results