PHP code example of homelan / mdfs-disk-reader

1. Go to this page and download the library: Download homelan/mdfs-disk-reader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

homelan / mdfs-disk-reader example snippets


$oMdfs = new \HomeLan\Retro\Acorn\Disk\MdfsReader('/path/to/mdfs.img');

$oMdfs = \HomeLan\Retro\Acorn\Disk\MdfsReader::createHdfs('/path/to/hdfs.img');

$oMdfs = new \HomeLan\Retro\Acorn\Disk\MdfsReader('/path/to/image.img', $iByteOffset);

$oMdfs = new \HomeLan\Retro\Acorn\Disk\MdfsWriter('/path/to/mdfs.img');

$oMdfs = \HomeLan\Retro\Acorn\Disk\MdfsWriter::createHdfs('/path/to/hdfs.img');

$oMdfs->getTitle();   // disk title string (up to 10 chars)
$oMdfs->getIdent();   // disk identification string, e.g. "SJ Research File Server"

$aCatalogue = $oMdfs->getCatalogue();

$aCatalogue = $oMdfs->getCatalogue();
foreach ($aCatalogue as $sName => $aEntry) {
    $sType = $aEntry['type'] === 'dir' ? 'DIR ' : 'FILE';
    $iSize = $aEntry['size'];
    printf("%s  %-20s  %d bytes\n", $sType, $sName, $iSize);
}

function printTree(array $aCat, string $sPrefix = '$'): void {
    foreach ($aCat as $sName => $aEntry) {
        $sPath = $sPrefix . '.' . $sName;
        echo $sPath . "\n";
        if ($aEntry['type'] === 'dir') {
            printTree($aEntry['dir'], $sPath);
        }
    }
}

printTree($oMdfs->getCatalogue());

$sData = $oMdfs->getFile('UTILS.DISASSEM');

$sData = $oMdfs->getFile('BBC.PROGRAMS.ADVENT');

$oMdfs->isFile('BBC.PROGRAMS.ADVENT');  // true if path resolves to a file
$oMdfs->isDir('BBC.PROGRAMS');          // true if path resolves to a directory

$aStat = $oMdfs->getStat('BBC.PROGRAMS.ADVENT');
// ['size' => 12288, 'alloc_vector' => [142, 143, 144, ...]]

$oMdfs->writeFile('UTILS.MYTOOLS.EDITOR', $sBinaryData);

$oMdfs->writeFile(
    path:    'BBC.PROGRAMS.ADVENT',
    data:    $sBinaryData,
    load:    0x00FF0E00,   // 32-bit load address
    exec:    0x00FF0E00,   // 32-bit exec address
    access:  0x0C,         // owner read+write (default)
);

$oMdfs->createDir('UTILS.MYTOOLS');

$oMdfs->deleteFile('BBC.PROGRAMS.ADVENT');

$oMdfs->deleteDir('BBC.PROGRAMS');

$oMdfs->lock('BBC.PROGRAMS.ADVENT');    // set the locked flag
$oMdfs->unlock('BBC.PROGRAMS.ADVENT');  // clear the locked flag

$oMdfs->setAccess('BBC.PROGRAMS.ADVENT', 0x0D);  // owner read+write, public read

$oMdfs->setLoadExec('BBC.PROGRAMS.ADVENT', 0x00FF0E00, 0x00FF0E00);