// // STORCMP.CPP // // Source file for ArchiveLib 1.0 // // Copyright (c) Greenleaf Software, Inc. 1994 // All Rights Reserved // // CONTENTS // // ALStorage::Compare() // // DESCRIPTION // // This file contains a single function from ALStorage. I'm not // sure why it is in a separate file. // // REVISION HISTORY // // May 26, 1994 1.0A : First release // // #include "arclib.h" #pragma hdrstop #include #include "storage.h" #include "_openf.h" // // int ALStorage::Compare( ALStorage & test ) // // ARGUMENTS: // // test : The storage object that will be compared to this. // // RETURNS // // AL_SUCCESS if the two files match. AL_COMPARE_ERROR if the files // don't match. An error code < AL_SUCCESS is possible if some other // error takes place during the process. // // DESCRIPTION // // This function provides a convenient way to test this object // against another. Note that if the comparison fails, the status // code of this object will be set to an error state. You will need // to clear that error if you intend to use this object again. // // REVISION HISTORY // // May 26, 1994 1.0A : First release // int AL_PROTO ALStorage::Compare( ALStorage AL_DLL_FAR & test ) { ALOpenInputFile in1( test ); ALOpenInputFile in2( *this ); if ( test.mStatus < 0 ) return mStatus = test.mStatus; if ( GetSize() != test.GetSize() ) return mStatus.SetError( AL_COMPARE_ERROR, "Comparison failed. " "File %s and %s are two different sizes.", mName.GetSafeName(), test.mName.GetSafeName() ); long position = 0; for ( ; ; ) { int c = ReadChar(); if ( c < 0 ) break; if ( c != test.ReadChar() ) return mStatus.SetError( AL_COMPARE_ERROR, "File %s and %s differed at position %ld", mName.GetSafeName(), test.mName.GetSafeName(), position ); position++; } return mStatus; }