source: calamares/trunk/fuentes/src/modules/partition/jobs/FormatPartitionJob.cpp @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 2.7 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014, Aurélien Gâteau <agateau@kde.org>
4 *   Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "jobs/FormatPartitionJob.h"
21
22#include "utils/Logger.h"
23
24// KPMcore
25#include <core/device.h>
26#include <core/partition.h>
27#include <core/partitiontable.h>
28#include <fs/filesystem.h>
29#include <ops/createfilesystemoperation.h>
30#include <util/report.h>
31
32FormatPartitionJob::FormatPartitionJob( Device* device, Partition* partition )
33    : PartitionJob( partition )
34    , m_device( device )
35{
36}
37
38QString
39FormatPartitionJob::prettyName() const
40{
41    return tr( "Format partition %1 (file system: %2, size: %3 MB) on %4." )
42           .arg( m_partition->partitionPath() )
43           .arg( m_partition->fileSystem().name() )
44           .arg( m_partition->capacity() / 1024 / 1024 )
45            .arg( m_device->name() );
46}
47
48
49QString
50FormatPartitionJob::prettyDescription() const
51{
52    return tr( "Format <strong>%3MB</strong> partition <strong>%1</strong> with "
53               "file system <strong>%2</strong>." )
54           .arg( m_partition->partitionPath() )
55           .arg( m_partition->fileSystem().name() )
56            .arg( m_partition->capacity() / 1024 / 1024 );
57}
58
59
60QString
61FormatPartitionJob::prettyStatusMessage() const
62{
63    return tr( "Formatting partition %1 with "
64               "file system %2." )
65           .arg( m_partition->partitionPath() )
66           .arg( m_partition->fileSystem().name() );
67}
68
69
70Calamares::JobResult
71FormatPartitionJob::exec()
72{
73    Report report( nullptr );  // Root of the report tree, no parent
74    CreateFileSystemOperation op(*m_device, *m_partition, m_partition->fileSystem().type());
75    op.setStatus(Operation::StatusRunning);
76
77    QString message = tr( "The installer failed to format partition %1 on disk '%2'." ).arg( m_partition->partitionPath(), m_device->name() );
78
79    if (op.execute(report))
80        return Calamares::JobResult::ok();
81
82    return Calamares::JobResult::error(message, report.toText());
83}
Note: See TracBrowser for help on using the repository browser.