From 4a1887d28b96c503cd8b4ac9aa2b57c8d834c349 Mon Sep 17 00:00:00 2001 From: mazunki Date: Fri, 31 Dec 2021 06:23:25 +0100 Subject: [PATCH 1/3] removed warning about used exception var --- NBTModel/Data/Nodes/RegionFileDataNode.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NBTModel/Data/Nodes/RegionFileDataNode.cs b/NBTModel/Data/Nodes/RegionFileDataNode.cs index 036d9186..ecd32560 100644 --- a/NBTModel/Data/Nodes/RegionFileDataNode.cs +++ b/NBTModel/Data/Nodes/RegionFileDataNode.cs @@ -89,8 +89,11 @@ protected override void ExpandCore () } } catch (Exception e) { - if (FormRegistry.MessageBox != null) + if (FormRegistry.MessageBox != null) { FormRegistry.MessageBox("Not a valid region file."); + } else { + Console.WriteLine(e.ToString()); + } } } From ec095b946f87b953e06dd2f2ff6118b18f0876a1 Mon Sep 17 00:00:00 2001 From: mazunki Date: Fri, 31 Dec 2021 06:23:54 +0100 Subject: [PATCH 2/3] added warning about incompatible filetype extensions --- NBTModel/Data/Nodes/NbtFileDataNode.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NBTModel/Data/Nodes/NbtFileDataNode.cs b/NBTModel/Data/Nodes/NbtFileDataNode.cs index 866d8124..83ac3683 100644 --- a/NBTModel/Data/Nodes/NbtFileDataNode.cs +++ b/NBTModel/Data/Nodes/NbtFileDataNode.cs @@ -51,7 +51,12 @@ private static NbtFileDataNode TryCreateFrom (string path, CompressionType compr public static bool SupportedNamePattern (string path) { path = Path.GetFileName(path); - return _namePattern.IsMatch(path); + if (_namePattern.IsMatch(path)) { + return true; + } else { + Console.WriteLine("File doesn't have the appropriate extension: '{0}'", path); + return false; + } } protected override NodeCapabilities Capabilities From 221cc3614d872e13cd2e358ed8c695744dcb8d20 Mon Sep 17 00:00:00 2001 From: mazunki Date: Fri, 31 Dec 2021 06:24:59 +0100 Subject: [PATCH 3/3] commented unused variables from legacy commented code, thus removing warnings --- NBTModel/NbtPath.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/NBTModel/NbtPath.cs b/NBTModel/NbtPath.cs index f2affa39..f65764ec 100644 --- a/NBTModel/NbtPath.cs +++ b/NBTModel/NbtPath.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System; namespace NBTExplorer.Model { @@ -8,8 +9,8 @@ public class NbtPathEnumerator : IEnumerable { private class PathPartDesc { - public string Name; - public DataNode Node; + //public string Name; + //public DataNode Node; } private string _pathRoot; @@ -22,6 +23,8 @@ public NbtPathEnumerator (string path) if (string.IsNullOrEmpty(_pathRoot)) _pathRoot = Directory.GetCurrentDirectory(); + Console.WriteLine("Root: '{0}': ", _pathRoot); + Console.WriteLine("Paths: [{0}]", string.Join(",", _pathParts.ToArray())); } public IEnumerator GetEnumerator () @@ -29,8 +32,9 @@ public IEnumerator GetEnumerator () DataNode dataNode = new DirectoryDataNode(_pathRoot); dataNode.Expand(); - foreach (DataNode childNode in EnumerateNodes(dataNode, _pathParts)) + foreach (DataNode childNode in EnumerateNodes(dataNode, _pathParts)) { yield return childNode; + } } IEnumerator IEnumerable.GetEnumerator () @@ -41,11 +45,13 @@ IEnumerator IEnumerable.GetEnumerator () private IEnumerable EnumerateNodes (DataNode containerNode, List nextLevels) { containerNode.Expand(); + Console.WriteLine("Enumerating {0}", string.Join(",", nextLevels.ToArray()) ); if (nextLevels.Count == 0) { yield return containerNode; yield break; } + Console.WriteLine("Count: {0}", containerNode.Nodes.Count); if (containerNode.Nodes.Count == 0) yield break; @@ -82,8 +88,8 @@ public class NbtPath { private class PathPart { - public string Name; - public DataNode Node; + //public string Name; + //public DataNode Node; }