vdechenaux / iso-9660
ISO9660文件(.iso文件)的流包装器
dev-master
2023-05-01 08:23 UTC
Requires
- php: ^7.4|^8.0
- symfony/polyfill-mbstring: ^1.8
Requires (Dev)
- guzzlehttp/guzzle: ^6.3 || ^7.0
- php-coveralls/php-coveralls: ^2.5
- phpunit/phpunit: ^9.5.10
This package is auto-updated.
Last update: 2024-08-30 01:23:16 UTC
README
PHP Stream Wrapper for ISO9660 files (.iso files)
使用方法
使用Composer安装
$ composer require vdechenaux/iso-9660
注册流包装器
\ISO9660\StreamWrapper::register();
使用支持流包装器的任何函数
// Get the content file_get_contents('iso9660://path/myIsoFile.iso#song.mp3'); // Get the size filesize('iso9660://path/myIsoFile.iso#song.mp3'); // Check if ISO file contains a file file_exists('iso9660://path/myIsoFile.iso#song.mp3'); // List files $iterator = new RecursiveTreeIterator(new RecursiveDirectoryIterator('iso9660://myIsoFile.iso#')); foreach ($iterator as $entry) { echo $entry.PHP_EOL; } // Get a stream on a file contained in the ISO file // Here, a PNG file $stream = fopen('iso9660://myIsoFile.iso#image.png', 'r'); fseek($stream, 1); // Skip 1st byte $header = fread($stream, 3); // We should get "PNG" // Etc...
您必须使用#
将iso文件和内部路径分开,即使右侧为空,如上面的示例所示。
如果您不想使用原生PHP函数,可以使用\ISO9660\Reader
类。
自定义上下文选项
您可以为读取器配置一些行为
showHiddenFiles
(布尔值,默认:false
)将其设置为true
以查看/读取隐藏文件。
要使用选项,您需要做类似以下的事情
$opts = [ 'iso9660' => [ 'showHiddenFiles' => true, ] ]; $context = stream_context_create($opts); file_get_contents('iso9660:///tmp/file.iso#hidden.mp3', false, $context);
如果您正在使用\ISO9660\Reader
类,您可以通过将\ISO9660\ReaderOptions
对象传递给构造函数来使用这些选项。
从光盘驱动器读取
由于这个包是ISO9660的实现,您可以直接通过这样做来直接读取光盘驱动器
$iterator = new RecursiveTreeIterator(new RecursiveDirectoryIterator('iso9660:///dev/cdrom#')); foreach ($iterator as $entry) { echo $entry.PHP_EOL; }
通过使用/dev/cdrom
而不是ISO文件,您可以直接与硬件交互,而无需在操作系统中将光盘挂载。
支持的ISO功能
- 基本的ISO9660支持
- Joliet支持
- SUSP
CE
续续区域SP
系统使用共享协议指示符ER
扩展引用(支持的类型:RRIP_1991A
,IEEE_P1282
,IEEE_1282
)
- Rock Ridge支持
CL
子链接PL
父链接NM
替代名称PX
POSIX文件属性RE
重新定位目录RR
Rock Ridge扩展使用指示器SL
符号链接TF
文件的时间戳
为什么?
为什么不?🤷♂️
我只是为了好玩。我希望有人能找到它的用途 😁
许可
本项目在MIT许可下发布。