Exemplo n.º 1
0
        protected static int GetFileOffset(TempHeader header, int baseOffset, int partIndex)
        {
            int resultOffset = 0;
            var temp         = header;

            if (partIndex == 4)
            {
                resultOffset = baseOffset + (int)temp.Archive4Sector - 1;
            }
            else if (partIndex == 3)
            {
                resultOffset = baseOffset + (int)temp.Archive3Sector - 1;
            }
            else if (partIndex == 2)
            {
                resultOffset = baseOffset + (int)temp.Archive2Sector - 1;
            }
            else if (partIndex == 1)
            {
                resultOffset = baseOffset + (int)temp.Archive1Sector - 1;
            }
            else if (partIndex == 0)
            {
                resultOffset = baseOffset - 125;
            }
            else
            {
                resultOffset = -1;
            }
            return(resultOffset);
        }
Exemplo n.º 2
0
        protected static TempHeader GetHeader(Bbsa bbsa, string inputFilesFolderPath, string prefix, FileStream[] streams, out uint bbs4Count)
        {
            uint       bbs4Sec    = 0;
            TempHeader tempHeader = new TempHeader(); //Used to count sectors in containers

            for (int i = 0; i < 5; i++)               //Foreach BBS{i} folder/container
            {
                #region Get Container Sector/Index
                uint Sector = 0;
                switch (i)
                {
                case 0:
                    Sector = 125;
                    break;

                default:
                    Sector = 1;
                    break;
                }
                #endregion//Used on Write

                string containerPath = Path.Combine(inputFilesFolderPath, $"{prefix}{i}");

                foreach (var file in bbsa.Files.Where(x => x.ArchiveIndex == i))
                {
                    var    name     = file.CalculateNameWithExtension(x => streams[x]);
                    string filePath = Path.Combine(containerPath, name);

                    var fileinfo = new FileInfo(filePath);
                    Sector += (uint)fileinfo.Length / 0x800;
                }
                bbs4Sec = Sector;
                #region Get Header Offsets
                switch (i)
                {
                case 0:
                    tempHeader.Archive1Sector = (uint)(Sector - 125);
                    //Console.WriteLine($"Arch1: {tempHeader.Archive1Sector}");
                    break;

                case 1:
                    tempHeader.Archive2Sector = (uint)(Sector + tempHeader.Archive1Sector - 2);
                    //Console.WriteLine($"Arch2: {tempHeader.Archive2Sector}");
                    break;

                case 2:
                    tempHeader.Archive3Sector = (uint)(Sector + tempHeader.Archive2Sector - 3);
                    //Console.WriteLine($"Arch3: {tempHeader.Archive3Sector}");
                    break;

                case 3:
                    tempHeader.Archive4Sector = (uint)(Sector + tempHeader.Archive3Sector - 2);
                    //Console.WriteLine($"Arch4: {tempHeader.Archive4Sector}");
                    break;
                }
                #endregion
            }
            bbs4Count = bbs4Sec;
            return(tempHeader);
        }