MCPcopy
hub / github.com/jvilk/BrowserFS / IsoFS

Class IsoFS

src/backend/IsoFS.ts:1156–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1154 * * Microsoft Joliet and Rock Ridge extensions to the ISO9660 standard
1155 */
1156export default class IsoFS extends SynchronousFileSystem implements FileSystem {
1157 public static readonly Name = "IsoFS";
1158
1159 public static readonly Options: FileSystemOptions = {
1160 data: {
1161 type: "object",
1162 description: "The ISO file in a buffer",
1163 validator: bufferValidator
1164 }
1165 };
1166
1167 /**
1168 * Creates an IsoFS instance with the given options.
1169 */
1170 public static Create(opts: IsoFSOptions, cb: BFSCallback<IsoFS>): void {
1171 let fs: IsoFS | undefined;
1172 let e: ApiError | undefined;
1173 try {
1174 fs = new IsoFS(opts.data, opts.name, false);
1175 } catch (e) {
1176 e = e;
1177 } finally {
1178 cb(e, fs);
1179 }
1180 }
1181 public static isAvailable(): boolean {
1182 return true;
1183 }
1184
1185 private _data: Buffer;
1186 private _pvd: PrimaryOrSupplementaryVolumeDescriptor;
1187 private _root: DirectoryRecord;
1188 private _name: string;
1189
1190 /**
1191 * **Deprecated. Please use IsoFS.Create() method instead.**
1192 *
1193 * Constructs a read-only file system from the given ISO.
1194 * @param data The ISO file in a buffer.
1195 * @param name The name of the ISO (optional; used for debug messages / identification via getName()).
1196 */
1197 constructor(data: Buffer, name: string = "", deprecateMsg = true) {
1198 super();
1199 this._data = data;
1200 deprecationMessage(deprecateMsg, IsoFS.Name, {data: "ISO data as a Buffer", name: name});
1201 // Skip first 16 sectors.
1202 let vdTerminatorFound = false;
1203 let i = 16 * 2048;
1204 const candidateVDs = new Array<PrimaryOrSupplementaryVolumeDescriptor>();
1205 while (!vdTerminatorFound) {
1206 const slice = data.slice(i);
1207 const vd = new VolumeDescriptor(slice);
1208 switch (vd.type()) {
1209 case VolumeDescriptorTypeCode.PrimaryVolumeDescriptor:
1210 candidateVDs.push(new PrimaryVolumeDescriptor(slice));
1211 break;
1212 case VolumeDescriptorTypeCode.SupplementaryVolumeDescriptor:
1213 candidateVDs.push(new SupplementaryVolumeDescriptor(slice));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected