Updated to C# 12
This commit is contained in:
@@ -5,13 +5,32 @@ using AMWD.Common.Packing.Tar.Utils;
|
||||
|
||||
namespace AMWD.Common.Packing.Tar
|
||||
{
|
||||
// https://github.com/ygoe/DotnetMakeDeb/blob/v1.1.0/DotnetMakeDeb/Tar/TarWriter.cs
|
||||
/// <summary>
|
||||
/// Writes a tar (see GNU tar) archive to a stream.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Copied from: <see href="https://github.com/ygoe/DotnetMakeDeb/blob/v1.1.0/DotnetMakeDeb/Tar/TarWriter.cs">DotnetMakeDeb</see>
|
||||
/// </remarks>
|
||||
public class TarWriter : LegacyTarWriter
|
||||
{
|
||||
/// <summary>
|
||||
/// Initilizes a new instance of the <see cref="TarWriter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="outStream">The stream to write the archive to.</param>
|
||||
public TarWriter(Stream outStream)
|
||||
: base(outStream)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Writes an entry header (file, dir, ...) to the archive.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="lastModificationTime">The last modification time.</param>
|
||||
/// <param name="count">The number of bytes.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="groupId">The group id.</param>
|
||||
/// <param name="mode">The access mode.</param>
|
||||
/// <param name="entryType">The entry type.</param>
|
||||
protected override void WriteHeader(string name, DateTime lastModificationTime, long count, int userId, int groupId, int mode, EntryType entryType)
|
||||
{
|
||||
var tarHeader = new UsTarHeader()
|
||||
@@ -29,6 +48,17 @@ namespace AMWD.Common.Packing.Tar
|
||||
OutStream.Write(tarHeader.GetHeaderValue(), 0, tarHeader.HeaderSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an entry header (file, dir, ...) to the archive.
|
||||
/// Hashes the username and groupname down to a HashCode.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="lastModificationTime">The last modification time.</param>
|
||||
/// <param name="count">The number of bytes.</param>
|
||||
/// <param name="userName">The username.</param>
|
||||
/// <param name="groupName">The group name.</param>
|
||||
/// <param name="mode">The access mode.</param>
|
||||
/// <param name="entryType">The entry type.</param>
|
||||
protected virtual void WriteHeader(string name, DateTime lastModificationTime, long count, string userName, string groupName, int mode, EntryType entryType)
|
||||
{
|
||||
WriteHeader(
|
||||
@@ -41,6 +71,16 @@ namespace AMWD.Common.Packing.Tar
|
||||
entryType: entryType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a file to the archive.
|
||||
/// </summary>
|
||||
/// <param name="name">The file name.</param>
|
||||
/// <param name="dataSizeInBytes">The filesize in bytes.</param>
|
||||
/// <param name="userName">The username.</param>
|
||||
/// <param name="groupName">The group name.</param>
|
||||
/// <param name="mode">The access mode.</param>
|
||||
/// <param name="lastModificationTime">The last modification time.</param>
|
||||
/// <param name="writeDelegate">The write handle.</param>
|
||||
public virtual void Write(string name, long dataSizeInBytes, string userName, string groupName, int mode, DateTime lastModificationTime, WriteDataDelegate writeDelegate)
|
||||
{
|
||||
var writer = new DataWriter(OutStream, dataSizeInBytes);
|
||||
@@ -52,6 +92,16 @@ namespace AMWD.Common.Packing.Tar
|
||||
AlignTo512(dataSizeInBytes, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a file to the archive.
|
||||
/// </summary>
|
||||
/// <param name="data">The file stream to add to the archive.</param>
|
||||
/// <param name="dataSizeInBytes">The filesize in bytes.</param>
|
||||
/// <param name="fileName">The file name.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="groupId">The group id.</param>
|
||||
/// <param name="mode">The access mode.</param>
|
||||
/// <param name="lastModificationTime">The last modification time.</param>
|
||||
public void Write(Stream data, long dataSizeInBytes, string fileName, string userId, string groupId, int mode,
|
||||
DateTime lastModificationTime)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user