mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
ModernKeePassLib custom PCL version
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2012 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Copyright (C) 2003-2014 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -22,42 +22,74 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Serialization
|
||||
{
|
||||
public sealed class BinaryReaderEx : BinaryReader
|
||||
public sealed class BinaryReaderEx
|
||||
{
|
||||
private string m_strReadExcp = null;
|
||||
private Stream m_s;
|
||||
// private Encoding m_enc; // See constructor
|
||||
|
||||
private string m_strReadExcp;
|
||||
public string ReadExceptionText
|
||||
{
|
||||
get { return m_strReadExcp; }
|
||||
set { m_strReadExcp = value; }
|
||||
}
|
||||
|
||||
public BinaryReaderEx(Stream input, Encoding encoding,
|
||||
string strReadExceptionText) :
|
||||
base(input, encoding)
|
||||
private Stream m_sCopyTo = null;
|
||||
/// <summary>
|
||||
/// If this property is set to a non-null stream, all data that
|
||||
/// is read from the input stream is automatically written to
|
||||
/// the copy stream (before returning the read data).
|
||||
/// </summary>
|
||||
public Stream CopyDataTo
|
||||
{
|
||||
get { return m_sCopyTo; }
|
||||
set { m_sCopyTo = value; }
|
||||
}
|
||||
|
||||
public BinaryReaderEx(Stream input, Encoding encoding,
|
||||
string strReadExceptionText)
|
||||
{
|
||||
if(input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
|
||||
m_s = input;
|
||||
// m_enc = encoding; // Not used yet
|
||||
m_strReadExcp = strReadExceptionText;
|
||||
}
|
||||
|
||||
public override byte[] ReadBytes(int count)
|
||||
public byte[] ReadBytes(int nCount)
|
||||
{
|
||||
/*try
|
||||
{*/
|
||||
byte[] pb = base.ReadBytes(count);
|
||||
if((pb == null) || (pb.Length != count))
|
||||
try
|
||||
{
|
||||
byte[] pb = MemUtil.Read(m_s, nCount);
|
||||
if((pb == null) || (pb.Length != nCount))
|
||||
{
|
||||
if(m_strReadExcp != null) throw new IOException(m_strReadExcp);
|
||||
else throw new EndOfStreamException();
|
||||
if(m_strReadExcp != null)
|
||||
throw new IOException(m_strReadExcp);
|
||||
else
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
if(m_sCopyTo != null)
|
||||
m_sCopyTo.Write(pb, 0, pb.Length);
|
||||
return pb;
|
||||
/*}
|
||||
catch(Exception ex)
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
if(m_strReadExcp != null) throw new IOException(m_strReadExcp);
|
||||
if(m_strReadExcp != null)
|
||||
throw new IOException(m_strReadExcp);
|
||||
else throw;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public byte ReadByte()
|
||||
{
|
||||
byte[] pb = ReadBytes(1);
|
||||
return pb[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user