|
1 | | -PHP ISO file Library. A library for reading ISO files using PHP. |
| 1 | +# PHP ISO Library |
| 2 | + |
| 3 | +PHP Library used to read metadata from ISO files based on [php-iso-file](https://github.com/php-classes/php-iso-file) |
| 4 | + |
| 5 | +This library follows the [ECMA-119](https://www.ecma-international.org/wp-content/uploads/ECMA-119_4th_edition_june_2019.pdf) standard. |
| 6 | + |
| 7 | +Basic concepts |
| 8 | +----- |
| 9 | +- `IsoFile` - main ISO file object, contains one more descriptors |
| 10 | +- `Descriptor` - descriptor object which can have one of the following types defined in `Type` class: |
| 11 | + - `BOOT_RECORD_DESC` : `Boot` object |
| 12 | + - `PRIMARY_VOLUME_DESC` : `PrimaryVolume` object |
| 13 | + - `SUPPLEMENTARY_VOLUME_DESC` : `SupplementaryVolume` object |
| 14 | + - `PARTITION_VOLUME_DESC` : `Partition` object |
| 15 | + - `TERMINATOR_DESC` : `Terminator` object |
| 16 | + - upon initialization of the `IsoFile` object, the descriptors will be populated automatically |
| 17 | +- Volume descriptors contain path table inside which can be loaded using `loadTable` |
| 18 | + - `PathTableRecord` - object which contains the record information for a file/directory |
| 19 | +- Each class contains various properties which can be used to interact with them, most of them `public` |
| 20 | + |
| 21 | +Installation |
| 22 | +------------ |
| 23 | + |
| 24 | +This class can easily be installed via [Composer](https://getcomposer.org): |
| 25 | +`composer require indy2kro/php-iso` |
| 26 | + |
| 27 | + |
| 28 | +Usage |
| 29 | +----- |
| 30 | +```php |
| 31 | +<?php |
| 32 | + |
| 33 | +use PhpIso\IsoFile; |
| 34 | +use PhpIso\Descriptor\Type; |
| 35 | +use PhpIso\Descriptor\PrimaryVolume; |
| 36 | +use PhpIso\FileDirectory; |
| 37 | +use PhpIso\PathTableRecord; |
| 38 | + |
| 39 | +$isoFilePath = 'test.iso'; |
| 40 | + |
| 41 | +$isoFile = new IsoFile($isoFilePath); |
| 42 | + |
| 43 | +// you can process each descriptor using $isoFile->descriptors directly |
| 44 | + |
| 45 | +/** @var PrimaryVolume $primaryVolumeDescriptor */ |
| 46 | +$primaryVolumeDescriptor = $isoFile->descriptors[Type::PRIMARY_VOLUME_DESC]; |
| 47 | + |
| 48 | +// get the path table |
| 49 | +$pathTable = $primaryVolumeDescriptor->loadTable($isoFile); |
| 50 | + |
| 51 | +$paths = []; |
| 52 | + |
| 53 | +/** @var PathTableRecord $pathRecord */ |
| 54 | +foreach ($pathTable as $pathRecord) { |
| 55 | + $currentPath = $pathRecord->getFullPath($pathTable); |
| 56 | + |
| 57 | + $paths[$currentPath] = []; |
| 58 | + |
| 59 | + // check extents |
| 60 | + $extents = $pathRecord->loadExtents($isoFile, $primaryVolumeDescriptor->blockSize); |
| 61 | + |
| 62 | + if ($extents !== false) { |
| 63 | + /** @var FileDirectory $extentRecord */ |
| 64 | + foreach ($extents as $extentRecord) { |
| 65 | + $path = $extentRecord->fileId; |
| 66 | + if ($extentRecord->isDirectory()) { |
| 67 | + $path .= '/'; |
| 68 | + } |
| 69 | + $paths[$currentPath][] = $path; |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +print_r($paths); |
| 75 | +``` |
0 commit comments