error detection

This commit is contained in:
chudov
2008-11-17 07:54:31 +00:00
parent af822ec6bd
commit 1eb2f5a9f5

View File

@@ -49,10 +49,8 @@ namespace UnRarDotNet
while (_size == null && !_close)
Monitor.Wait(this);
}
if (_ex != null)
throw _ex;
if (_size == null)
throw new NotSupportedException();
if (_close)
throw new IOException("Decompression failed", _ex);
return _size.Value;
}
}
@@ -140,14 +138,6 @@ namespace UnRarDotNet
}
public override long Seek(long offset, SeekOrigin origin)
{
Go();
lock (this)
{
while (_size == null && !_close)
Monitor.Wait(this);
if (_size == null)
throw new NotSupportedException();
}
switch (origin)
{
case SeekOrigin.Begin:
@@ -157,9 +147,14 @@ namespace UnRarDotNet
_seek_to = Position + offset;
break;
case SeekOrigin.End:
_seek_to = _size.Value + offset;
_seek_to = Length + offset;
break;
}
if (_seek_to.Value > Length)
{
_seek_to = null;
throw new IOException("Invalid seek");
}
if (_seek_to.Value == _pos)
{
_seek_to = null;
@@ -174,8 +169,6 @@ namespace UnRarDotNet
_buffer = null;
Monitor.Pulse(this);
}
//_seek_to = null;
//throw new NotSupportedException("cannot seek backwards");
}
return _seek_to.Value;
}
@@ -242,6 +235,7 @@ namespace UnRarDotNet
{
do
{
bool foundFile = false;
_unrar.Open(_path, Unrar.OpenMode.Extract);
while (_unrar.ReadHeader())
{
@@ -256,6 +250,7 @@ namespace UnRarDotNet
}
}
_unrar.Test();
foundFile = true;
break;
}
else
@@ -263,6 +258,13 @@ namespace UnRarDotNet
}
_unrar.Close();
lock (this)
{
if (!foundFile)
{
_ex = new FileNotFoundException();
break;
}
else
{
_eof = true;
Monitor.Pulse(this);
@@ -273,6 +275,7 @@ namespace UnRarDotNet
_rewind = false;
_eof = false;
}
}
} while (true);
}
catch (Exception ex)