ContentCompareFiles is called in Synchronize dirs to compare two files by content, e.g. two text files with different line breaks, one Windows (CRLF) and one Unix (LF only).
Declaration
int __stdcall ContentCompareFiles(PROGRESSCALLBACKPROC progresscallback,int compareindex,TCHAR* filename1,TCHAR* filename2,FileDetailsStruct* filedetails);
Description of parameters
progresscallback
|
Callback function to inform the calling program about the compare progress. If progresscallback returned a value other than zero (0), the user pressed the Abort/Cancel button and the comparison MUST be aborted with return value -2. You should call this message only every 100-200 milliseconds or so, because callbacks are slow.
|
compareindex
|
The value returned by ContentGetSupportedField for this compare field (starting with 10000)
|
filename1
|
The first name to be compared
|
filename2
|
The second name to be compared
|
filedetails
|
A structure which informs the plugin about the size, timestamp and attributes of both files
|
Return value
1
|
The two files are equal, show equal sign in list
|
2
|
The two files are equal, show equal sign with 'TXT' below it in list
|
0
|
The two files are different
|
-1
|
Could not open at least one of the files
|
-2
|
Compare aborted
|
-3
|
The file cannot be compared with this function, please continue with the next plugin. Example: A plugin which compares two Word files by contents (even if the meta data is different) needs to return -3 if at least one of the two files isn't a Word file
|
100 or higher
|
The two files are equal. The plugin file contains a 16x16 icon resource with this numeric ID, to be loaded via LoadImage(DllHandle,MAKEINTRESOURCE(id),IMAGE_ICON,16,16,LR_SHARED); which will be shown between the two files. The icon must contain a 16 color image, and may also contain higher color images. Please test your icon at least with black on white and white on black window settings (Control panel - Display).There are two types of icons you can use:
- 1: If the value is <10000, the icon will be drawn in addition to the equal sign (which will be in black or white, depending on the color of the background). The upper 8 pixels (plus 1 pixel optional border) may be used for drawing the additional image or text.
- 2: If the value is >=10000, no equal sign will be drawn by TC, so the plugin can use the entire 16x16 space for drawing.
|
- Do not return 0 (files different) if the two files are binary identical (containing exactly the same data) just because the plugin cannot compare them - this would break the normal compare function. Return -3 instead.
- It's recommended to make a binary comparison first if the plugin is for a broad range of files, so the user may use *.* as the file type. Example_ See our "filesys" sample content plugin (text comparison), which makes a binary comparison until it finds the first difference, and then continues with using its text comparison method.
Back to Content plugins developer guide