public void FixAllChecksums()
        {
            if (ArchiveOpen != 1)
            {
                return;
            }

            CA_Checksums CAChecksum = new CA_Checksums();

            for (int i = 0; i < ArchiveHead1.FileCount; i++)
            {
                ArchiveFiles1[i].ChecksumV1 = CAChecksum.GenerateChecksum(ArchiveFiles1[i].Contents, ArchiveFiles1[i].Size);
            }
        }
        public string GetFileDetails(int index)
        {
            string details = "";

            if (ArchiveOpen == 1)
            {
                details += "Archive Type 1";
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);
                details += "Version " + ArchiveHead1.ArchiveVersion.ToString();
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);
                details += "Compression Level ";
                if (ArchiveHead1.Compression > 0)
                {
                    details += ArchiveHead1.Compression.ToString();
                }
                else
                {
                    details += "N/A";
                }
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "File: " + ArchiveFiles1[index].Name;
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "Size: " + ArchiveFiles1[index].Size.ToString() + " bytes";
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "Database ID: " + ArchiveFiles1[index].dbID.ToString("X8");
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "Var Name: " + HexToStr(HexReverse(ArchiveFiles1[index].VarName.ToString("X8"))).Replace('\0', ' ');
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "Checksum: " + ArchiveFiles1[index].ChecksumV1.ToString("X8");
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "Uknown2: " + ArchiveFiles1[index].Empty.ToString("X8");
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                CA_Checksums CACheckSum = new CA_Checksums();
                uint         cs         = CACheckSum.GenerateChecksum(ArchiveFiles1[index].Contents, ArchiveFiles1[index].Size);


                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);
                details += "Generated Checksum: " + cs.ToString("X8");
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                return(details);
            }
            else if (ArchiveOpen == 2)
            {
                details += "File: " + ArchiveFiles2[index].Name;
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                details += "Size: " + ArchiveFiles2[index].Size.ToString() + " bytes";
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);
                details += Convert.ToChar(0x0d);
                details += Convert.ToChar(0x0a);

                return(details);
            }

            return("");
        }
        public void AddFile(string filePath, string archivePath, uint varName)
        {
            byte[] fileData;
            uint   fileSize;

            if (ArchiveOpen == 0)
            {
                return;
            }

            try { fileData = System.IO.File.ReadAllBytes(filePath); }
            catch { return; }

            fileSize = Convert.ToUInt32(fileData.Length);

            if (ArchiveOpen == 1)
            {
                ArchiveHead1.FileCount++;
                Array.Resize(ref ArchiveFiles1, ArchiveFiles1.Length + 1);

                int fIndex = ArchiveFiles1.Length - 1;

                ArchiveFiles1[fIndex].FullPath = archivePath.Replace("z:/", "");
                ArchiveFiles1[fIndex].FullPath = ArchiveFiles1[fIndex].FullPath.Replace("/", "\\");

                string spTmp = ArchiveFiles1[fIndex].FullPath + "/";
                spTmp = spTmp.Replace('\\', '/');
                spTmp = spTmp.Replace("//", "/");
                string[] sp = spTmp.Split('/');
                ArchiveFiles1[fIndex].Name = sp[sp.Length - 2];

                CA_Checksums CAChecksum = new CA_Checksums();

                ArchiveFiles1[fIndex].VarName    = varName;
                ArchiveFiles1[fIndex].dbID       = 0;
                ArchiveFiles1[fIndex].Entry      = 0;
                ArchiveFiles1[fIndex].Size       = fileSize;
                ArchiveFiles1[fIndex].ChecksumV1 = CAChecksum.GenerateChecksum(fileData, fileSize);
                ArchiveFiles1[fIndex].Empty      = 0;

                ArchiveFiles1[fIndex].Contents = new byte[fileSize];
                for (int i = 0; i < fileSize; i++)
                {
                    ArchiveFiles1[fIndex].Contents[i] = fileData[i];
                }

                BuildDirectoryListings();
            }
            else if (ArchiveOpen == 2)
            {
                ArchiveHead2.FileCount++;
                Array.Resize(ref ArchiveFiles2, ArchiveFiles2.Length + 1);

                int fIndex = ArchiveFiles2.Length - 1;

                ArchiveFiles2[fIndex].FullPath = archivePath;
                ArchiveFiles2[fIndex].FullPath = archivePath.Replace("z:/", "");
                ArchiveFiles2[fIndex].FullPath = ArchiveFiles2[fIndex].FullPath.Replace("/", "\\");

                string spTmp = ArchiveFiles2[fIndex].FullPath + "/";
                spTmp = spTmp.Replace('\\', '/');
                spTmp = spTmp.Replace("//", "/");
                string[] sp = spTmp.Split('/');
                ArchiveFiles2[fIndex].Name = sp[sp.Length - 2];

                ArchiveFiles2[fIndex].Entry = 0;
                ArchiveFiles2[fIndex].Size  = fileSize;

                ArchiveFiles2[fIndex].Contents = new byte[fileSize];
                for (int i = 0; i < fileSize; i++)
                {
                    ArchiveFiles2[fIndex].Contents[i] = fileData[i];
                }

                BuildDirectoryListings();
            }
        }