Skip to content

Commit

Permalink
*fix: -mon: did not process directory names with a trailing \ correctly.
Browse files Browse the repository at this point in the history
*add: max filesize criteria. To be configured in the config-xml. Default is 25MB.
  • Loading branch information
Pixinger committed Jun 16, 2021
1 parent 27d7370 commit 316ae86
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions DcsMissionValidator/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public ArgumentParser(string[] args)
{
this._IsValid = true;
this._MonitorFolder = argument.Substring(5, argument.Length - 5);
if (this._MonitorFolder.EndsWith("\""))
{
this._MonitorFolder = this._MonitorFolder.Remove(this._MonitorFolder.Length - 1, 1);
}
if (this._MonitorFolder.EndsWith("\\"))
{
this._MonitorFolder = this._MonitorFolder.Remove(this._MonitorFolder.Length - 1, 1);
}
}
else if (argument.StartsWith("-?", StringComparison.InvariantCultureIgnoreCase) ||
argument.StartsWith("/?", StringComparison.InvariantCultureIgnoreCase))
Expand Down
3 changes: 2 additions & 1 deletion DcsMissionValidator/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace DcsMissionValidator
{
public class Configuration
{
public const int CFG_VERSION = 2;
public const int CFG_VERSION = 3;

[XmlAttribute]
public int CfgVersion = 1;
Expand All @@ -21,6 +21,7 @@ public class Configuration
public string[] InvalidFolders;
public string[] ValidMods;
public double DelayAfterModified_s = 2.0;
public int MaxFileSize_b = 26214400; // 26,214,400 Bytes := 25MB

[XmlIgnore]
private string Filename = "DcsMissionValidator.xml";
Expand Down
7 changes: 7 additions & 0 deletions DcsMissionValidator/MissionValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ private static bool Analyze(Configuration configuration, FileInfo fileInfo, bool
{
bool result = true;

if (fileInfo.Length > configuration.MaxFileSize_b)
{
Logger.Error($"File '{fileInfo.FullName}' exceeded max filesize of {configuration.MaxFileSize_b} bytes.");
textfileLogger?.Write($"Exceeded with {fileInfo.Length} Bytes, the max allowed filesize of {configuration.MaxFileSize_b} Bytes.");
return false;
}

Logger.Debug($"Open miz-File: {fileInfo.FullName}");
using (ZipArchive zip = ZipFile.Open(fileInfo.FullName, ZipArchiveMode.Read))
{
Expand Down
2 changes: 1 addition & 1 deletion DcsMissionValidator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.*")]
[assembly: AssemblyVersion("1.2.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 316ae86

Please sign in to comment.