internal bool Find(string path, out ArchiveNode node) { string internalPath = path.Replace(PATH_SEPARATOR, INTERNAL_SEPARATOR); node = Nodes.FirstOrDefault(x => x.QualifiedName == internalPath); return(node == null); }
internal int GetNodeDataEnd(string name) { ArchiveNode node = GetNode(name); if (node == null) { return(0); } return(node.End); }
internal int GetNodeDataStart(string name) { ArchiveNode node = GetNode(name); if (node == null) { return(0); } return(node.Start); }
internal static ArchiveHeader Deserialize(Stream s) { byte[] nodeCountBlock = new byte[sizeof(int)]; s.Read(nodeCountBlock, 0, nodeCountBlock.Length); int nodeCount = BitConverter.ToInt32(nodeCountBlock, 0); List <ArchiveNode> nodes = new List <ArchiveNode>(); for (int i = 0; i < nodeCount; i++) { nodes.Add(ArchiveNode.Deserialize(s)); } return(new ArchiveHeader(nodes)); }
public static ArchiveNode Deserialize(Stream s) { byte[] sSize = new byte[sizeof(int)]; s.Read(sSize, 0, sSize.Length); int blockSize = BitConverter.ToInt32(sSize, 0); byte[] block = new byte[blockSize]; s.Read(block, 0, block.Length); ArchiveNode node = new ArchiveNode { Start = BitConverter.ToInt32(block, 0), End = BitConverter.ToInt32(block, sizeof(int)), NodeType = (ArchiveHeader.ArchiveNodeType)BitConverter.ToInt32(block, sizeof(int) * 2), QualifiedName = Encoding.UTF8.GetString(block, sizeof(int) * 3, blockSize - sizeof(int) * 3) }; return(node); }
internal string[] GetAllFolders() { List <string> folder = new List <string>(); for (int i = 0; i < Nodes.Count; i++) { string dir = Nodes[i].Parent; while (dir != "") { if (!folder.Contains(dir)) { folder.Add(dir); dir = ArchiveNode.GetParent(dir); } else { break; } } } return(folder.ToArray()); }