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
***************************************************************************/
22
#include "util/externalcommand.h"
23
#include "util/capacity.h"
25
#include <QStringList>
30
FileSystem::SupportType hfs::m_GetUsed = FileSystem::SupportNone;
31
FileSystem::SupportType hfs::m_GetLabel = FileSystem::SupportNone;
32
FileSystem::SupportType hfs::m_Create = FileSystem::SupportNone;
33
FileSystem::SupportType hfs::m_Shrink = FileSystem::SupportNone;
34
FileSystem::SupportType hfs::m_Move = FileSystem::SupportNone;
35
FileSystem::SupportType hfs::m_Check = FileSystem::SupportNone;
36
FileSystem::SupportType hfs::m_Copy = FileSystem::SupportNone;
37
FileSystem::SupportType hfs::m_Backup = FileSystem::SupportNone;
39
hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
40
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Hfs)
46
m_Create = findExternal("hformat") ? SupportExternal : SupportNone;
47
m_Check = m_GetLabel = findExternal("hfsck") ? SupportExternal : SupportNone;
49
m_GetUsed = SupportLibParted;
50
m_Shrink = SupportLibParted;
52
m_Move = m_Copy = (m_Check != SupportNone) ? SupportInternal : SupportNone;
53
m_Backup = SupportInternal;
56
qint64 hfs::maxCapacity() const
58
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
61
QString hfs::readLabel(const QString& deviceNode) const
63
ExternalCommand cmd("hfsck", QStringList() << "-v" << deviceNode);
67
QRegExp rxVolumeName("drVN\\s*= \"(\\w+)\"");
69
if (rxVolumeName.indexIn(cmd.output()) != -1)
70
return rxVolumeName.cap(1);
76
bool hfs::check(Report& report, const QString& deviceNode) const
78
ExternalCommand cmd(report, "hfsck", QStringList() << "-v" << deviceNode);
79
return cmd.run(-1) && cmd.exitCode() == 0;
82
bool hfs::create(Report& report, const QString& deviceNode) const
84
return ExternalCommand(report, "hformat", QStringList() << deviceNode).run(-1);