mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-14 21:23:38 +00:00
An exception occurred in ReadOnlySubStream when attempting to set the position to the same value.
This commit is contained in:
@@ -69,16 +69,8 @@ namespace SharpCompress.Common.Arc
|
||||
|
||||
public static DateTime ConvertToDateTime(long rawDateTime)
|
||||
{
|
||||
// Extract components using bit manipulation
|
||||
int year = (int)((rawDateTime >> 25) & 0x7F) + 1980;
|
||||
int month = (int)((rawDateTime >> 21) & 0xF);
|
||||
int day = (int)((rawDateTime >> 16) & 0x1F);
|
||||
int hour = (int)((rawDateTime >> 11) & 0x1F);
|
||||
int minute = (int)((rawDateTime >> 5) & 0x3F);
|
||||
int second = (int)((rawDateTime & 0x1F) * 2); // Multiply by 2 since DOS seconds are stored as halves
|
||||
|
||||
// Return as a DateTime object
|
||||
return new DateTime(year, month, day, hour, minute, second);
|
||||
// Convert Unix timestamp to DateTime (UTC)
|
||||
return DateTimeOffset.FromUnixTimeSeconds(rawDateTime).UtcDateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ internal class ReadOnlySubStream : NonDisposingStream
|
||||
public ReadOnlySubStream(Stream stream, long? origin, long bytesToRead)
|
||||
: base(stream, throwOnDispose: false)
|
||||
{
|
||||
if (origin != null)
|
||||
if (origin != null && stream.Position != origin.Value)
|
||||
{
|
||||
stream.Position = origin.Value;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ internal class ReadOnlySubStream : NonDisposingStream
|
||||
|
||||
public override void Flush() { }
|
||||
|
||||
public override long Length => throw new NotSupportedException();
|
||||
public override long Length => base.Length;
|
||||
|
||||
public override long Position
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user