PHP Classes

Extract information

Recommend this page to a friend!

      PHP ISO File  >  All threads  >  Extract information  >  (Un) Subscribe thread alerts  
Subject:Extract information
Summary:Extract information of specific file into .iso file
Messages:3
Author:Romain Bala
Date:2015-06-30 08:39:12
 

  1. Extract information   Reply   Report abuse  
Picture of Romain Bala Romain Bala - 2015-06-30 08:39:12
Hi,

First, thanks a lot for your library.

I'm trying to extract a specific file from an .iso file.
I currently am able to list dirs and files inside but I can't figure out how to get the content of a specific file.

Do you have any example on how to do this ?

Regards,

  2. Re: Extract information   Reply   Report abuse  
Picture of Sergey Vanyushin Sergey Vanyushin - 2015-11-04 13:32:09 - In reply to message 1 from Romain Bala
// init iso image
$iso = new \CISOFile;
$iso->open($filename);
$iso->ISOInit();

// get descriptor
$usedDesc = $this->iso->GetDescriptor(SUPPLEMENTARY_VOLUME_DESC);
if(!$usedDesc) $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);

// get block size
$isoBlockSize = $usedDesc->iBlockSize;

// traverse directories and create files table
$files_locations = array();
$files_sizes = array();

$directories = $usedDesc->LoadMPathTable($this->iso);
foreach ($directories as $Directory) {
$directory = $Directory->GetFullPath($directories, false);
$directory = trim($directory, '/');
if ($directory != '') {
$directory .= '/';
}
$files = $Directory->LoadExtents($this->iso, $usedDesc->iBlockSize, true);
if ($files) {
foreach ($files as $file) {
if (in_array($file->strd_FileId, array('.', '..'))) continue;
$files_locations[$file->Location] = $directory.$file->strd_FileId;
$files_sizes[$directory.$file->strd_FileId] = $file->DataLen;
}
}
}

// find file position in iso image
// for example, let's use filename "README.txt"
$Location = array_search('README.txt', $files_locations);
$Location_Real = $Location * $isoBlockSize;

// seek file
$iso->Seek($Location_Real, SEEK_SET);
// read file
$content = $iso->Read($files_sizes['README.txt']);

  3. Re: Extract information   Reply   Report abuse  
Picture of Sergey Vanyushin Sergey Vanyushin - 2015-11-04 13:33:22 - In reply to message 1 from Romain Bala
Better view code at https://gist.github.com/wapmorgan/e1d7864dc8c086893eb1