file_compare

 

Description

Comare the contents of two files. This function does a byte by byte binary compare

Syntax

int file_compare( LPCSTR lpcszFilename1, LPCSTR lpcszFilename2, uint * pnDiff1stbyte = NULL )

Parameters

lpcszFilename1
[input] fullpath filename of the first file
lpcszFilename2
[input] fullpath filename of the second file
pnDiff1stbyte
[output] if not NULL to receive the 1st byte (0ffset) that the two files differ

Return

0 if two files match in contents

1 if two files are different

2 if two files are different and pnDiff1stbyte is not NULL but the 1st byte difference is beyond UINT for really large files

-1 if error

Examples

EX1

// This is a self contained sample program for the function file_compare, 
// To run the program, enter the following command in the Script window:
//   file_compare_ex1
// When it runs, it will print the following message:
//   Line+Symbol is NOT the Origin default graph type.
//     To make so, first make a backup copy in Origin.otp at E:\Origin\OriginE80Alpha\,
//     then copy Linesymb.otp to Origin.otp.
//
void file_compare_ex1()
{
    // %a=system.path.program$ 
    string    strPath = GetAppPath(TRUE);
    string  strLinesymbOTP = strPath + "Linesymb.otp";
    string  strOriginOTP = strPath + "Origin.otp";
    
    int rc = file_compare(strLinesymbOTP, strOriginOTP);
    if(rc == 0)
        printf("Line+Symbol is your Origin default graph type.\n");
    else if(rc == 1)
        printf("Line+Symbol is NOT the Origin default graph type.\n To make so, first make a backup copy in Origin.otp at %s,\n then copy Linesymb.otp to Origin.otp.\n",strPath);
    else printf("Error! file_compare failed.\n");

}

Remark

See Also

header to Include

origin.h

Reference