public string GetString(int symbol) { if (symbol == PropertyStringTable.EmptyStringSymbol) { return(string.Empty); } if (symbol == PropertyStringTable.StringTableFullSymbol) { return(null); } using (LockRead()) { if (symbol >= m_Header.usedStringBytes) { return(null); } var byteOffset = GetStringsOffset() + symbol; if (byteOffset > m_Fs.Length - PropertyStringTable.StringLengthByteSize) { return(null); } m_Fs.Seek(byteOffset, SeekOrigin.Begin); var strLength = ReadInt32(); if (strLength == 0) { return(string.Empty); } if (strLength < 0) { return(null); } if (byteOffset + PropertyStringTable.StringLengthByteSize + strLength > m_Fs.Length) { return(null); } if (m_StringBuffer.Length < strLength) { m_StringBuffer = new byte[strLength]; } TransactionUtils.ReadIntoArray(m_Fs, m_StringBuffer, strLength); return(PropertyStringTable.encoding.GetString(m_StringBuffer, 0, strLength)); } }
public IList <string> GetAllStrings() { using (LockRead()) { var strings = new List <string>(m_Header.count); // Skip the first length for empty string (symbol 0) var startOffset = GetStringsOffset() + PropertyStringTable.StringLengthByteSize; m_Fs.Seek(startOffset, SeekOrigin.Begin); for (var i = 0; i < m_Header.count; ++i) { var strLength = ReadInt32(); if (strLength == 0) { strings.Add(string.Empty); } if (strLength < 0) { break; } if (m_Fs.Position + PropertyStringTable.StringLengthByteSize + strLength > m_Fs.Length) { break; } if (m_StringBuffer.Length < strLength) { m_StringBuffer = new byte[strLength]; } TransactionUtils.ReadIntoArray(m_Fs, m_StringBuffer, strLength); var str = PropertyStringTable.encoding.GetString(m_StringBuffer, 0, strLength); strings.Add(str); } return(strings); } }