91 references to TarHelpers
System.Formats.Tar (91)
System\Formats\Tar\GnuTarEntry.cs (2)
62changedATime = TarHelpers.TryGetDateTimeOffsetFromTimestampString(paxOther._header.ExtendedAttributes, TarHeader.PaxEaATime, out DateTimeOffset aTime); 68changedCTime = TarHelpers.TryGetDateTimeOffsetFromTimestampString(paxOther._header.ExtendedAttributes, TarHeader.PaxEaCTime, out DateTimeOffset cTime);
System\Formats\Tar\PaxTarEntry.cs (3)
125_header.ExtendedAttributes[TarHeader.PaxEaATime] = TarHelpers.GetTimestampStringFromDateTimeOffset(gnuOther.AccessTime); 126_header.ExtendedAttributes[TarHeader.PaxEaCTime] = TarHelpers.GetTimestampStringFromDateTimeOffset(gnuOther.ChangeTime); 167string secondsFromEpochString = TarHelpers.GetTimestampStringFromDateTimeOffset(useMTime ? _header._mTime : DateTimeOffset.UtcNow);
System\Formats\Tar\TarEntry.cs (12)
42TarHelpers.ThrowIfEntryTypeNotSupported(entryType, format); 46_header = new TarHeader(format, entryName, TarHelpers.GetDefaultMode(entryType), DateTimeOffset.UtcNow, entryType); 57TarEntryType compatibleEntryType = TarHelpers.GetCorrectTypeFlagForFormat(format, other.EntryType); 59TarHelpers.ThrowIfEntryTypeNotSupported(compatibleEntryType, format, nameof(other)); 140get => (UnixFileMode)(_header._mode & (int)TarHelpers.ValidUnixFileModes); 143if ((value & ~TarHelpers.ValidUnixFileModes) != 0) // throw on invalid UnixFileModes 294TarHelpers.CreateDirectory(destinationFullPath, Mode, pendingModes); 295TarHelpers.UpdatePendingModificationTimes(directoryModificationTimes, destinationFullPath, ModificationTime); 300TarHelpers.CreateDirectory(Path.GetDirectoryName(destinationFullPath)!, mode: null, pendingModes); 317TarHelpers.CreateDirectory(destinationFullPath, Mode, pendingModes); 318TarHelpers.UpdatePendingModificationTimes(directoryModificationTimes, destinationFullPath, ModificationTime); 324TarHelpers.CreateDirectory(Path.GetDirectoryName(destinationFullPath)!, mode: null, pendingModes);
System\Formats\Tar\TarFile.cs (6)
460SortedDictionary<string, UnixFileMode>? pendingModes = TarHelpers.CreatePendingModesDictionary(); 470TarHelpers.SetPendingModes(pendingModes); 471TarHelpers.SetPendingModificationTimes(directoryModificationTimes); 502SortedDictionary<string, UnixFileMode>? pendingModes = TarHelpers.CreatePendingModesDictionary(); 516TarHelpers.SetPendingModes(pendingModes); 517TarHelpers.SetPendingModificationTimes(directoryModificationTimes);
System\Formats\Tar\TarHeader.Read.cs (39)
24Span<byte> buffer = stackalloc byte[TarHelpers.RecordSize]; 45byte[] rented = ArrayPool<byte>.Shared.Rent(minimumLength: TarHelpers.RecordSize); 46Memory<byte> buffer = rented.AsMemory(0, TarHelpers.RecordSize); // minimumLength means the array could've been larger 122if (TarHelpers.TryGetDateTimeOffsetFromTimestampString(ExtendedAttributes, PaxEaMTime, out DateTimeOffset mTime)) 128if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaMode, out int mode)) 134if (TarHelpers.TryGetStringAsBaseTenLong(ExtendedAttributes, PaxEaSize, out long size)) 140if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaUid, out int uid)) 146if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaGid, out int gid)) 164if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaDevMajor, out int devMajor)) 170if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaDevMinor, out int devMinor)) 217TarHelpers.AdvanceStream(archiveStream, _size); 233TarHelpers.SkipBlockAlignmentPadding(archiveStream, _size); 279await TarHelpers.AdvanceStreamAsync(archiveStream, _size, cancellationToken).ConfigureAwait(false); 295await TarHelpers.SkipBlockAlignmentPaddingAsync(archiveStream, _size, cancellationToken).ConfigureAwait(false); 319TarHelpers.CopyBytes(archiveStream, copiedData, _size); 346await TarHelpers.CopyBytesAsync(archiveStream, copiedData, size, cancellationToken).ConfigureAwait(false); 366if (TarHelpers.IsAllNullBytes(spanChecksum)) 370int checksum = (int)TarHelpers.ParseOctal<uint>(spanChecksum); 377long size = (long)TarHelpers.ParseOctal<ulong>(buffer.Slice(FieldLocations.Size, FieldLengths.Size)); 378Debug.Assert(size <= TarHelpers.MaxSizeLength, "size exceeded the max value possible with 11 octal digits. Actual size " + size); 386name: TarHelpers.GetTrimmedUtf8String(buffer.Slice(FieldLocations.Name, FieldLengths.Name)), 387mode: (int)TarHelpers.ParseOctal<uint>(buffer.Slice(FieldLocations.Mode, FieldLengths.Mode)), 388mTime: TarHelpers.GetDateTimeOffsetFromSecondsSinceEpoch((long)TarHelpers.ParseOctal<ulong>(buffer.Slice(FieldLocations.MTime, FieldLengths.MTime))), 393_uid = (int)TarHelpers.ParseOctal<uint>(buffer.Slice(FieldLocations.Uid, FieldLengths.Uid)), 394_gid = (int)TarHelpers.ParseOctal<uint>(buffer.Slice(FieldLocations.Gid, FieldLengths.Gid)), 395_linkName = TarHelpers.GetTrimmedUtf8String(buffer.Slice(FieldLocations.LinkName, FieldLengths.LinkName)) 433if (TarHelpers.IsAllNullBytes(magic)) 519_uName = TarHelpers.GetTrimmedUtf8String(buffer.Slice(FieldLocations.UName, FieldLengths.UName)); 520_gName = TarHelpers.GetTrimmedUtf8String(buffer.Slice(FieldLocations.GName, FieldLengths.GName)); 527_devMajor = (int)TarHelpers.ParseOctal<uint>(buffer.Slice(FieldLocations.DevMajor, FieldLengths.DevMajor)); 530_devMinor = (int)TarHelpers.ParseOctal<uint>(buffer.Slice(FieldLocations.DevMinor, FieldLengths.DevMinor)); 539long aTime = (long)TarHelpers.ParseOctal<ulong>(buffer.Slice(FieldLocations.ATime, FieldLengths.ATime)); 540_aTime = TarHelpers.GetDateTimeOffsetFromSecondsSinceEpoch(aTime); 542long cTime = (long)TarHelpers.ParseOctal<ulong>(buffer.Slice(FieldLocations.CTime, FieldLengths.CTime)); 543_cTime = TarHelpers.GetDateTimeOffsetFromSecondsSinceEpoch(cTime); 552_prefix = TarHelpers.GetTrimmedUtf8String(buffer.Slice(FieldLocations.Prefix, FieldLengths.Prefix)); 622buffer = TarHelpers.TrimEndingNullsAndSpaces(buffer); 681string longPath = TarHelpers.GetTrimmedUtf8String(buffer);
System\Formats\Tar\TarHeader.Write.cs (16)
161TarEntryType actualEntryType = TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.V7, _typeFlag); 171TarEntryType actualEntryType = TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.Ustar, _typeFlag); 427_mode = TarHelpers.GetDefaultMode(entryType), 440tmpChecksum += WriteCommonFields(buffer, TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.Gnu, _typeFlag)); 475_mode = TarHelpers.GetDefaultMode(_typeFlag); 483tmpChecksum += WriteCommonFields(buffer, TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.Pax, _typeFlag)); 624if (_size <= TarHelpers.MaxSizeLength) 636Debug.Assert(Convert.ToInt64(ExtendedAttributes[PaxEaSize]) > TarHelpers.MaxSizeLength); 777int paddingAfterData = TarHelpers.CalculatePadding(_size); 780Debug.Assert(paddingAfterData <= TarHelpers.RecordSize); 782Span<byte> zeros = stackalloc byte[TarHelpers.RecordSize]; 793int paddingAfterData = TarHelpers.CalculatePadding(_size); 796Debug.Assert(paddingAfterData <= TarHelpers.RecordSize); 812int paddingAfterData = TarHelpers.CalculatePadding(_size); 908ExtendedAttributes[PaxEaMTime] = TarHelpers.GetTimestampStringFromDateTimeOffset(_mTime); 919if (_size > TarHelpers.MaxSizeLength)
System\Formats\Tar\TarReader.cs (4)
231TarHelpers.AdvanceStream(_archiveStream, bytesToSkip); 235TarHelpers.SkipBlockAlignmentPadding(_archiveStream, _previouslyReadEntry._header._size); 273await TarHelpers.AdvanceStreamAsync(_archiveStream, bytesToSkip, cancellationToken).ConfigureAwait(false); 277await TarHelpers.SkipBlockAlignmentPaddingAsync(_archiveStream, _previouslyReadEntry._header._size, cancellationToken).ConfigureAwait(false);
System\Formats\Tar\TarWriter.cs (5)
281Span<byte> buffer = stackalloc byte[TarHelpers.RecordSize]; 322byte[] rented = ArrayPool<byte>.Shared.Rent(minimumLength: TarHelpers.RecordSize); 323Memory<byte> buffer = rented.AsMemory(0, TarHelpers.RecordSize); // minimumLength means the array could've been larger 346Span<byte> emptyRecord = stackalloc byte[TarHelpers.RecordSize]; 358const int TwoRecordSize = TarHelpers.RecordSize * 2;
System\Formats\Tar\TarWriter.Unix.cs (4)
65entry._header._mTime = TarHelpers.GetDateTimeOffsetFromSecondsSinceEpoch(status.MTime); 66entry._header._aTime = TarHelpers.GetDateTimeOffsetFromSecondsSinceEpoch(status.ATime); 67entry._header._cTime = TarHelpers.GetDateTimeOffsetFromSecondsSinceEpoch(status.CTime); 70entry._header._mode = status.Mode & (int)TarHelpers.ValidUnixFileModes;