Esempio n. 1
0
        internal override void ReadData(AwesomeReader ar)
        {
            Entries.Clear();

            Version = ar.ReadInt32();
            int count = ar.ReadInt32();

            ar.BaseStream.Position += 4; // Should be 4

            for (int i = 0; i < count; i++)
            {
                Index2Entry entry = new Index2Entry();

                // 24 bytes
                entry.FilePath = ar.ReadUInt64();
                entry.Type     = ar.ReadUInt64();
                int stringCount = ar.ReadInt32(); // Usually 1 for most entries

                entry.PackageEntries = new List <Index2PackageEntry>();

                // Jumps to packages/external paths entries
                long stringOffset     = (ar.ReadInt32() - 4) + ar.BaseStream.Position;
                long previousPosition = ar.BaseStream.Position;

                for (int ii = 0; ii < stringCount; ii++)
                {
                    // 248 bytes
                    ar.BaseStream.Position = stringOffset;

                    // Reads string + null-terminated string
                    Index2PackageEntry pack = new Index2PackageEntry();
                    pack.Package          = ar.ReadUInt64();
                    pack.ExternalFilePath = ar.ReadNullString();
                    entry.PackageEntries.Add(pack);

                    stringOffset += 248;
                }

                // Returns to next entry
                ar.BaseStream.Position = previousPosition;

                // Adds to entries
                Entries.Add(entry);
            }
        }
Esempio n. 2
0
        public void UpdateIndexEntryAsPending(HKey filePath, HKey type, string physicalPath, HKey packageFilePath)
        {
            Index2Entry indexEntry = Index.Entries.FirstOrDefault(x => x.FilePath == filePath);

            if (indexEntry == null)
            {
                // Creates new entry
                indexEntry = new Index2Entry()
                {
                    FilePath = filePath,
                    Type     = type
                };

                Index.Entries.Add(indexEntry);
            }

            Index2PackageEntry packageEntry = indexEntry.PackageEntries.FirstOrDefault(x => x.Package == packageFilePath);

            if (packageEntry == null)
            {
                // Creates new entry
                packageEntry = new Index2PackageEntry()
                {
                    Package          = packageFilePath,
                    ExternalFilePath = physicalPath
                };

                // Inserts at the front
                indexEntry.PackageEntries.Insert(0, packageEntry);
            }
            else
            {
                // Updates external file path
                packageEntry.ExternalFilePath = physicalPath;
            }
        }
Esempio n. 3
0
        private ZObject GetZObject(Index2Entry entry)
        {
            if (entry == null || !entry.IsZObject())
            {
                return(null);
            }

            foreach (Index2PackageEntry pkEntry in entry.PackageEntries)
            {
                if (!_packagePaths.ContainsKey(pkEntry.Package))
                {
                    continue;
                }
                string filePath = Path.Combine(_packagePaths[pkEntry.Package], pkEntry.ExternalFilePath);

                // Checks if cached
                if (_tempObjectsPackageEntry != null &&
                    _tempObjectsPackageEntry.ExternalFilePath == pkEntry.ExternalFilePath &&
                    _tempObjectsPackageEntry.Package == pkEntry.Package)
                {
                    return(_tempObjects.SingleOrDefault(x => x.FilePath == entry.FilePath));
                }

                // Checks if file exists
                if (!File.Exists(filePath))
                {
                    continue;
                }
                if (LoadRiffFile(filePath, pkEntry))
                {
                    return(_tempObjects.SingleOrDefault(x => x.FilePath == entry.FilePath));
                }
            }

            return(null);
        }