示例#1
0
        /// <summary>
        /// Push all of the data back. Note that LBA should only be applied once, otherwise they'll be wrong!
        /// </summary>
        private void PushDataBack(Dictionary <BuildDirectoryMember, uint> primaryLocationTable,
                                  Dictionary <BuildDirectoryMember, uint> supplementaryLocationTable, List <BuilderExtent> fixedRegions,
                                  long pushFilesBackAmt, int firstRegionIdx, bool applyLBA)
        {
            //Now that we just intruded by shoving the file tables in there, let's push back the files
            Dictionary <BuildDirectoryMember, uint> rebuiltPrimary       = new Dictionary <BuildDirectoryMember, uint>();
            Dictionary <BuildDirectoryMember, uint> rebuiltSupplementary = new Dictionary <BuildDirectoryMember, uint>();

            foreach (KeyValuePair <BuildDirectoryMember, uint> item in primaryLocationTable)
            {
                if (item.Key is BuildFileInfo || applyLBA) //The directory entries are in here too. :-(
                {
                    rebuiltPrimary.Add(item.Key, (uint)(item.Value + (pushFilesBackAmt / IsoUtilities.SectorSize)) + (applyLBA ? _buildParams.LBAoffset : 0));
                }
                else
                {
                    //Don't modify directories, those already have their moved offsets
                    rebuiltPrimary.Add(item.Key, item.Value + (applyLBA?_buildParams.LBAoffset:0));
                }
            }
            primaryLocationTable.Clear();
            foreach (KeyValuePair <BuildDirectoryMember, uint> item in rebuiltPrimary)
            {
                //Can't just do a simple re-assign, because Directory extents have a reference to it
                primaryLocationTable.Add(item.Key, item.Value);
            }
            foreach (KeyValuePair <BuildDirectoryMember, uint> item in supplementaryLocationTable)
            {
                if (item.Key is BuildFileInfo || applyLBA)
                {
                    rebuiltSupplementary.Add(item.Key, (uint)(item.Value + (pushFilesBackAmt / IsoUtilities.SectorSize)) + (applyLBA ? _buildParams.LBAoffset : 0));
                }
                else
                {
                    rebuiltSupplementary.Add(item.Key, item.Value + (applyLBA ? _buildParams.LBAoffset : 0));
                }
            }
            supplementaryLocationTable.Clear();
            foreach (KeyValuePair <BuildDirectoryMember, uint> item in rebuiltSupplementary)
            {
                //Can't just do a simple re-assign, because Directory extents have a reference to it
                supplementaryLocationTable.Add(item.Key, item.Value);
            }

            for (int i = firstRegionIdx; i < fixedRegions.Count; i++)
            {
                BuilderExtent extent = fixedRegions[i];
                extent.Start += pushFilesBackAmt;
            }
        }
示例#2
0
        internal override List <BuilderExtent> FixExtents(out long totalLength)
        {
            List <BuilderExtent> result = new List <BuilderExtent>((_files.Count * 2) + 2);
            long pos = 0;

            foreach (BuildFileRecord file in _files)
            {
                BuilderExtent fileContentExtent = file.Fix(pos + TarHeader.Length);

                result.Add(new TarHeaderExtent(pos, file.Name, fileContentExtent.Length));
                pos += TarHeader.Length;

                result.Add(fileContentExtent);
                pos += Utilities.RoundUp(fileContentExtent.Length, 512);
            }

            // Two empty 512-byte blocks at end of tar file.
            result.Add(new BuilderBufferExtent(pos, new byte[1024]));

            totalLength = pos + 1024;
            return(result);
        }
示例#3
0
        protected override List <BuilderExtent> FixExtents(out long totalLength)
        {
            List <BuilderExtent> result = new List <BuilderExtent>(_files.Count * 2 + 2);
            long pos = 0;

            foreach (UnixBuildFileRecord file in _files)
            {
                BuilderExtent fileContentExtent = file.Fix(pos + TarHeader.Length);

                result.Add(new TarHeaderExtent(
                               pos, file.Name, fileContentExtent.Length, file.FileMode, file.OwnerId, file.GroupId,
                               file.ModificationTime));
                pos += TarHeader.Length;

                result.Add(fileContentExtent);
                pos += MathUtilities.RoundUp(fileContentExtent.Length, 512);
            }

            // Two empty 512-byte blocks at end of tar file.
            result.Add(new BuilderBufferExtent(pos, new byte[1024]));

            totalLength = pos + 1024;
            return(result);
        }