当前位置: 首页>>代码示例>>C#>>正文


C# TarEntry.WriteEntryHeader方法代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Tar.TarEntry.WriteEntryHeader方法的典型用法代码示例。如果您正苦于以下问题:C# TarEntry.WriteEntryHeader方法的具体用法?C# TarEntry.WriteEntryHeader怎么用?C# TarEntry.WriteEntryHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpZipLib.Tar.TarEntry的用法示例。


在下文中一共展示了TarEntry.WriteEntryHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PutNextEntry

		/// <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;
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:49,代码来源:TarOutputStream.cs

示例2: PutNextEntry

		/// <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;
		}
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:49,代码来源:TarOutputStream.cs

示例3: PutNextEntry

        /// <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;
        }
开发者ID:icsharpcode,项目名称:SharpZipLib,代码行数:50,代码来源:TarOutputStream.cs


注:本文中的ICSharpCode.SharpZipLib.Tar.TarEntry.WriteEntryHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。