Coder Social home page Coder Social logo

iso-9660's Introduction

ISO9660 Stream Wrapper for PHP

PHP Stream Wrapper for ISO9660 files (.iso files)

CircleCI Coverage Status

Usage

Install using Composer:

$ composer require vdechenaux/iso-9660

Register the Stream Wrapper:

\ISO9660\StreamWrapper::register();

Use it, with any function which supports stream wrappers:

// 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...

You must separate the iso file and the internal path with a #, even if the right part is empty, like in above examples.

You can use the \ISO9660\Reader class if you don't want to use native PHP functions.

Custom context options

You can configure some behaviors of the reader:

  • showHiddenFiles (boolean, default: false) Set it to true to see/read hidden files.

To use options, you have to do something like this:

$opts = [
    'iso9660' => [
        'showHiddenFiles'  => true,
    ]
];

$context  = stream_context_create($opts);

file_get_contents('iso9660:///tmp/file.iso#hidden.mp3', false, $context);

If you are using the \ISO9660\Reader class, you can use theses options by passing an \ISO9660\ReaderOptions object to the constructor.

Read from an optical drive

As this package is an ISO9660 implementation, you can directly read an optical drive by doing something like this:

$iterator = new RecursiveTreeIterator(new RecursiveDirectoryIterator('iso9660:///dev/cdrom#'));
foreach ($iterator as $entry) {
    echo $entry.PHP_EOL;
}

By using /dev/cdrom instead of an ISO file, you can directly interact with the hardware, without mounting the disc in the OS.

ISO features supported

  • Basic ISO9660 support
  • Joliet support
  • SUSP
    • CE Continuation Area
    • SP System Use Sharing Protocol Indicator
    • ER Extensions Reference (supported types: RRIP_1991A, IEEE_P1282, IEEE_1282)
  • Rock Ridge support
    • CL Child link
    • PL Parent link
    • NM Alternate name
    • PX POSIX file attributes
    • RE Relocated directory
    • RR Rock Ridge extensions in-use indicator
    • SL Symbolic link
    • TF Time stamp(s) for a file

Why ?

Why not ? ๐Ÿคทโ€โ™‚๏ธ

I made it only for fun. I hope someone will find a usage ๐Ÿ˜

License

This project is released under the MIT license.

iso-9660's People

Contributors

chrismshelton avatar vdechenaux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chrismshelton

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.