82 references to TarHelpers
System.Formats.Tar (82)
System\Formats\Tar\GnuSparseStream.cs (5)
345
await
TarHelpers
.AdvanceStreamCoreAsync<TAdapter>(_rawStream, skipBytes, cancellationToken).ConfigureAwait(false);
447
int bufferSize = 2 *
TarHelpers
.RecordSize;
467
int newBytes = await TAdapter.ReadAtLeastAsync(rawStream, bytes.AsMemory(availableStart,
TarHelpers
.RecordSize),
TarHelpers
.RecordSize, throwOnEndOfStream: false, cancellationToken).ConfigureAwait(false);
491
if ((availableStart - activeStart) +
TarHelpers
.RecordSize > bufferSize)
System\Formats\Tar\PaxTarEntry.cs (2)
104
_header.ExtendedAttributes[TarHeader.PaxEaATime] =
TarHelpers
.GetTimestampStringFromDateTimeOffset(gnuOther.AccessTime);
108
_header.ExtendedAttributes[TarHeader.PaxEaCTime] =
TarHelpers
.GetTimestampStringFromDateTimeOffset(gnuOther.ChangeTime);
System\Formats\Tar\TarEntry.cs (21)
46
TarHelpers
.ThrowIfEntryTypeNotSupported(entryType, format);
50
_header = new TarHeader(format, entryName,
TarHelpers
.GetDefaultMode(entryType), DateTimeOffset.UtcNow, entryType);
61
TarEntryType compatibleEntryType =
TarHelpers
.GetCorrectTypeFlagForFormat(format, other.EntryType);
63
TarHelpers
.ThrowIfEntryTypeNotSupported(compatibleEntryType, format, nameof(other));
154
get => (UnixFileMode)(_header._mode & (int)
TarHelpers
.ValidUnixFileModes);
157
if ((value & ~
TarHelpers
.ValidUnixFileModes) != 0) // throw on invalid UnixFileModes
323
internal void ExtractRelativeToDirectory(string destinationDirectoryPath, bool overwrite, ref
TarHelpers
.ExtractState extractState)
331
TarHelpers
.CreateDirectory(Path.GetDirectoryName(destinationFullPath)!, mode: null, extractState.PendingModes);
338
TarHelpers
.CreateDirectory(destinationFullPath, Mode, extractState.PendingModes);
339
TarHelpers
.UpdatePendingModificationTimes(extractState.DirectoryModificationTimes, destinationFullPath, ModificationTime);
344
TarHelpers
.CreateDirectory(Path.GetDirectoryName(destinationFullPath)!, mode: null, extractState.PendingModes);
350
internal Task ExtractRelativeToDirectoryAsync(string destinationDirectoryPath, bool overwrite, ref
TarHelpers
.ExtractState extractState, CancellationToken cancellationToken)
363
TarHelpers
.CreateDirectory(Path.GetDirectoryName(destinationFullPath)!, mode: null, extractState.PendingModes);
370
TarHelpers
.CreateDirectory(destinationFullPath, Mode, extractState.PendingModes);
371
TarHelpers
.UpdatePendingModificationTimes(extractState.DirectoryModificationTimes, destinationFullPath, ModificationTime);
377
TarHelpers
.CreateDirectory(Path.GetDirectoryName(destinationFullPath)!, mode: null, extractState.PendingModes);
384
private (string DestinationFullPath, string? LinkTargetPath, bool Deferred) GetDestinationAndLinkPaths(string destinationDirectoryPath, ref
TarHelpers
.ExtractState extractState)
457
if (!
TarHelpers
.FullPathIsEqualOrNested(destinationDirectoryPath, resolvedPath))
497
FileId fileId =
TarHelpers
.GetFileId(filePath);
504
private static bool FilePathEscapesDirectory(string destinationDirectoryPath, string fileDestinationPath, ref
TarHelpers
.ExtractState extractState)
739
if (pendingLinks is { Count: > 0 } &&
TarHelpers
.TryGetPathInfo(filePath, out FileId placeholderId, out _))
System\Formats\Tar\TarFile.cs (2)
643
var extractState = new
TarHelpers
.ExtractState()
689
var extractState = new
TarHelpers
.ExtractState()
System\Formats\Tar\TarHeader.cs (2)
211
_ea[key] =
TarHelpers
.GetTimestampStringFromDateTimeOffset(value);
258
ea[PaxEaMTime] =
TarHelpers
.GetTimestampStringFromDateTimeOffset(_mTime);
System\Formats\Tar\TarHeader.Read.cs (31)
26
byte[] rented = ArrayPool<byte>.Shared.Rent(minimumLength:
TarHelpers
.RecordSize);
27
Memory<byte> buffer = rented.AsMemory(0,
TarHelpers
.RecordSize); // minimumLength means the array could've been larger
182
if (
TarHelpers
.TryGetDateTimeOffsetFromTimestampString(values.MTime, out DateTimeOffset mTime))
188
if (
TarHelpers
.TryGetStringAsBaseTenInteger(values.Mode, out int mode))
194
if (
TarHelpers
.TryGetStringAsBaseTenLong(values.Size, out long size))
216
if (
TarHelpers
.TryGetStringAsBaseTenLong(values.GnuSparseRealSize, out long gnuSparseRealSize))
234
if (
TarHelpers
.TryGetStringAsUidGid(values.Uid, out int uid))
240
if (
TarHelpers
.TryGetStringAsUidGid(values.Gid, out int gid))
258
if (
TarHelpers
.TryGetStringAsBaseTenInteger(values.DevMajor, out int devMajor))
264
if (
TarHelpers
.TryGetStringAsBaseTenInteger(values.DevMinor, out int devMinor))
345
await
TarHelpers
.AdvanceStreamCoreAsync<TAdapter>(archiveStream, _size, cancellationToken).ConfigureAwait(false);
362
await
TarHelpers
.SkipBlockAlignmentPaddingCoreAsync<TAdapter>(archiveStream, _size, cancellationToken).ConfigureAwait(false);
394
await
TarHelpers
.CopyBytesCoreAsync<TAdapter>(archiveStream, copiedData, _size, cancellationToken).ConfigureAwait(false);
412
if (
TarHelpers
.IsAllNullBytes(spanChecksum))
420
checksum = (int)
TarHelpers
.ParseOctal<uint>(spanChecksum);
443
long size =
TarHelpers
.ParseNumeric<long>(buffer.Slice(FieldLocations.Size, FieldLengths.Size));
451
name:
TarHelpers
.ParseUtf8String(buffer.Slice(FieldLocations.Name, FieldLengths.Name)),
452
mode:
TarHelpers
.ParseNumeric<int>(buffer.Slice(FieldLocations.Mode, FieldLengths.Mode)),
458
_uid =
TarHelpers
.ParseUidGid(buffer.Slice(FieldLocations.Uid, FieldLengths.Uid)),
459
_gid =
TarHelpers
.ParseUidGid(buffer.Slice(FieldLocations.Gid, FieldLengths.Gid)),
460
_linkName =
TarHelpers
.ParseUtf8String(buffer.Slice(FieldLocations.LinkName, FieldLengths.LinkName))
504
calculatedChecksum += Checksum(buffer.Slice(FieldLocations.Checksum + FieldLengths.Checksum,
TarHelpers
.RecordSize - (FieldLocations.Checksum + FieldLengths.Checksum)));
516
if (
TarHelpers
.IsAllNullBytes(magic))
602
_uName =
TarHelpers
.ParseUtf8String(buffer.Slice(FieldLocations.UName, FieldLengths.UName));
603
_gName =
TarHelpers
.ParseUtf8String(buffer.Slice(FieldLocations.GName, FieldLengths.GName));
610
_devMajor =
TarHelpers
.ParseNumeric<int>(buffer.Slice(FieldLocations.DevMajor, FieldLengths.DevMajor));
613
_devMinor =
TarHelpers
.ParseNumeric<int>(buffer.Slice(FieldLocations.DevMinor, FieldLengths.DevMinor));
637
long time =
TarHelpers
.ParseNumeric<long>(buffer);
638
return
TarHelpers
.GetDateTimeOffsetFromSecondsSinceEpoch(time);
645
_prefix =
TarHelpers
.ParseUtf8String(buffer.Slice(FieldLocations.Prefix, FieldLengths.Prefix));
736
string longPath =
TarHelpers
.ParseUtf8String(buffer);
System\Formats\Tar\TarHeader.Write.cs (11)
162
TarEntryType actualEntryType =
TarHelpers
.GetCorrectTypeFlagForFormat(TarEntryFormat.V7, _typeFlag);
172
TarEntryType actualEntryType =
TarHelpers
.GetCorrectTypeFlagForFormat(TarEntryFormat.Ustar, _typeFlag);
436
_mode =
TarHelpers
.GetDefaultMode(entryType),
453
tmpChecksum += WriteCommonFields(buffer,
TarHelpers
.GetCorrectTypeFlagForFormat(TarEntryFormat.Gnu, _typeFlag));
487
_mode =
TarHelpers
.GetDefaultMode(_typeFlag);
495
tmpChecksum += WriteCommonFields(buffer,
TarHelpers
.GetCorrectTypeFlagForFormat(TarEntryFormat.Pax, _typeFlag));
780
int paddingAfterData =
TarHelpers
.CalculatePadding(_size);
783
Debug.Assert(paddingAfterData <=
TarHelpers
.RecordSize);
785
Span<byte> zeros = stackalloc byte[
TarHelpers
.RecordSize];
797
int paddingAfterData =
TarHelpers
.CalculatePadding(_size);
800
Debug.Assert(paddingAfterData <=
TarHelpers
.RecordSize);
System\Formats\Tar\TarReader.cs (1)
207
await
TarHelpers
.SkipBlockAlignmentPaddingCoreAsync<TAdapter>(_archiveStream, _previouslyReadEntry._header._size, cancellationToken).ConfigureAwait(false);
System\Formats\Tar\TarWriter.cs (4)
304
Span<byte> buffer = stackalloc byte[
TarHelpers
.RecordSize];
344
byte[] rented = ArrayPool<byte>.Shared.Rent(minimumLength:
TarHelpers
.RecordSize);
345
Memory<byte> buffer = rented.AsMemory(0,
TarHelpers
.RecordSize); // minimumLength means the array could've been larger
374
const int TwoRecordSize =
TarHelpers
.RecordSize * 2;
System\Formats\Tar\TarWriter.Unix.cs (3)
57
Interop.Sys.FileTypes.S_IFREG =>
TarHelpers
.GetRegularFileEntryTypeForFormat(Format),
80
entry._header._mTime =
TarHelpers
.GetDateTimeOffsetFromSecondsSinceEpoch(status.MTime);
88
entry._header._mode = status.Mode & (int)
TarHelpers
.ValidUnixFileModes;