WriteHeader() public method

'Write' header information to buffer provided, updating the check sum.
public WriteHeader ( byte outBuffer ) : void
outBuffer byte output buffer for header information
return void
コード例 #1
0
        /// <summary>
        /// Put an entry on the output stream. This writes the entry's
        /// header and positions the output stream for writing
        /// the contents of the entry. Once this method is called, the
        /// stream is ready for calls to write() to write the entry's
        /// contents. Once the contents are written, closeEntry()
        /// <B>MUST</B> be called to ensure that all buffered data
        /// is completely written to the output stream.
        /// </summary>
        /// <param name="entry">
        /// The TarEntry to be written to the archive.
        /// </param>
        public void PutNextEntry(TarEntry entry)
        {
            if (entry.TarHeader.name.Length > TarHeader.NAMELEN)
            {
                TarHeader longHeader = new TarHeader();
                longHeader.typeFlag = TarHeader.LF_GNU_LONGNAME;
                longHeader.name.Append("././@LongLink");
                longHeader.userId           = 0;
                longHeader.groupId          = 0;
                longHeader.groupName.Length = 0;
                longHeader.userName.Length  = 0;
                longHeader.linkName.Length  = 0;

                longHeader.size = entry.TarHeader.name.Length;

                longHeader.WriteHeader(this.blockBuf);
                this.buffer.WriteBlock(this.blockBuf);                  // Add special long filename header block

                int nameCharIndex = 0;

                while (nameCharIndex < entry.TarHeader.name.Length)
                {
                    TarHeader.GetNameBytes(entry.TarHeader.name, nameCharIndex, this.blockBuf, 0, TarBuffer.BlockSize);
                    nameCharIndex += TarBuffer.BlockSize;
                    this.buffer.WriteBlock(this.blockBuf);
                }
            }

            entry.WriteEntryHeader(this.blockBuf);
            this.buffer.WriteBlock(this.blockBuf);

            this.currBytes = 0;

            this.currSize = entry.IsDirectory ? 0 : entry.Size;
        }
コード例 #2
0
 public void PutNextEntry(TarEntry entry)
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     if (entry.TarHeader.Name.Length >= 100)
     {
         TarHeader header = new TarHeader {
             TypeFlag = 0x4c
         };
         header.Name      = header.Name + "././@LongLink";
         header.UserId    = 0;
         header.GroupId   = 0;
         header.GroupName = "";
         header.UserName  = "";
         header.LinkName  = "";
         header.Size      = entry.TarHeader.Name.Length + 1;
         header.WriteHeader(this.blockBuffer);
         this.buffer.WriteBlock(this.blockBuffer);
         int nameOffset = 0;
         while (nameOffset < entry.TarHeader.Name.Length)
         {
             Array.Clear(this.blockBuffer, 0, this.blockBuffer.Length);
             TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameOffset, this.blockBuffer, 0, 0x200);
             nameOffset += 0x200;
             this.buffer.WriteBlock(this.blockBuffer);
         }
     }
     entry.WriteEntryHeader(this.blockBuffer);
     this.buffer.WriteBlock(this.blockBuffer);
     this.currBytes = 0L;
     this.currSize  = entry.IsDirectory ? 0L : entry.Size;
 }
コード例 #3
0
 public void PutNextEntry(TarEntry entry)
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     if (entry.TarHeader.Name.Length > 100)
     {
         TarHeader tarHeader = new TarHeader();
         tarHeader.TypeFlag  = 76;
         tarHeader.Name     += "././@LongLink";
         tarHeader.Mode      = 420;
         tarHeader.UserId    = entry.UserId;
         tarHeader.GroupId   = entry.GroupId;
         tarHeader.GroupName = entry.GroupName;
         tarHeader.UserName  = entry.UserName;
         tarHeader.LinkName  = string.Empty;
         tarHeader.Size      = (long)(entry.TarHeader.Name.Length + 1);
         tarHeader.WriteHeader(this.blockBuffer);
         this.buffer.WriteBlock(this.blockBuffer);
         int i = 0;
         while (i < entry.TarHeader.Name.Length + 1)
         {
             Array.Clear(this.blockBuffer, 0, this.blockBuffer.Length);
             TarHeader.GetAsciiBytes(entry.TarHeader.Name, i, this.blockBuffer, 0, 512);
             i += 512;
             this.buffer.WriteBlock(this.blockBuffer);
         }
     }
     entry.WriteEntryHeader(this.blockBuffer);
     this.buffer.WriteBlock(this.blockBuffer);
     this.currBytes = 0L;
     this.currSize  = ((!entry.IsDirectory) ? entry.Size : 0L);
 }
コード例 #4
0
 public void PutNextEntry(TarEntry entry)
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     if (entry.TarHeader.Name.Length >= 100)
     {
         TarHeader tarHeader = new TarHeader();
         tarHeader.TypeFlag  = 76;
         tarHeader.Name     += "././@LongLink";
         tarHeader.UserId    = 0;
         tarHeader.GroupId   = 0;
         tarHeader.GroupName = "";
         tarHeader.UserName  = "";
         tarHeader.LinkName  = "";
         tarHeader.Size      = entry.TarHeader.Name.Length;
         tarHeader.WriteHeader(blockBuffer);
         buffer.WriteBlock(blockBuffer);
         int num = 0;
         while (num < entry.TarHeader.Name.Length)
         {
             Array.Clear(blockBuffer, 0, blockBuffer.Length);
             TarHeader.GetAsciiBytes(entry.TarHeader.Name, num, blockBuffer, 0, 512);
             num += 512;
             buffer.WriteBlock(blockBuffer);
         }
     }
     entry.WriteEntryHeader(blockBuffer);
     buffer.WriteBlock(blockBuffer);
     currBytes = 0L;
     currSize  = (entry.IsDirectory ? 0 : entry.Size);
 }
コード例 #5
0
 public void PutNextEntry(TarEntry entry)
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     if (entry.TarHeader.Name.get_Length() >= 100)
     {
         TarHeader tarHeader = new TarHeader();
         tarHeader.TypeFlag  = 76;
         tarHeader.Name     += "././@LongLink";
         tarHeader.UserId    = 0;
         tarHeader.GroupId   = 0;
         tarHeader.GroupName = "";
         tarHeader.UserName  = "";
         tarHeader.LinkName  = "";
         tarHeader.Size      = entry.TarHeader.Name.get_Length();
         tarHeader.WriteHeader(blockBuffer);
         buffer.WriteBlock(blockBuffer);
         int num = 0;
         while (num < entry.TarHeader.Name.get_Length())
         {
             global::System.Array.Clear((global::System.Array)blockBuffer, 0, blockBuffer.Length);
             TarHeader.GetAsciiBytes(entry.TarHeader.Name, num, blockBuffer, 0, 512);
             num += 512;
             buffer.WriteBlock(blockBuffer);
         }
     }
     entry.WriteEntryHeader(blockBuffer);
     buffer.WriteBlock(blockBuffer);
     currBytes = 0L;
     currSize  = (entry.IsDirectory ? 0 : entry.Size);
 }
コード例 #6
0
        /// <summary>
        /// Put an entry on the output stream. This writes the entry's
        /// header and positions the output stream for writing
        /// the contents of the entry. Once this method is called, the
        /// stream is ready for calls to write() to write the entry's
        /// contents. Once the contents are written, closeEntry()
        /// <B>MUST</B> be called to ensure that all buffered data
        /// is completely written to the output stream.
        /// </summary>
        /// <param name="entry">
        /// The TarEntry to be written to the archive.
        /// </param>
        public void PutNextEntry(TarEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            var namelen = nameEncoding != null?nameEncoding.GetByteCount(entry.TarHeader.Name) : entry.TarHeader.Name.Length;

            if (namelen > TarHeader.NAMELEN)
            {
                var longHeader = new TarHeader();
                longHeader.TypeFlag  = TarHeader.LF_GNU_LONGNAME;
                longHeader.Name      = longHeader.Name + "././@LongLink";
                longHeader.Mode      = 420;           //644 by default
                longHeader.UserId    = entry.UserId;
                longHeader.GroupId   = entry.GroupId;
                longHeader.GroupName = entry.GroupName;
                longHeader.UserName  = entry.UserName;
                longHeader.LinkName  = "";
                longHeader.Size      = namelen + 1;             // Plus one to avoid dropping last char

                longHeader.WriteHeader(blockBuffer, nameEncoding);
                buffer.WriteBlock(blockBuffer);                  // Add special long filename header block

                int nameCharIndex = 0;

                while (nameCharIndex < namelen + 1 /* we've allocated one for the null char, now we must make sure it gets written out */)
                {
                    Array.Clear(blockBuffer, 0, blockBuffer.Length);
                    TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize, nameEncoding);                     // This func handles OK the extra char out of string length
                    nameCharIndex += TarBuffer.BlockSize;
                    buffer.WriteBlock(blockBuffer);
                }
            }

            entry.WriteEntryHeader(blockBuffer, nameEncoding);
            buffer.WriteBlock(blockBuffer);

            currBytes = 0;

            currSize = entry.IsDirectory ? 0 : entry.Size;
        }
コード例 #7
0
        /// <summary>
        /// Put an entry on the output stream. This writes the entry's
        /// header and positions the output stream for writing
        /// the contents of the entry. Once this method is called, the
        /// stream is ready for calls to write() to write the entry's
        /// contents. Once the contents are written, closeEntry()
        /// <B>MUST</B> be called to ensure that all buffered data
        /// is completely written to the output stream.
        /// </summary>
        /// <param name="entry">
        /// The TarEntry to be written to the archive.
        /// </param>
        public void PutNextEntry(TarEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            if (entry.TarHeader.Name.Length >= TarHeader.NAMELEN)
            {
                TarHeader longHeader = new TarHeader();
                longHeader.TypeFlag  = TarHeader.LF_GNU_LONGNAME;
                longHeader.Name      = longHeader.Name + "././@LongLink";
                longHeader.UserId    = 0;
                longHeader.GroupId   = 0;
                longHeader.GroupName = "";
                longHeader.UserName  = "";
                longHeader.LinkName  = "";

                longHeader.Size = entry.TarHeader.Name.Length;

                longHeader.WriteHeader(this.blockBuffer);
                this.buffer.WriteBlock(this.blockBuffer);                  // Add special long filename header block

                int nameCharIndex = 0;

                while (nameCharIndex < entry.TarHeader.Name.Length)
                {
                    Array.Clear(blockBuffer, 0, blockBuffer.Length);
                    TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize);
                    nameCharIndex += TarBuffer.BlockSize;
                    buffer.WriteBlock(blockBuffer);
                }
            }

            entry.WriteEntryHeader(blockBuffer);
            buffer.WriteBlock(blockBuffer);

            currBytes = 0;

            currSize = entry.IsDirectory ? 0 : entry.Size;
        }
コード例 #8
0
        /// <summary>
        /// Put an entry on the output stream. This writes the entry's
        /// header and positions the output stream for writing
        /// the contents of the entry. Once this method is called, the
        /// stream is ready for calls to write() to write the entry's
        /// contents. Once the contents are written, closeEntry()
        /// <B>MUST</B> be called to ensure that all buffered data
        /// is completely written to the output stream.
        /// </summary>
        /// <param name="entry">
        /// The TarEntry to be written to the archive.
        /// </param>
        public void PutNextEntry(TarEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            if (entry.TarHeader.Name.Length > TarHeader.NAMELEN)
            {
                var longHeader = new TarHeader();
                longHeader.TypeFlag  = TarHeader.LF_GNU_LONGNAME;
                longHeader.Name      = longHeader.Name + "././@LongLink";
                longHeader.Mode      = 420;           //644 by default
                longHeader.UserId    = entry.UserId;
                longHeader.GroupId   = entry.GroupId;
                longHeader.GroupName = entry.GroupName;
                longHeader.UserName  = entry.UserName;
                longHeader.LinkName  = "";
                longHeader.Size      = entry.TarHeader.Name.Length + 1;             // Plus one to avoid dropping last char

                longHeader.WriteHeader(blockBuffer);
                buffer.WriteBlock(blockBuffer);                  // Add special long filename header block

                int nameCharIndex = 0;

                while (nameCharIndex < entry.TarHeader.Name.Length)
                {
                    Array.Clear(blockBuffer, 0, blockBuffer.Length);
                    TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize);
                    nameCharIndex += TarBuffer.BlockSize;
                    buffer.WriteBlock(blockBuffer);
                }
            }

            entry.WriteEntryHeader(blockBuffer);
            buffer.WriteBlock(blockBuffer);

            currBytes = 0;

            currSize = entry.IsDirectory ? 0 : entry.Size;
        }
コード例 #9
0
ファイル: TarEntry.cs プロジェクト: Bectinced-aeN/vrcsdk
 public void WriteEntryHeader(byte[] outBuffer)
 {
     header.WriteHeader(outBuffer);
 }
コード例 #10
0
		/// <summary>
		/// Put an entry on the output stream. This writes the entry's
		/// header and positions the output stream for writing
		/// the contents of the entry. Once this method is called, the
		/// stream is ready for calls to write() to write the entry's
		/// contents. Once the contents are written, closeEntry()
		/// <B>MUST</B> be called to ensure that all buffered data
		/// is completely written to the output stream.
		/// </summary>
		/// <param name="entry">
		/// The TarEntry to be written to the archive.
		/// </param>
		public void PutNextEntry(TarEntry entry)
		{
			if ( entry == null ) {
				throw new ArgumentNullException("entry");
			}

			if (entry.TarHeader.Name.Length >= TarHeader.NAMELEN) {
				TarHeader longHeader = new TarHeader();
				longHeader.TypeFlag = TarHeader.LF_GNU_LONGNAME;
				longHeader.Name = longHeader.Name + "././@LongLink";
				longHeader.UserId = 0;
				longHeader.GroupId = 0;
				longHeader.GroupName = "";
				longHeader.UserName = "";
				longHeader.LinkName = "";
                longHeader.Size = entry.TarHeader.Name.Length;

				longHeader.WriteHeader(blockBuffer);
				buffer.WriteBlock(blockBuffer);  // Add special long filename header block

				int nameCharIndex = 0;

				while (nameCharIndex < entry.TarHeader.Name.Length) {
					Array.Clear(blockBuffer, 0, blockBuffer.Length);
					TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize);
					nameCharIndex += TarBuffer.BlockSize;
					buffer.WriteBlock(blockBuffer);
				}
			}
			
			entry.WriteEntryHeader(blockBuffer);
			buffer.WriteBlock(blockBuffer);
			
			currBytes = 0;
			
			currSize = entry.IsDirectory ? 0 : entry.Size;
		}
コード例 #11
0
ファイル: TarOutputStream.cs プロジェクト: jack-pappas/mono
		/// <summary>
		/// Put an entry on the output stream. This writes the entry's
		/// header and positions the output stream for writing
		/// the contents of the entry. Once this method is called, the
		/// stream is ready for calls to write() to write the entry's
		/// contents. Once the contents are written, closeEntry()
		/// <B>MUST</B> be called to ensure that all buffered data
		/// is completely written to the output stream.
		/// </summary>
		/// <param name="entry">
		/// The TarEntry to be written to the archive.
		/// </param>
		public void PutNextEntry(TarEntry entry)
		{
			if (entry.TarHeader.name.Length > TarHeader.NAMELEN) 
			{
            TarHeader longHeader = new TarHeader();
            longHeader.typeFlag = TarHeader.LF_GNU_LONGNAME;
            longHeader.name.Append("././@LongLink");
            longHeader.userId = 0;
            longHeader.groupId = 0;
            longHeader.groupName.Length = 0;
            longHeader.userName.Length = 0;
            longHeader.linkName.Length = 0;

            longHeader.size = entry.TarHeader.name.Length;

            Console.WriteLine("TarOutputStream: PutNext entry Long name found size = " + longHeader.size); // DEBUG

            longHeader.WriteHeader(this.blockBuf);
            this.buffer.WriteBlock(this.blockBuf);  // Add special long filename header block

            int nameCharIndex = 0;

            while (nameCharIndex < entry.TarHeader.name.Length)
            {
         		TarHeader.GetNameBytes(entry.TarHeader.name, nameCharIndex, this.blockBuf, 0, TarBuffer.BlockSize);
               nameCharIndex += TarBuffer.BlockSize;
               this.buffer.WriteBlock(this.blockBuf);
            }
			}
			
			entry.WriteEntryHeader(this.blockBuf);
			this.buffer.WriteBlock(this.blockBuf);
			
			this.currBytes = 0;
			
			this.currSize = entry.IsDirectory ? 0 : (int)entry.Size;
		}
コード例 #12
0
 /// <summary>
 /// Write an entry's header information to a header buffer.
 /// </summary>
 /// <param name = "outbuf">
 /// The tar entry header buffer to fill in.
 /// </param>
 public void WriteEntryHeader(byte[] outbuf)
 {
     header.WriteHeader(outbuf);
 }
コード例 #13
0
        /// <summary>
        /// Put an entry on the output stream. This writes the entry's
        /// header and positions the output stream for writing
        /// the contents of the entry. Once this method is called, the
        /// stream is ready for calls to write() to write the entry's
        /// contents. Once the contents are written, closeEntry()
        /// <B>MUST</B> be called to ensure that all buffered data
        /// is completely written to the output stream.
        /// </summary>
        /// <param name="entry">
        /// The TarEntry to be written to the archive.
        /// </param>
        public void PutNextEntry(TarEntry entry)
        {
            if (entry == null) {
                throw new ArgumentNullException(nameof(entry));
            }

            if (entry.TarHeader.Name.Length > TarHeader.NAMELEN) {
                var longHeader = new TarHeader();
                longHeader.TypeFlag = TarHeader.LF_GNU_LONGNAME;
                longHeader.Name = longHeader.Name + "././@LongLink";
                longHeader.Mode = 420;//644 by default
                longHeader.UserId = entry.UserId;
                longHeader.GroupId = entry.GroupId;
                longHeader.GroupName = entry.GroupName;
                longHeader.UserName = entry.UserName;
                longHeader.LinkName = "";
                longHeader.Size = entry.TarHeader.Name.Length + 1;  // Plus one to avoid dropping last char

                longHeader.WriteHeader(blockBuffer);
                buffer.WriteBlock(blockBuffer);  // Add special long filename header block

                int nameCharIndex = 0;

                while (nameCharIndex < entry.TarHeader.Name.Length + 1 /* we've allocated one for the null char, now we must make sure it gets written out */) {
                    Array.Clear(blockBuffer, 0, blockBuffer.Length);
                    TarHeader.GetAsciiBytes(entry.TarHeader.Name, nameCharIndex, this.blockBuffer, 0, TarBuffer.BlockSize); // This func handles OK the extra char out of string length
                    nameCharIndex += TarBuffer.BlockSize;
                    buffer.WriteBlock(blockBuffer);
                }
            }

            entry.WriteEntryHeader(blockBuffer);
            buffer.WriteBlock(blockBuffer);

            currBytes = 0;

            currSize = entry.IsDirectory ? 0 : entry.Size;
        }