Exemple #1
0
 public IsoTableEntryInfo(int index, int defectiveIndex, long offset, long compressedSize, IsoTableEntryFlags flags)
 {
     Index          = index;
     DefectiveIndex = defectiveIndex;
     Offset         = offset;
     CompressedSize = compressedSize;
     Flags          = flags;
 }
Exemple #2
0
        public static IsoTableEntryInfo TryParse(string filePath)
        {
            string name = Path.GetFileNameWithoutExtension(filePath);

            if (name[0] != 'F' || name[6] != '_')
            {
                return(null);
            }

            int index          = int.Parse(name.Substring(1, 5));
            int defectiveIndex = int.Parse(name.Substring(7, 5));

            bool implicitCompressed  = false;
            IsoTableEntryFlags flags = IsoTableEntryFlags.None;

            for (int i = 12; i < name.Length; i++)
            {
                switch (name[i])
                {
                case 'I':
                    implicitCompressed = true;
                    break;

                case 'C':
                    flags |= IsoTableEntryFlags.Compressed;
                    break;

                case 'D':
                    flags |= IsoTableEntryFlags.Dummy;
                    break;
                }
            }

            FFXFileSignatures signature = 0;
            string            ext       = Path.GetExtension(filePath);

            if (!string.IsNullOrEmpty(ext))
            {
                FFXFileSignatures?tag = EnumCache <FFXFileSignatures> .TryParse(ext.Substring(1));

                if (tag == null)
                {
                    return(null);
                }
                signature = tag.Value;
            }

            return(new IsoTableEntryInfo(index, defectiveIndex, -1, -1, flags)
            {
                IsCompressed = implicitCompressed,
                Signature = signature,
                UncompressedSize = new FileInfo(filePath).Length,
            });
        }