Skip to content

Commit

Permalink
Add dryrun
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMoolenaar committed Mar 5, 2024
1 parent 6a557e1 commit e323805
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion MatroskaLib/MatroskaLib/MatroskaWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion MkvReadCrawler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e323805

Please sign in to comment.