[partition] Tidy up iso9660 detection
This commit is contained in:
parent
1c853941dc
commit
4e61f24960
@ -41,6 +41,10 @@ hasRootPartition( Device* device )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Check if @p path holds an iso9660 filesystem
|
||||||
|
*
|
||||||
|
* The @p path should point to a device; blkid is used to check the FS type.
|
||||||
|
*/
|
||||||
static bool
|
static bool
|
||||||
blkIdCheckIso9660( const QString& path )
|
blkIdCheckIso9660( const QString& path )
|
||||||
{
|
{
|
||||||
@ -49,6 +53,18 @@ blkIdCheckIso9660( const QString& path )
|
|||||||
return r.getOutput().contains( "iso9660" );
|
return r.getOutput().contains( "iso9660" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Convenience to check if @p partition holds an iso9660 filesystem
|
||||||
|
static bool
|
||||||
|
blkIdCheckIso9660P( const Partition* partition )
|
||||||
|
{
|
||||||
|
return blkIdCheckIso9660( partition->partitionPath() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Check if the @p device is an iso9660 device
|
||||||
|
*
|
||||||
|
* An iso9660 device is **probably** a CD-ROM. If the device holds an
|
||||||
|
* iso9660 FS, or any of its partitions do, then we call it an iso9660 device.
|
||||||
|
*/
|
||||||
static bool
|
static bool
|
||||||
isIso9660( const Device* device )
|
isIso9660( const Device* device )
|
||||||
{
|
{
|
||||||
@ -64,13 +80,8 @@ isIso9660( const Device* device )
|
|||||||
|
|
||||||
if ( device->partitionTable() && !device->partitionTable()->children().isEmpty() )
|
if ( device->partitionTable() && !device->partitionTable()->children().isEmpty() )
|
||||||
{
|
{
|
||||||
for ( const Partition* partition : device->partitionTable()->children() )
|
const auto& p = device->partitionTable()->children();
|
||||||
{
|
return std::any_of( p.cbegin(), p.cend(), blkIdCheckIso9660P );
|
||||||
if ( blkIdCheckIso9660( partition->partitionPath() ) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user