Exemple #1
0
        /// <summary>
        /// Write an entry to the archive. This method will call the putNextEntry
        /// and then write the contents of the entry, and finally call closeEntry()
        /// for entries that are files. For directories, it will call putNextEntry(),
        /// and then, if the recurse flag is true, process each entry that is a
        /// child of the directory.
        /// </summary>
        /// <param name="sourceEntry">
        /// The TarEntry representing the entry to write to the archive.
        /// </param>
        /// <param name="recurse">
        /// If true, process the children of directory entries.
        /// </param>
        public void WriteEntry(TarEntry sourceEntry, bool recurse)
        {
            if (sourceEntry == null)
            {
                throw new ArgumentNullException(nameof(sourceEntry));
            }

            if (isDisposed)
            {
                throw new ObjectDisposedException("TarArchive");
            }

            try {
                if (recurse)
                {
                    TarHeader.SetValueDefaults(sourceEntry.UserId, sourceEntry.UserName,
                                               sourceEntry.GroupId, sourceEntry.GroupName);
                }
                WriteEntryCore(sourceEntry, recurse);
            } finally {
                if (recurse)
                {
                    TarHeader.RestoreSetValues();
                }
            }
        }