mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-26 00:48:22 -04:00
[partition] Add convenience methods to FstabEntry
- Add something like a constructor - Add validity checking
This commit is contained in:
parent
594618f2cc
commit
f1c1d07dca
2 changed files with 41 additions and 0 deletions
|
@ -372,3 +372,31 @@ isEfiBootable( const Partition* candidate )
|
|||
}
|
||||
|
||||
} // nmamespace PartUtils
|
||||
|
||||
/* Implementation of methods for FstabEntry, from OsproberEntry.h */
|
||||
|
||||
bool
|
||||
FstabEntry::isValid() const
|
||||
{
|
||||
return !partitionNode.isEmpty() && !mountPoint.isEmpty() && !fsType.isEmpty();
|
||||
}
|
||||
|
||||
FstabEntry
|
||||
FstabEntry::fromEtcFstab( const QString& rawLine )
|
||||
{
|
||||
QString line = rawLine.simplified();
|
||||
if ( line.startsWith( '#' ) )
|
||||
return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 };
|
||||
|
||||
QStringList splitLine = line.split( ' ' );
|
||||
if ( splitLine.length() != 6 )
|
||||
return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 };
|
||||
|
||||
return FstabEntry{ splitLine.at( 0 ), // path, or UUID, or LABEL, etc.
|
||||
splitLine.at( 1 ), // mount point
|
||||
splitLine.at( 2 ), // fs type
|
||||
splitLine.at( 3 ), // options
|
||||
splitLine.at( 4 ).toInt(), //dump
|
||||
splitLine.at( 5 ).toInt() //pass
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue