aboutsummaryrefslogtreecommitdiff
path: root/srcds-pkgs/depotdownloader-json/2_7/0002-emit-json-in-.DepotDownload.patch
blob: cd50e0b9d7c96692ccd07c3b9ba1da13dcce5367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From 740cc23a0993d5a0d757aeb07762714b5e0a4fbe Mon Sep 17 00:00:00 2001
From: yuuko <yuuko@partyvan.io>
Date: Sun, 24 Nov 2024 00:43:33 -0800
Subject: [PATCH 2/2] emit json in .DepotDownload

---
 DepotDownloader/ContentDownloader.cs | 1 +
 DepotDownloader/ProtoManifest.cs     | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs
index 9042c39..bd1ec4a 100644
--- a/DepotDownloader/ContentDownloader.cs
+++ b/DepotDownloader/ContentDownloader.cs
@@ -876,6 +876,7 @@ namespace DepotDownloader
 
                     newProtoManifest = new ProtoManifest(depotManifest, depot.ManifestId);
                     newProtoManifest.SaveToFile(newManifestFileName, out var checksum);
+                    newProtoManifest.SaveToJSON(newManifestFileName.Replace(".bin", ".json"));
                     File.WriteAllBytes(newManifestFileName + ".sha", checksum);
 
                     Console.WriteLine(" Done!");
diff --git a/DepotDownloader/ProtoManifest.cs b/DepotDownloader/ProtoManifest.cs
index 260fdef..ffb0420 100644
--- a/DepotDownloader/ProtoManifest.cs
+++ b/DepotDownloader/ProtoManifest.cs
@@ -5,6 +5,8 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.IO.Compression;
+using System.Text;
+using System.Text.Json;
 using System.Security.Cryptography;
 using ProtoBuf;
 using SteamKit2;
@@ -158,5 +160,11 @@ namespace DepotDownloader
             using var ds = new DeflateStream(fs, CompressionMode.Compress);
             ms.CopyTo(ds);
         }
+
+        public void SaveToJSON(string filename)
+        {
+            var jsonBytes = new UTF8Encoding(true).GetBytes(JsonSerializer.Serialize(this));
+            File.Open(filename, FileMode.Create).Write(jsonBytes, 0, jsonBytes.Length);
+        }
     }
 }
-- 
2.47.0