1 /* -*- Mode: C; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3 -*- */
2 
3 /*
4  * GImageView
5  * Copyright (C) 2001-2003 Takuro Ashie
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  *
21  * $Id: compare_filesize.c,v 1.3 2003/06/18 09:26:55 makeinu Exp $
22  */
23 
24 #include "gimv_dupl_finder.h"
25 #include "gimv_image_info.h"
26 #include "gimv_thumb.h"
27 
28 
29 static gint
duplicates_file_size_compare(gpointer data1,gpointer data2,gfloat * similarity)30 duplicates_file_size_compare (gpointer data1, gpointer data2, gfloat *similarity)
31 {
32    GimvThumb *thumb1 = data1, *thumb2 = data2;
33    gint retval, d;
34 
35    if (!thumb1)
36       return thumb2 ? 1 : 0;
37    else if (!thumb2)
38       return 1;
39 
40    d = thumb1->info->st.st_size - thumb2->info->st.st_size;
41 
42    if (d < 0)
43       retval = -1;
44    else if (d > 0)
45       retval = 1;
46    else
47       retval = 0;
48 
49    if (!d)
50       *similarity = 1.0;
51    else
52       *similarity = 0.0;
53 
54    return retval;
55 }
56 
57 
58 GimvDuplCompFuncTable gimv_dupl_file_size_funcs =
59 {
60    label:       N_("File Size"),
61    get_data:    NULL,
62    compare:     duplicates_file_size_compare,
63    data_delete: NULL,
64 };
65