-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Implement Tar APIs #67883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Tar APIs #67883
Changes from 1 commit
e9fbcc9
0731cb2
8f1f1af
10df463
da4af67
8710ceb
76e484c
c9c4d85
e0dafda
5b8392b
a16d4d9
7ca674e
560b789
b3e5988
c22a8e7
d3e4f31
23caa17
e0b0442
b682576
9fd01c3
7b0d8c3
f1d9b7b
0980fbd
a28f3e5
7f2e516
3f71b60
cb855ed
dd40447
9a28f12
40097c6
b1e8dfc
c11e434
255ec96
8ae7788
d3cbdd2
6b5d078
19eb98d
69ca3e7
b1a2d5a
fb644dd
cd40d62
0ee2c33
58a3476
fc0e568
5d81577
a52dfe4
b227fa9
5745b9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- When reading a regular file entry from one format, and writing it to an archive of another format, need to make sure the entry type is converted to the compatible type. Added tests to verify this for all formats. Changes: - Change NotSupportedException to InvalidOperationException. Adjusted tests. - Improved resource messages based on suggestions. - Clean unused interop code. - Remove PNSE line in csproj.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ internal PosixTarEntry(TarEntryType entryType, string entryName, TarFormat forma | |
| /// When the current entry represents a character device or a block device, the major number identifies the driver associated with the device. | ||
| /// </summary> | ||
| /// <remarks>Character and block devices are Unix-specific entry types.</remarks> | ||
| /// <exception cref="NotSupportedException">The entry does not represent a block device or a character device.</exception> | ||
| /// <exception cref="InvalidOperationException">The entry does not represent a block device or a character device.</exception> | ||
| /// <exception cref="ArgumentOutOfRangeException">Cannot set a negative value.</exception> | ||
|
||
| public int DeviceMajor | ||
| { | ||
|
|
@@ -35,7 +35,7 @@ public int DeviceMajor | |
| { | ||
| if (_header._typeFlag is not TarEntryType.BlockDevice and not TarEntryType.CharacterDevice) | ||
| { | ||
| throw new NotSupportedException(SR.TarEntryBlockOrCharacterExpected); | ||
| throw new InvalidOperationException(SR.TarEntryBlockOrCharacterExpected); | ||
| } | ||
|
|
||
| if (value < 0 || value > 99_999_999) | ||
|
|
@@ -50,7 +50,7 @@ public int DeviceMajor | |
| /// When the current entry represents a character device or a block device, the minor number is used by the driver to distinguish individual devices it controls. | ||
| /// </summary> | ||
| /// <remarks>Character and block devices are Unix-specific entry types.</remarks> | ||
| /// <exception cref="NotSupportedException">The entry does not represent a block device or a character device.</exception> | ||
| /// <exception cref="InvalidOperationException">The entry does not represent a block device or a character device.</exception> | ||
| /// <exception cref="ArgumentOutOfRangeException">Cannot set a negative value.</exception> | ||
| public int DeviceMinor | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Subsequently, would it make sense for DeviceMajor/Minor to be combined into a single property? e.g. of type
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can discuss this in a separate issue to determine if we want to modify these public APIs into what you proposed. |
||
| { | ||
|
|
@@ -59,7 +59,7 @@ public int DeviceMinor | |
| { | ||
| if (_header._typeFlag is not TarEntryType.BlockDevice and not TarEntryType.CharacterDevice) | ||
| { | ||
| throw new NotSupportedException(SR.TarEntryBlockOrCharacterExpected); | ||
| throw new InvalidOperationException(SR.TarEntryBlockOrCharacterExpected); | ||
| } | ||
| if (value < 0 || value > 99_999_999) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ public SubReadStream(Stream superStream, long startPosition, long maxLength) | |
| { | ||
| if (!superStream.CanRead) | ||
| { | ||
| throw new NotSupportedException(SR.IO_NotSupported_UnreadableStream); | ||
| throw new InvalidOperationException(SR.IO_NotSupported_UnreadableStream); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In what situations will this exception be thrown? Should this be an assert instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. We shouldn't reach all the way here with an unreadable stream. We already checked that in the public APIs. |
||
| _startInSuperStream = startPosition; | ||
| _positionInSuperStream = startPosition; | ||
|
|
@@ -54,7 +54,7 @@ public override long Position | |
| set | ||
| { | ||
| ThrowIfDisposed(); | ||
| throw new NotSupportedException(SR.IO_NotSupported_UnseekableStream); | ||
| throw new InvalidOperationException(SR.IO_NotSupported_UnseekableStream); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -158,13 +158,13 @@ protected async ValueTask<int> ReadAsyncCore(Memory<byte> buffer, CancellationTo | |
| return ret; | ||
| } | ||
|
|
||
| public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(SR.IO_NotSupported_UnseekableStream); | ||
| public override long Seek(long offset, SeekOrigin origin) => throw new InvalidOperationException(SR.IO_NotSupported_UnseekableStream); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the wrapped stream is seekable, why don't we want this one to be seekable as well?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should rename this class to UnseekableSubReadStream. For seekable streams, we wrap the main stream with the other class, SeekableSubReadStream, which overrides Seek and allows performing such action. |
||
|
|
||
| public override void SetLength(long value) => throw new NotSupportedException(SR.IO_NotSupported_UnseekableStream); | ||
| public override void SetLength(long value) => throw new InvalidOperationException(SR.IO_NotSupported_UnseekableStream); | ||
|
|
||
| public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(SR.IO_NotSupported_UnwritableStream); | ||
| public override void Write(byte[] buffer, int offset, int count) => throw new InvalidOperationException(SR.IO_NotSupported_UnwritableStream); | ||
|
|
||
| public override void Flush() => throw new NotSupportedException(SR.IO_NotSupported_UnwritableStream); | ||
| public override void Flush() => throw new InvalidOperationException(SR.IO_NotSupported_UnwritableStream); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a nop. Flush is allowed to be used on read-only streams as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for letting me know. Will fix that. |
||
|
|
||
| // Close the stream for reading. Note that this does NOT close the superStream (since | ||
| // the substream is just 'a chunk' of the super-stream | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.