private void FindChildren(DatabaseFile parent) { var chainMap = parent.ClusterChain; foreach (var child in files) { if (chainMap.Contains(child.Value.Cluster)) { //if (child.Value.HasParent()) //{ // Console.WriteLine("Warning: {0} already has a parent", child.Value.FileName); //} // TODO: Use a HashSet or something.. // Add the file as a child of the parent. if (!parent.Children.Contains(child.Value)) { parent.Children.Add(child.Value); } // TODO: What if this file has multiple parents? // Assign the parent file for this file. if (child.Value.GetParent() != parent) { child.Value.SetParent(parent); } } } }
public DatabaseFile(DirectoryEntry dirent, bool deleted) { this.deleted = deleted; this.dirent = dirent; this.clusterChain = null; this.parent = null; this.Children = new List <DatabaseFile>(); }
private void SaveDirectoryEntry(Dictionary <string, object> directoryEntryObject, DatabaseFile directoryEntry) { directoryEntryObject["Cluster"] = directoryEntry.Cluster; directoryEntryObject["Offset"] = directoryEntry.Offset; /* * At this moment, I believe this will only be used for debugging. */ directoryEntryObject["FileNameLength"] = directoryEntry.FileNameLength; directoryEntryObject["FileAttributes"] = (byte)directoryEntry.FileAttributes; directoryEntryObject["FileName"] = directoryEntry.FileName; directoryEntryObject["FileNameBytes"] = directoryEntry.FileNameBytes; directoryEntryObject["FirstCluster"] = directoryEntry.FirstCluster; directoryEntryObject["FileSize"] = directoryEntry.FileSize; directoryEntryObject["CreationTime"] = directoryEntry.CreationTime.AsInteger(); directoryEntryObject["LastWriteTime"] = directoryEntry.LastWriteTime.AsInteger(); directoryEntryObject["LastAccessTime"] = directoryEntry.LastAccessTime.AsInteger(); if (directoryEntry.IsDirectory()) { directoryEntryObject["Children"] = new List <Dictionary <string, object> >(); var childrenList = directoryEntryObject["Children"] as List <Dictionary <string, object> >; foreach (var child in directoryEntry.Children) { var childObject = new Dictionary <string, object>(); childrenList.Add(childObject); SaveDirectoryEntry(childObject, child); } } directoryEntryObject["Clusters"] = directoryEntry.ClusterChain; }
public void SetParent(DatabaseFile parent) { this.parent = parent; }