summaryrefslogtreecommitdiffstats
path: root/kdat/BackupProfile.h
blob: 048690d7bec86baf0de3abe22396d0dc818fbead (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// KDat - a tar-based DAT archiver
// Copyright (C) 1998-2000  Sean Vyain, [email protected]
// Copyright (C) 2001-2002  Lawrence Widman, [email protected]
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef _BackupProfile_h_
#define _BackupProfile_h_

#include <tqstring.h>
#include <tqstrlist.h>

/**
 * @short This class stores all the information necessary to perform a backup.
 */
class BackupProfile {
    TQString  _name;
    TQString  _lastSavedName;
    TQString  _archiveName;
    TQString  _workingDirectory;
    TQStringList _relativeFiles;
    TQStringList _absoluteFiles;
    bool     _oneFilesystem;
    bool     _incremental;
    TQString  _snapshotFile;
    bool     _removeSnapshot;

    void calcRelativeFiles();
public:
    /**
     * Create a new backup profile.
     */
    BackupProfile();

    /**
     * Load the named backup profile from disk.
     *
     * @param name The name of the backup profile.
     */
    BackupProfile( const TQString & name );

    /**
     * Destroy the backup profile.
     */
    ~BackupProfile();

    /**
     * Load the backup profile from disk.
     */
    void load();

    /**
     * Save the backup profile to disk.  If the backup profile was renamed,
     * the old backup profile will be removed.
     */
    void save();

    /**
     * Query the name of this backup profile.
     *
     * @return The name of this profile.
     */
    TQString getName();

    /**
     * Query the name of the archive.
     *
     * @return The name of the new archive.
     */
    TQString getArchiveName();

    /**
     * Query the working directory for the tar command.
     *
     * @return The working directory.
     */
    TQString getWorkingDirectory();

    /**
     * Query the list of files to backup, relative to the working directory.
     *
     * @return The file list.
     */
    const TQStringList& getRelativeFiles();

    /**
     * Query the list of files to backup, with their full paths.
     *
     * @return The file list.
     */
    const TQStringList& getAbsoluteFiles();

    /**
     * Query whether or not to cross filesystem boundaries when performing the
     * backup.
     *
     * @return TRUE if the backup is restricted to a single filesystem, FALSE
     *         if the backup can cross filesystem boundaries.
     */
    bool isOneFilesystem();

    /**
     * Query whether this is to be a GNU incremental backup.
     *
     * @return TRUE if incremental, otherwise FALSE.
     */
    bool isIncremental();

    /**
     * Query the name of the snapshot file to use for an incremental backup.
     *
     * @return The name of the snapshot file.
     */
    TQString getSnapshotFile();

    /**
     * Query whether to remove the snapshot file before beginning an
     * incremental backup.  This has the effect of performing a full backup.
     *
     * @return TRUE if the snapshot file should be removed, otherwise FALSE.
     */
    bool getRemoveSnapshot();

    /**
     * Set the name of this backup profile.
     *
     * @param name The name of this profile.
     */
    void setName( const TQString & name );
    
    /**
     * Set the name of the archive.
     *
     * @param archiveName The name of the new archive.
     */
    void setArchiveName( const TQString & archiveName );

    /**
     * Set the working directory for the tar command.
     *
     * @param workingDirectory The working directory.
     */
    void setWorkingDirectory( const TQString & workingDirectory );

    /**
     * Set the list of files to backup, with their full paths.
     *
     * @param files The file list.
     */
    void setAbsoluteFiles( const TQStringList& files );

    /**
     * Set whether or not to cross filesystem boundaries when performing the
     * backup.
     *
     * @param oneFilesystem TRUE if the backup is restricted to a single
     *                      filesystem, FALSE if the backup can cross
     *                      filesystem boundaries.
     */
    void setOneFilesystem( bool oneFilesystem );

    /**
     * Set whether this is to be a GNU incremental backup.
     *
     * @param incremental TRUE if incremental, otherwise FALSE.
     */
    void setIncremental( bool incremental );

    /**
     * Set the name of the snapshot file to use for an incremental backup.
     *
     * @param snapshotFile The name of the snapshot file.
     */
    void setSnapshotFile( const TQString & snapshotFile );

    /**
     * Set whether to remove the snapshot file before beginning an
     * incremental backup.  This has the effect of performing a full backup.
     *
     * @param removeSnapshot TRUE if the snapshot file should be removed,
     *                       otherwise FALSE.
     */
    void setRemoveSnapshot( bool removeSnapshot );
};

#endif