1
/***************************************************************************
2
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18
***************************************************************************/
20
#include "jobs/backupfilesystemjob.h"
22
#include "core/partition.h"
23
#include "core/device.h"
24
#include "core/copysourcedevice.h"
25
#include "core/copytargetfile.h"
27
#include "fs/filesystem.h"
29
#include "util/report.h"
33
/** Creates a new BackupFileSystemJob
34
@param sourcedevice the device the FileSystem to back up is on
35
@param sourcepartition the Partition the FileSystem to back up is on
36
@param filename name of the file to backup to
38
BackupFileSystemJob::BackupFileSystemJob(Device& sourcedevice, Partition& sourcepartition, const QString& filename) :
40
m_SourceDevice(sourcedevice),
41
m_SourcePartition(sourcepartition),
46
qint32 BackupFileSystemJob::numSteps() const
51
bool BackupFileSystemJob::run(Report& parent)
55
Report* report = jobStarted(parent);
57
if (sourcePartition().fileSystem().supportBackup() == FileSystem::SupportExternal)
58
rval = sourcePartition().fileSystem().backup(*report, sourceDevice(), sourcePartition().deviceNode(), fileName());
59
else if (sourcePartition().fileSystem().supportBackup() == FileSystem::SupportInternal)
61
CopySourceDevice copySource(sourceDevice(), sourcePartition().fileSystem().firstSector(), sourcePartition().fileSystem().lastSector());
62
CopyTargetFile copyTarget(fileName(), sourceDevice().sectorSize());
64
if (!copySource.open())
65
report->line() << i18nc("@info/plain", "Could not open file system on source partition <filename>%1</filename> for backup.", sourcePartition().deviceNode());
66
else if (!copyTarget.open())
67
report->line() << i18nc("@info/plain", "Could not create backup file <filename>%1</filename>.", fileName());
69
rval = copyBlocks(*report, copyTarget, copySource);
72
jobFinished(*report, rval);
77
QString BackupFileSystemJob::description() const
79
return i18nc("@info/plain", "Back up file system on partition <filename>%1</filename> to <filename>%2</filename>", sourcePartition().deviceNode(), fileName());