RegionLoader: added utility function getProportionUnusedSpace()

This commit is contained in:
Dylan K. Taylor 2020-06-15 13:49:03 +01:00
parent 63b14a083c
commit 9bb8a8f761

View File

@ -404,6 +404,20 @@ class RegionLoader{
return $result;
}
/**
* Returns a float between 0 and 1 indicating what fraction of the file is currently unused space.
*/
public function getProportionUnusedSpace() : float{
$size = $this->nextSector;
$used = self::FIRST_SECTOR; //header is always allocated
foreach($this->locationTable as $entry){
if($entry !== null){
$used += $entry->getSectorCount();
}
}
return 1 - ($used / $size);
}
public function getX() : int{
return $this->x;
}