Wednesday, December 15, 2010

CMirrorFile - MFC class not found in documentation

Tip :   CMirrorFile class can write, delete a file. But if you wish you can rollback the changes at any point before committing.
Details :  In CMirrorFile, you can open a file like CFile and you can do as many operations. All the changes will be committed only if you call CMirrorFile::Close(). If you want to rollback the changes, then call CMirrorFile::Abort(). See the code snippet.

Actually when we open a file using CMirrorFile, It is really creating a temporary file. All the further changes that you apply is updated to the temporary file copy. When you call Close(), CMirrorFile, updates the temporary file copy, then replaces the master file with temporary file by using api – ReplaceFile(). When you call Abort(), CMirrorFile just deletes that temporary copy of file.
Cool! You can use CMirrorFile, if you want to do several operations without damaging the main file and can commit only if you need or else you are free to rollback at any point.

Reference    :

Posted By :Krishnaraj S.

No comments:

Post a Comment