mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: manifest storing
This commit is contained in:
1 parent
d3bdbc39d2
commit
81612793e3
1 file changed
+26
-17
@@ -1,27 +1,30 @@
|
|||||||
|
import { writeFile } from "fs/promises";
|
||||||
import SteamUser, { EConnectionProtocol } from "steam-user";
|
import SteamUser, { EConnectionProtocol } from "steam-user";
|
||||||
|
|
||||||
interface SteamManifest {
|
interface SteamManifestFile {
|
||||||
files: {
|
chunks: {
|
||||||
chunks: {
|
sha: string;
|
||||||
sha: string;
|
crc: number;
|
||||||
crc: number;
|
offset: string;
|
||||||
offset: string;
|
cb_original: number;
|
||||||
cb_original: number;
|
cb_compressed: number;
|
||||||
cb_compressed: number;
|
|
||||||
}[];
|
|
||||||
filename: string;
|
|
||||||
size: string;
|
|
||||||
flags: number;
|
|
||||||
sha_filename: string;
|
|
||||||
sha_content: string;
|
|
||||||
linktarget: unknown;
|
|
||||||
}[];
|
}[];
|
||||||
|
filename: string;
|
||||||
|
size: string;
|
||||||
|
flags: number;
|
||||||
|
sha_filename: string;
|
||||||
|
sha_content: string;
|
||||||
|
linktarget: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SteamManifest {
|
||||||
|
files: SteamManifestFile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SteamVFS {
|
export class SteamVFS {
|
||||||
private steam = new SteamUser({ protocol: EConnectionProtocol.TCP });
|
private steam = new SteamUser({ protocol: EConnectionProtocol.TCP });
|
||||||
|
|
||||||
private manifest: SteamManifest;
|
private manifest: Map<string, SteamManifestFile> = new Map();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private username: string,
|
private username: string,
|
||||||
@@ -39,7 +42,7 @@ export class SteamVFS {
|
|||||||
await new Promise((resolve) => this.steam.once("loggedOn", resolve));
|
await new Promise((resolve) => this.steam.once("loggedOn", resolve));
|
||||||
|
|
||||||
const productInfo = await this.steam.getProductInfo([this.app], []);
|
const productInfo = await this.steam.getProductInfo([this.app], []);
|
||||||
const manifest = await new Promise((resolve) => {
|
const manifest: SteamManifest = await new Promise((resolve) => {
|
||||||
this.steam.getManifest(
|
this.steam.getManifest(
|
||||||
this.app,
|
this.app,
|
||||||
this.depot,
|
this.depot,
|
||||||
@@ -52,6 +55,12 @@ export class SteamVFS {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const file of manifest.files) {
|
||||||
|
this.manifest.set(file.filename, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFile("test.manifest.json", JSON.stringify(manifest, null, 2));
|
||||||
|
|
||||||
console.log(JSON.stringify(manifest.files[0], null, 2));
|
console.log(JSON.stringify(manifest.files[0], null, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user