using System; using System.IO; namespace NBTExplorer.Model { /// /// Common functionality for a few nodes that represent files. /// public class AbstractFileDataNode : DataNode { protected string _path; protected AbstractFileDataNode(string path) { _path = path; } /// /// Not only the name of the node but also (in some cases, but not all) the value (or part of the value) that is displayed to the user. /// Return the full path if this node is the root, otherwise return only the file/folder name /// public override string NodeName { get => Parent == null ? _path : Path.GetFileName(_path); } /// /// Just return NodeName, since that is where the display name is build. /// Side note: I believe NodeName and NodeDisplay should be separated, this would then allow to replace NodePathName with NodeName, but that /// would require changing a lot of unfamiliar (to me) code. /// public override string NodeDisplay { get => NodeName; } /// /// The actual name of the node in a path. Return only the name of the file or folder, not the whole path. /// public override string NodePathName { get => Path.GetFileName(_path); } } }