bitburner-src/src/Paths/ContentFile.ts
catloversg 7b993f3550
MISC: Remove file-saver (#1217)
Also refactor to dedup our own download code
2024-04-19 13:38:44 -07:00

19 lines
737 B
TypeScript

import type { BaseServer } from "../Server/BaseServer";
import { ScriptFilePath } from "./ScriptFilePath";
import { TextFilePath } from "./TextFilePath";
/** Provide a common interface for accessing script and text files */
export type ContentFilePath = ScriptFilePath | TextFilePath;
export interface ContentFile {
filename: ContentFilePath;
content: string;
deleteFromServer: (server: BaseServer) => boolean;
}
export type ContentFileMap = Map<ContentFilePath, ContentFile>;
/** Generator function to allow iterating through all content files on a server */
export function* allContentFiles(server: BaseServer): Generator<[ContentFilePath, ContentFile], void, undefined> {
yield* server.scripts;
yield* server.textFiles;
}