Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion NBTModel/Data/Nodes/NbtFileDataNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion NBTModel/Data/Nodes/RegionFileDataNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down
16 changes: 11 additions & 5 deletions NBTModel/NbtPath.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;

namespace NBTExplorer.Model
{
public class NbtPathEnumerator : IEnumerable<DataNode>
{
private class PathPartDesc
{
public string Name;
public DataNode Node;
//public string Name;
//public DataNode Node;
}

private string _pathRoot;
Expand All @@ -22,15 +23,18 @@ 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<DataNode> 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 ()
Expand All @@ -41,11 +45,13 @@ IEnumerator IEnumerable.GetEnumerator ()
private IEnumerable<DataNode> EnumerateNodes (DataNode containerNode, List<string> 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;

Expand Down Expand Up @@ -82,8 +88,8 @@ public class NbtPath
{
private class PathPart
{
public string Name;
public DataNode Node;
//public string Name;
//public DataNode Node;
}


Expand Down