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:

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

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

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

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

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