Skip to content

Commit

Permalink
unused
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Mar 9, 2025
1 parent 0e54bce commit c5ea314
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions src/sahara.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,6 @@ import { CommandHandler, cmd_t, sahara_mode_t, status_t, exec_cmd_t } from "./sa
import { concatUint8Array, packGenerator } from "./utils";


class localFile {
constructor(url) {
this.url = url;
this.filename = url.substring(url.lastIndexOf("/") + 1);
}

async download() {
const rootDir = await navigator.storage.getDirectory();
let writable;
try {
const fileHandle = await rootDir.getFileHandle(this.filename, { create: true });
writable = await fileHandle.createWritable();
} catch (error) {
throw `Sahara - Error getting file handle ${error}`;
}
const response = await fetch(this.url, { mode: "cors" })
if (!response.ok || !response.body) {
throw `Sahara - Failed to fetch loader: ${response.status} ${response.statusText}`;
}
try {
const reader = response.body.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) break;
await writable.write(value);
}
} catch (error) {
throw `Sahara - Could not read response body: ${error}`;
}
try {
await writable.close();
} catch (error) {
throw `Sahara - Error closing file handle: ${error}`;
}
}

async get() {
const rootDir = await navigator.storage.getDirectory();
let fileHandle;
try {
fileHandle = await rootDir.getFileHandle(this.filename);
} catch (error) {
throw `Sahara - Error getting file handle: ${error}`;
}
return await fileHandle.getFile();
}
}


export class Sahara {
/**
* @param {usbClass} cdc
Expand Down

0 comments on commit c5ea314

Please sign in to comment.