示例#1
0
        private Afs2Archive GetInternalAwbArchive()
        {
            var internalAwbOffset = GetFieldOffset(0, "AwbFile");
            var internalAwb       = new Afs2Archive(Stream, internalAwbOffset.Value, AcbFileName, false);

            internalAwb.Initialize();
            return(internalAwb);
        }
示例#2
0
        private Afs2Archive GetExternalAwbArchive()
        {
            var acbFileName = AcbFileName;
            var awbDirPath  = Path.GetDirectoryName(acbFileName);

            if (awbDirPath == null)
            {
                awbDirPath = string.Empty;
            }

            var awbBaseFileName = Path.GetFileNameWithoutExtension(acbFileName);

            string[] awbFiles = null;
            string   awbMask1 = null, awbMask2 = null, awbMask3 = null;

            if (awbFiles == null || awbFiles.Length < 1)
            {
                awbMask1 = string.Format(AwbFileNameFormats.Format1, awbBaseFileName);
                awbFiles = Directory.GetFiles(awbDirPath, awbMask1, SearchOption.TopDirectoryOnly);
            }

            if (awbFiles == null || awbFiles.Length < 1)
            {
                awbMask2 = string.Format(AwbFileNameFormats.Format2, awbBaseFileName);
                awbFiles = Directory.GetFiles(awbDirPath, awbMask2, SearchOption.TopDirectoryOnly);
            }

            if (awbFiles == null || awbFiles.Length < 1)
            {
                awbMask3 = string.Format(AwbFileNameFormats.Format3, awbBaseFileName);
                awbFiles = Directory.GetFiles(awbDirPath, awbMask3, SearchOption.TopDirectoryOnly);
            }

            if (awbFiles.Length < 1)
            {
                throw new FileNotFoundException($"Cannot find AWB file. Please verify corresponding AWB file is named '{awbMask1}', '{awbMask2}', or '{awbMask3}'.");
            }

            if (awbFiles.Length > 1)
            {
                throw new FileNotFoundException($"More than one matching AWB file for this ACB. Please verify only one AWB file is named '{awbMask1}', '{awbMask2}' or '{awbMask3}'.");
            }

            var externalAwbHash = GetFieldValueAsData(0, "StreamAwbHash");
            var fs      = File.Open(awbFiles[0], FileMode.Open, FileAccess.Read, FileShare.Read);
            var awbHash = AcbHelper.GetMd5Checksum(fs);

            if (!AcbHelper.AreDataIdentical(awbHash, externalAwbHash))
            {
                Trace.WriteLine($"Checksum of AWB file '{fs.Name}' ({BitConverter.ToString(awbHash)}) does not match MD5 checksum inside ACB file '{acbFileName}' ({BitConverter.ToString(externalAwbHash)}).");
            }

            var archive = new Afs2Archive(fs, 0, fs.Name, true);

            archive.Initialize();

            return(archive);
        }
示例#3
0
        private Afs2Archive GetInternalAwbArchive()
        {
            var internalAwbOffset = GetFieldOffset(0, "AwbFile");

            if (internalAwbOffset == null)
            {
                throw new AcbFieldMissingException("AwbFile");
            }
            var internalAwb = new Afs2Archive(Stream, internalAwbOffset.Value, AcbFileName, false);

            internalAwb.Initialize();
            return(internalAwb);
        }