From e323805c0b491c4e53bc2ea01eb3d7e4c25a4178 Mon Sep 17 00:00:00 2001 From: MikeMoolenaar Date: Tue, 5 Mar 2024 20:54:19 +0100 Subject: [PATCH] Add dryrun --- MatroskaLib/MatroskaLib/MatroskaWriter.cs | 3 ++- MkvReadCrawler/Program.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MatroskaLib/MatroskaLib/MatroskaWriter.cs b/MatroskaLib/MatroskaLib/MatroskaWriter.cs index 8806a97..4b148d7 100644 --- a/MatroskaLib/MatroskaLib/MatroskaWriter.cs +++ b/MatroskaLib/MatroskaLib/MatroskaWriter.cs @@ -8,7 +8,7 @@ namespace MatroskaLib; public static class MatroskaWriter { - public static void WriteMkvFile(MkvFile mkfFile) + public static void WriteMkvFile(MkvFile mkfFile, bool dryRun = false) { using var dataStream = File.Open(mkfFile.filePath, FileMode.Open); dataStream.Seek(0, SeekOrigin.Begin); @@ -25,6 +25,7 @@ public static void WriteMkvFile(MkvFile mkfFile) offset, lsBytes); // Write modified changes to file + if (dryRun) return; dataStream.Seek(0, SeekOrigin.Begin); dataStream.Write(lsBytes.ToArray(), 0, lsBytes.Count); } diff --git a/MkvReadCrawler/Program.cs b/MkvReadCrawler/Program.cs index c778a0a..30bf708 100644 --- a/MkvReadCrawler/Program.cs +++ b/MkvReadCrawler/Program.cs @@ -28,7 +28,7 @@ static void Main(string[] args) try { var lsFiles = MatroskaReader.ReadMkvFiles([mkvFile]); - MatroskaWriter.WriteMkvFile(lsFiles[0], true); + MatroskaWriter.WriteMkvFile(lsFiles[0], dryRun:true); stringBuilder.AppendLine("Track count:" + lsFiles[0].tracks.Count); } catch (Exception e)