mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
error detection
This commit is contained in:
@@ -49,10 +49,8 @@ namespace UnRarDotNet
|
|||||||
while (_size == null && !_close)
|
while (_size == null && !_close)
|
||||||
Monitor.Wait(this);
|
Monitor.Wait(this);
|
||||||
}
|
}
|
||||||
if (_ex != null)
|
if (_close)
|
||||||
throw _ex;
|
throw new IOException("Decompression failed", _ex);
|
||||||
if (_size == null)
|
|
||||||
throw new NotSupportedException();
|
|
||||||
return _size.Value;
|
return _size.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,14 +138,6 @@ namespace UnRarDotNet
|
|||||||
}
|
}
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
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)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case SeekOrigin.Begin:
|
case SeekOrigin.Begin:
|
||||||
@@ -157,9 +147,14 @@ namespace UnRarDotNet
|
|||||||
_seek_to = Position + offset;
|
_seek_to = Position + offset;
|
||||||
break;
|
break;
|
||||||
case SeekOrigin.End:
|
case SeekOrigin.End:
|
||||||
_seek_to = _size.Value + offset;
|
_seek_to = Length + offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (_seek_to.Value > Length)
|
||||||
|
{
|
||||||
|
_seek_to = null;
|
||||||
|
throw new IOException("Invalid seek");
|
||||||
|
}
|
||||||
if (_seek_to.Value == _pos)
|
if (_seek_to.Value == _pos)
|
||||||
{
|
{
|
||||||
_seek_to = null;
|
_seek_to = null;
|
||||||
@@ -174,8 +169,6 @@ namespace UnRarDotNet
|
|||||||
_buffer = null;
|
_buffer = null;
|
||||||
Monitor.Pulse(this);
|
Monitor.Pulse(this);
|
||||||
}
|
}
|
||||||
//_seek_to = null;
|
|
||||||
//throw new NotSupportedException("cannot seek backwards");
|
|
||||||
}
|
}
|
||||||
return _seek_to.Value;
|
return _seek_to.Value;
|
||||||
}
|
}
|
||||||
@@ -242,6 +235,7 @@ namespace UnRarDotNet
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
bool foundFile = false;
|
||||||
_unrar.Open(_path, Unrar.OpenMode.Extract);
|
_unrar.Open(_path, Unrar.OpenMode.Extract);
|
||||||
while (_unrar.ReadHeader())
|
while (_unrar.ReadHeader())
|
||||||
{
|
{
|
||||||
@@ -256,6 +250,7 @@ namespace UnRarDotNet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_unrar.Test();
|
_unrar.Test();
|
||||||
|
foundFile = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -264,14 +259,22 @@ namespace UnRarDotNet
|
|||||||
_unrar.Close();
|
_unrar.Close();
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
_eof = true;
|
if (!foundFile)
|
||||||
Monitor.Pulse(this);
|
{
|
||||||
while (!_rewind && !_close)
|
_ex = new FileNotFoundException();
|
||||||
Monitor.Wait(this);
|
|
||||||
if (_close)
|
|
||||||
break;
|
break;
|
||||||
_rewind = false;
|
}
|
||||||
_eof = false;
|
else
|
||||||
|
{
|
||||||
|
_eof = true;
|
||||||
|
Monitor.Pulse(this);
|
||||||
|
while (!_rewind && !_close)
|
||||||
|
Monitor.Wait(this);
|
||||||
|
if (_close)
|
||||||
|
break;
|
||||||
|
_rewind = false;
|
||||||
|
_eof = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user