js-dos Help

Working with File System

When js-dos player successfully starts, the DOSBox command interface is available. You can get it from the event:

Dos(/*element*/, { url: /* bundle url */, onEvent: (event, ci: CommandInterface) => { if (event === "ci-ready") { // now ci is ready } }, );

With ci you can interact with a DOS file system.

Read file from FS

fsReadFile(file: string): Promise<Uint8Array>;

This function will read the file from the given path and return the promise to Uint8Array.

Write file to FS

fsWriteFile(file: string, contents: ReadableStream<Uint8Array> | Uint8Array): Promise<void>;

This method will write contents into the provided file.

Delete file from FS

fsDeleteFile(file: string): Promise<boolean>;

Delete file from FS. The returned value is true when the file was deleted.

Get the whole file tree

You can read the full file system structure by calling:

fsTree(): Promise<FsNode>;

The FsNode contains following:

export interface FsNode { name: string; size: number | null; nodes: FsNode[] | null; }
  • name - is a file name

  • size - size of file in bytes, or null in case of directory

  • nodes - children of directory, or null in case of file

Advanced: using Emscripten FS API

Emscripten API is even more powerful, but also low level. You can access it only in direct mode.

19 июня 2026