static public AVEntryTree loadEntries() { AVEntryTree resList = new AVEntryTree(); FileStream db = File.Open(dbName, FileMode.Open); byte[] bytes = new byte[7]; db.Read(bytes, 0, 7); if (Encoding.ASCII.GetString(bytes) == Encoding.ASCII.GetString(name)) { int nEntries = db.ReadByte(); byte[] virusName = new byte[20]; byte[] signature = new byte[8]; byte[] hash = new byte[16]; byte[] type = new byte[5]; for (int i = 0; i < nEntries; i++) { db.Read(virusName, 0, 20); AVEntry entry = new AVEntry(Encoding.ASCII.GetString(virusName)); int lOffset = db.ReadByte(); int rOffset = db.ReadByte(); int length = db.ReadByte(); db.Read(signature, 0, 8); db.Read(hash, 0, 16); db.Read(type, 0, 5); entry.setSignatureInfo(lOffset, rOffset, length, signature, hash, Encoding.ASCII.GetString(type)); resList.insertNode(entry); } db.Close(); return(resList); } db.Close(); return(null); }
private void addEntry_Click(object sender, RoutedEventArgs e) { AVEntry newEntry = new AVEntry(tbTitle.Text); string[] offset = tbOffset.Text.Split(';'); if (offset.Count() != 2) { return; } newEntry.setSignatureInfo(Convert.ToInt16(offset[0]), Convert.ToInt16(offset[1]), tbSignature.Text, tbTypes.Text); entryList.insertNode(newEntry); update_ListBox(); }
public void insertNode(AVEntry entry) { if (root == null) { root = new AVEntryTreeNode(entry); size++; return; } if (keyComp(root.getKey(), entry.getStartBits()) == 1) // entry > root { root.rNode = insertNode(root.rNode, entry); } else { root.lNode = insertNode(root.lNode, entry); } root = treeBalance(root); }
private AVEntryTreeNode insertNode(AVEntryTreeNode node, AVEntry entry) { if (node == null) { size++; return(new AVEntryTreeNode(entry)); } if (keyComp(node.getKey(), entry.getStartBits()) == 1) // entry > node { node.rNode = insertNode(node.rNode, entry); } else { node.lNode = insertNode(node.lNode, entry); } node = treeBalance(node); return(node); }
public AVEntryTree(AVEntry root) { this.root = new AVEntryTreeNode(root); size = 1; }
public AVEntryTreeNode(AVEntry entry, byte height = 0) { data = entry; lNode = null; rNode = null; this.height = height; }