Beispiel #1
0
        /// <summary>
        ///     Writes a tar header for a file entry to the output stream.
        /// </summary>
        /// <param name="path">The path to the file in the archive.</param>
        /// <param name="size">The size of the file.</param>
        /// <param name="lastModification">The last modification date in UTC of the file.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="groupId">The group identifier.</param>
        /// <param name="fileMode">The file mode.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="path" /> is null.</exception>
        public void WriteFileEntry(string path, long size, DateTime lastModification, string userId, string groupId, IFileModeGroup fileMode)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            AssertNotDisposed();

            path = PathHelper.TarNormalize(path);

            if (path.Length >= 100)
            {
                WriteLongNameEntry(path);

                // NOTE: GNU tar puts 100 characters into the name field, without
                // the null terminator. However, the GNU tar specifications state
                // the name should end with a null terminator. Sticking to the
                // specifications here.
                path = path.Substring(0, 99);
            }

            var header = new TarHeader
            {
                Name             = path,
                Mode             = fileMode,
                Size             = size,
                Flag             = TarHeaderFlag.NormalFileAlt,
                UserId           = userId,
                GroupId          = groupId,
                LastModification = lastModification
            };

            WriteHeader(header);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ReadOnlyFileModeGroup" /> class.
 /// </summary>
 /// <param name="fileModeGroup">The underlying file mode group.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="fileModeGroup" /> is null.</exception>
 public ReadOnlyFileModeGroup(IFileModeGroup fileModeGroup)
 {
     _fileModeGroup = fileModeGroup ?? throw new ArgumentNullException(nameof(fileModeGroup));
 }