-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Tar Global Extended Attributes API changes (#70869)
* ref: Global Extended Attributes API changes * src: Global Extended Attributes API changes * tests: Verify Global Extended Attributes API changes * Address suggestions * Address debug suggestion. * Improve the decision of reducing the size of the GEA path. * Use Path.GetTempPath for the GEA path. * Rename field tracking GEA entry number. Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
- Loading branch information
1 parent
b1839d3
commit d3f7e01
Showing
23 changed files
with
986 additions
and
626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ibraries/System.Formats.Tar/src/System/Formats/Tar/PaxGlobalExtendedAttributesTarEntry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
|
||
namespace System.Formats.Tar | ||
{ | ||
/// <summary> | ||
/// Represents a Global Extended Attributes TAR entry from an archive of the PAX format. | ||
/// </summary> | ||
public sealed class PaxGlobalExtendedAttributesTarEntry : PosixTarEntry | ||
{ | ||
private ReadOnlyDictionary<string, string>? _readOnlyGlobalExtendedAttributes; | ||
|
||
// Constructor used when reading an existing archive. | ||
internal PaxGlobalExtendedAttributesTarEntry(TarHeader header, TarReader readerOfOrigin) | ||
: base(header, readerOfOrigin, TarEntryFormat.Pax) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="PaxGlobalExtendedAttributesTarEntry"/> instance with the specified Global Extended Attributes enumeration. | ||
/// </summary> | ||
/// <param name="globalExtendedAttributes">An enumeration of string key-value pairs that represents the metadata to include as Global Extended Attributes.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="globalExtendedAttributes"/> is <see langword="null"/>.</exception> | ||
public PaxGlobalExtendedAttributesTarEntry(IEnumerable<KeyValuePair<string, string>> globalExtendedAttributes) | ||
: base(TarEntryType.GlobalExtendedAttributes, TarHeader.GlobalHeadFormatPrefix, TarEntryFormat.Pax, isGea: true) | ||
{ | ||
ArgumentNullException.ThrowIfNull(globalExtendedAttributes); | ||
_header._extendedAttributes = new Dictionary<string, string>(globalExtendedAttributes); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the global extended attributes stored in this entry. | ||
/// </summary> | ||
public IReadOnlyDictionary<string, string> GlobalExtendedAttributes | ||
{ | ||
get | ||
{ | ||
_header._extendedAttributes ??= new Dictionary<string, string>(); | ||
return _readOnlyGlobalExtendedAttributes ??= _header._extendedAttributes.AsReadOnly(); | ||
} | ||
} | ||
|
||
// Determines if the current instance's entry type supports setting a data stream. | ||
internal override bool IsDataStreamSetterSupported() => false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.