Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Updated core to latest
Browse files Browse the repository at this point in the history
Refactored to use getters instead of functions
Updated readme
  • Loading branch information
james-pre committed Mar 15, 2024
1 parent aa95c82 commit ab0ad8e
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 179 deletions.
66 changes: 46 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@browserfs/core": "^0.1.0"
"@browserfs/core": "^0.2.2"
}
}
5 changes: 1 addition & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ npm install @browserfs/iso

> 🛈 The examples are written in ESM. If you are using CJS, you can `require` the package. If running in a browser you can add a script tag to your HTML pointing to the `browser.min.js` and use BrowserFS Iso via the global `BrowserFS_ISO` object.
You can't use IsoFS on its own. You must import the core in order to use the backend, and must register it if you plan on using `configure`:

```js
import { configure, fs, registerBackend } from '@browserfs/core';
import { configure, fs } from '@browserfs/core';
import { IsoFS } from '@browserfs/iso';
registerBackend(IsoFS);

const res = await fetch('http://example.com/image.iso');
const isoData = await res.arrayBuffer();
Expand Down
20 changes: 10 additions & 10 deletions src/Directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export abstract class Directory<T extends DirectoryRecord> {
private _fileMap: { [name: string]: T } = {};
constructor(record: T, isoData: ArrayBuffer) {
this._record = record;
let i = record.lba();
let iLimit = i + record.dataLength();
if (!(record.fileFlags() & FileFlags.Directory)) {
let i = record.lba;
let iLimit = i + record.dataLength;
if (!(record.fileFlags & FileFlags.Directory)) {
// Must have a CL entry.
const cl = <CLEntry>record.getSUEntries(isoData).filter(e => e instanceof CLEntry)[0];
i = cl.childDirectoryLba() * 2048;
Expand All @@ -31,15 +31,15 @@ export abstract class Directory<T extends DirectoryRecord> {
// Skip '.' and '..' entries.
if (fname !== '\u0000' && fname !== '\u0001') {
// Skip relocated entries.
if (!r.hasRockRidge() || r.getSUEntries(isoData).filter(e => e instanceof REEntry).length === 0) {
if (!r.hasRockRidge || r.getSUEntries(isoData).filter(e => e instanceof REEntry).length === 0) {
this._fileMap[fname] = r;
this._fileList.push(fname);
}
} else if (iLimit === Infinity) {
// First entry contains needed data.
iLimit = i + r.dataLength();
iLimit = i + r.dataLength;
}
i += r.length();
i += r.length;
}
}
/**
Expand All @@ -49,11 +49,11 @@ export abstract class Directory<T extends DirectoryRecord> {
public getRecord(name: string): DirectoryRecord {
return this._fileMap[name];
}
public getFileList(): string[] {
public get fileList(): string[] {
return this._fileList;
}
public getDotEntry(isoData: ArrayBuffer): T {
return this._constructDirectoryRecord(isoData.slice(this._record.lba()));
return this._constructDirectoryRecord(isoData.slice(this._record.lba));
}
protected abstract _constructDirectoryRecord(data: ArrayBuffer): T;
}
Expand All @@ -62,7 +62,7 @@ export class ISODirectory extends Directory<ISODirectoryRecord> {
super(record, isoData);
}
protected _constructDirectoryRecord(data: ArrayBuffer): ISODirectoryRecord {
return new ISODirectoryRecord(data, this._record.getRockRidgeOffset());
return new ISODirectoryRecord(data, this._record.rockRidgeOffset);
}
}

Expand All @@ -71,6 +71,6 @@ export class JolietDirectory extends Directory<JolietDirectoryRecord> {
super(record, isoData);
}
protected _constructDirectoryRecord(data: ArrayBuffer): JolietDirectoryRecord {
return new JolietDirectoryRecord(data, this._record.getRockRidgeOffset());
return new JolietDirectoryRecord(data, this._record.rockRidgeOffset);
}
}
Loading

0 comments on commit ab0ad8e

Please sign in to comment.