1 /*
2  *      fm-deep-count-job.h
3  *
4  *      Copyright 2009 PCMan <pcman.tw@gmail.com>
5  *
6  *      This file is a part of the Libfm library.
7  *
8  *      This library is free software; you can redistribute it and/or
9  *      modify it under the terms of the GNU Lesser General Public
10  *      License as published by the Free Software Foundation; either
11  *      version 2.1 of the License, or (at your option) any later version.
12  *
13  *      This library is distributed in the hope that it will be useful,
14  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *      Lesser General Public License for more details.
17  *
18  *      You should have received a copy of the GNU Lesser General Public
19  *      License along with this library; if not, write to the Free Software
20  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 
23 
24 #ifndef __FM_DEEP_COUNT_JOB_H__
25 #define __FM_DEEP_COUNT_JOB_H__
26 
27 #include "fm-job.h"
28 #include "fm-path.h"
29 #include <gio/gio.h>
30 #include <sys/types.h>
31 
32 G_BEGIN_DECLS
33 
34 #define FM_DEEP_COUNT_JOB_TYPE              (fm_deep_count_job_get_type())
35 #define FM_DEEP_COUNT_JOB(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj),\
36             FM_DEEP_COUNT_JOB_TYPE, FmDeepCountJob))
37 #define FM_DEEP_COUNT_JOB_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass),\
38             FM_DEEP_COUNT_JOB_TYPE, FmDeepCountJobClass))
39 #define FM_IS_DEEP_COUNT_JOB(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
40             FM_DEEP_COUNT_JOB_TYPE))
41 #define FM_IS_DEEP_COUNT_JOB_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass),\
42             FM_DEEP_COUNT_JOB_TYPE))
43 
44 typedef struct _FmDeepCountJob            FmDeepCountJob;
45 typedef struct _FmDeepCountJobClass        FmDeepCountJobClass;
46 
47 /**
48  * FmDeepCountJobFlags
49  * @FM_DC_JOB_DEFAULT: do deep count for all files/folders
50  * @FM_DC_JOB_FOLLOW_LINKS: don't follow symlinks
51  * @FM_DC_JOB_SAME_FS: only do deep count for files on the same devices. what's the use case of this?
52  * @FM_DC_JOB_PREPARE_MOVE: special handling for moving files. only do deep count for files on different devices
53  * @FM_DC_JOB_PREPARE_DELETE: special handling for deleting files
54  */
55 typedef enum {
56     FM_DC_JOB_DEFAULT = 0,
57     FM_DC_JOB_FOLLOW_LINKS = 1<<0,
58     FM_DC_JOB_SAME_FS = 1<<1,
59     FM_DC_JOB_PREPARE_MOVE = 1<<2,
60     FM_DC_JOB_PREPARE_DELETE = 1 <<3
61 } FmDeepCountJobFlags;
62 
63 /**
64  * FmDeepCountJob
65  * @parent: the parent object
66  * @paths: list of paths to count
67  * @flags: flags for counting
68  * @total_size: counted total file size
69  * @total_ondisk_size: counted total file size on disk
70  * @count: number of files to be moved between devices
71  */
72 struct _FmDeepCountJob
73 {
74     /*< public >*/
75     FmJob parent;
76     FmPathList* paths;
77     FmDeepCountJobFlags flags;
78     goffset total_size;
79     goffset total_ondisk_size;
80     guint count;
81 
82     /*< private >*/
83     gpointer _reserved1;
84     gpointer _reserved2;
85     /* used to count total size used when moving files */
86     dev_t dest_dev;
87     const char* dest_fs_id;
88 };
89 
90 struct _FmDeepCountJobClass
91 {
92     /*< private >*/
93     FmJobClass parent_class;
94 };
95 
96 GType fm_deep_count_job_get_type(void);
97 FmDeepCountJob* fm_deep_count_job_new(FmPathList* paths, FmDeepCountJobFlags flags);
98 
99 /* dev is UNIX device ID.
100  * fs_id is filesystem id in gio format (can be NULL).
101  */
102 void fm_deep_count_job_set_dest(FmDeepCountJob* dc, dev_t dev, const char* fs_id);
103 
104 G_END_DECLS
105 
106 #endif /* __FM_DEEP_COUNT_JOB_H__ */
107