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/setfilesystemlabeljob.h"
22
#include "core/partition.h"
24
#include "fs/filesystem.h"
26
#include "util/report.h"
30
/** Creates a new SetFileSystemLabelJob
31
@param p the Partition the FileSystem whose label is to be set is on
32
@param newlabel the new label
34
SetFileSystemLabelJob::SetFileSystemLabelJob(Partition& p, const QString& newlabel) :
41
bool SetFileSystemLabelJob::run(Report& parent)
45
Report* report = jobStarted(parent);
47
// If there's no support for file system label setting for this file system,
48
// just ignore the request and say all is well. This helps in operations because
49
// we don't have to check for support to avoid having a failed job.
50
if (partition().fileSystem().supportSetLabel() == FileSystem::SupportNone)
51
report->line() << i18nc("@info/plain", "File system on partition <filename>%1</filename> does not support setting labels. Job ignored.", partition().deviceNode());
52
else if (partition().fileSystem().supportSetLabel() == FileSystem::SupportExternal)
54
rval = partition().fileSystem().writeLabel(*report, partition().deviceNode(), label());
57
partition().fileSystem().setLabel(label());
60
jobFinished(*report, rval);
65
QString SetFileSystemLabelJob::description() const
67
return i18nc("@info/plain", "Set the file system label on partition <filename>%1</filename> to \"%2\"", partition().deviceNode(), label());