2008-09-24 20:32:01 +01:00
|
|
|
/***************************************************************************
|
2011-08-28 14:25:16 +01:00
|
|
|
* Copyright (C) 2008,2011 by Volker Lanz <vl@fidra.de> *
|
2008-09-24 20:32:01 +01:00
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "fs/hfs.h"
|
|
|
|
|
|
|
|
#include "util/externalcommand.h"
|
|
|
|
#include "util/capacity.h"
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QRegExp>
|
|
|
|
|
|
|
|
namespace FS
|
|
|
|
{
|
2010-01-27 13:00:14 +00:00
|
|
|
FileSystem::CommandSupportType hfs::m_GetUsed = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_GetLabel = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_Create = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_Shrink = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_Move = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_Check = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_Copy = FileSystem::cmdSupportNone;
|
|
|
|
FileSystem::CommandSupportType hfs::m_Backup = FileSystem::cmdSupportNone;
|
2008-09-24 20:32:01 +01:00
|
|
|
|
|
|
|
hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
|
|
|
|
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Hfs)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void hfs::init()
|
|
|
|
{
|
2010-01-27 13:00:14 +00:00
|
|
|
m_GetLabel = cmdSupportCore;
|
|
|
|
m_Create = findExternal("hformat") ? cmdSupportFileSystem : cmdSupportNone;
|
|
|
|
m_Check = findExternal("hfsck") ? cmdSupportFileSystem : cmdSupportNone;
|
|
|
|
m_Move = m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
|
|
|
|
m_Backup = cmdSupportCore;
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|
|
|
|
|
2010-05-20 16:25:55 +01:00
|
|
|
bool hfs::supportToolFound() const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
// m_GetUsed != cmdSupportNone &&
|
|
|
|
m_GetLabel != cmdSupportNone &&
|
|
|
|
// m_SetLabel != cmdSupportNone &&
|
|
|
|
m_Create != cmdSupportNone &&
|
|
|
|
m_Check != cmdSupportNone &&
|
|
|
|
// m_UpdateUUID != cmdSupportNone &&
|
|
|
|
// m_Grow != cmdSupportNone &&
|
|
|
|
// m_Shrink != cmdSupportNone &&
|
|
|
|
m_Copy != cmdSupportNone &&
|
|
|
|
m_Move != cmdSupportNone &&
|
|
|
|
m_Backup != cmdSupportNone;
|
|
|
|
// m_GetUUID != cmdSupportNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileSystem::SupportTool hfs::supportToolName() const
|
|
|
|
{
|
2014-05-17 03:34:51 +01:00
|
|
|
return SupportTool("hfsutils", QUrl("http://www.mars.org/home/rob/proj/hfs/"));
|
2010-05-20 16:25:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-24 20:32:01 +01:00
|
|
|
qint64 hfs::maxCapacity() const
|
|
|
|
{
|
|
|
|
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
|
|
|
}
|
|
|
|
|
2013-01-03 12:43:03 +00:00
|
|
|
qint64 hfs::maxLabelLength() const
|
|
|
|
{
|
|
|
|
return 27;
|
|
|
|
}
|
|
|
|
|
2008-09-24 20:32:01 +01:00
|
|
|
bool hfs::check(Report& report, const QString& deviceNode) const
|
|
|
|
{
|
|
|
|
ExternalCommand cmd(report, "hfsck", QStringList() << "-v" << deviceNode);
|
|
|
|
return cmd.run(-1) && cmd.exitCode() == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hfs::create(Report& report, const QString& deviceNode) const
|
|
|
|
{
|
2010-05-15 14:10:34 +01:00
|
|
|
ExternalCommand cmd(report, "hformat", QStringList() << deviceNode);
|
|
|
|
return cmd.run(-1) && cmd.exitCode() == 0;
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|
|
|
|
}
|