public int Read() { AdditionalInfo = null; if (SetReader()) { if (hashes == null) { hashes = new Dictionary <string, ByteStringAuto>(); } int c = hashes.Count; using (reader) { ReadAdditionalInfo(); KeyValuePair <string, ByteStringAuto> item; while (ReadItem(out item)) { if (!string.IsNullOrEmpty(item.Key)) { string k = item.Key; if (!CaseSensitive) { k = k.ToLower(); } if (priority == PriorityItem.Last) { hashes[k] = item.Value; } else { try { hashes.Add(k, item.Value); } catch (ArgumentException) { ByteStringAuto bs = hashes[k]; if (bs == null) { hashes[k] = item.Value; } else if ((priority == PriorityItem.Biggest) && (item.Value != null) && (bs.Length < item.Value.Length)) { hashes[k] = item.Value; } } } } } reader.Close(); } return(hashes.Count - c); } return(0); }
private bool SetHashValue(byte[] bs, ByteStringFormat format) { if (m_HashValue != null) { m_HashValue.Bytes = bs; m_HashValue.StringFormat = format; } else { m_HashValue = new ByteStringAuto(bs, format); } return(bs != null); }
protected override bool ReadItem(out KeyValuePair <string, ByteStringAuto> item) { item = new KeyValuePair <string, ByteStringAuto>(); string s; do { s = reader.ReadLine(); if (s == null) { return(false); } s = s.TrimStart(null); for (int j = 0; j < STRING_COMMENT.Length; ++j) { if (s.StartsWith(STRING_COMMENT[j])) { s = string.Empty; break; } } }while (s == string.Empty); int i = s.IndexOf(STRING_HASH_DELIMITER); bool res = i >= 0; if (res) { string h = s.Substring(0, i).TrimEnd(null); s = s.Substring(i + STRING_HASH_DELIMITER.Length).TrimStart(new char[] { Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar }); res = !string.IsNullOrEmpty(s); if (res) { ByteStringAuto bs; try { bs = new ByteStringAuto(h); } catch (FormatException) { bs = null; } res = (bs != null) && (bs.Length > 0); if (res) { item = new KeyValuePair <string, ByteStringAuto>(s.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar), bs); } } } else if ((m_ReadCount == 0) && !string.IsNullOrEmpty(path) && (reader.Peek() == -1)) { s = s.TrimEnd(null); ByteStringAuto bs = new ByteStringAuto(s); res = bs.Length > 0; if (res) { s = Path.GetFileNameWithoutExtension(path); res = !string.IsNullOrEmpty(s); if (res) { item = new KeyValuePair <string, ByteStringAuto>(s, bs); } } } if (res) { ++m_ReadCount; } return(res); }
public HashHelper(string src) { HashValue = new ByteStringAuto(src); }
public HashHelper(byte[] src, ByteStringFormat format) { HashValue = new ByteStringAuto(src, format); }
public HashHelper(ByteStringAuto src) { HashValue = src; }