Esempio n. 1
0
        public void AddScheme(string filePath, string fileName)
        {
            FileScheme scheme = GameCollection.LoadScheme(filePath, fileName);

            OnSchemeLoaded(scheme);
            m_schemes.Add(scheme);
        }
Esempio n. 2
0
            private bool LoadDependencies(FileScheme scheme)
            {
                bool loaded = true;

#warning TODO: fetch unresolved (external) dependencies
                foreach (FileIdentifier dependency in scheme.Dependencies)
                {
                    if (m_loadedFiles.Contains(dependency.FilePath))
                    {
                        continue;
                    }

                    string fileSystemPath = m_dependencyCallback.Invoke(dependency.FilePath);
                    if (fileSystemPath == null)
                    {
                        if (m_knownFiles.Add(dependency.FilePath))
                        {
                            Logger.Log(LogType.Warning, LogCategory.Import, $"Dependency '{dependency}' hasn't been found");
                        }
                        loaded = false;
                    }
                    else
                    {
                        ProcessFile(dependency.FilePath, fileSystemPath);
                    }
                }
                return(loaded);
            }
Esempio n. 3
0
 private void ProcessEntries()
 {
     foreach (WebFileEntry entry in Metadata.Entries.Values)
     {
         FileScheme scheme = GameCollection.ReadScheme(m_stream, entry.Offset, entry.Size, FilePath, entry.NameOrigin);
         AddScheme(scheme);
     }
 }
Esempio n. 4
0
 private void ProcessEntries()
 {
     foreach (BundleFileEntry entry in Metadata.Entries.Values)
     {
         FileEntryOffset offset = m_entryStreams[entry];
         FileScheme      scheme = GameCollection.ReadScheme(offset.Stream, offset.Offset, entry.Size, FilePath, entry.NameOrigin);
         AddScheme(scheme);
     }
 }
Esempio n. 5
0
 private void ReadPre530Data(Stream stream, long metadataOffset)
 {
     foreach (BundleFileEntry entry in Metadata.Entries)
     {
         byte[] buffer = new byte[entry.Size];
         stream.Position = metadataOffset + entry.Offset;
         stream.ReadBuffer(buffer, 0, buffer.Length);
         FileScheme scheme = GameCollection.ReadScheme(buffer, FilePath, entry.NameOrigin);
         AddScheme(scheme);
     }
 }
 private void ReadRawWebData(Stream stream, long metadataOffset)
 {
     foreach (Node entry in Metadata.DirectoryInfo.Nodes)
     {
         byte[] buffer = new byte[entry.Size];
         stream.Position = metadataOffset + entry.Offset;
         stream.ReadBuffer(buffer, 0, buffer.Length);
         FileScheme scheme = GameCollection.ReadScheme(buffer, FilePath, entry.PathOrigin);
         AddScheme(scheme);
     }
 }
Esempio n. 7
0
        internal void AddFile(FileScheme scheme, IFileCollection collection, IAssemblyManager manager)
        {
            switch (scheme.SchemeType)
            {
            case FileEntryType.Serialized:
            {
                SerializedFileScheme serializedScheme = (SerializedFileScheme)scheme;
                SerializedFile       file             = serializedScheme.ReadFile(collection, manager);
                m_serializedFiles.Add(file);
                OnSerializedFileAdded(file);
            }
            break;

            case FileEntryType.Bundle:
            {
                BundleFileScheme bundleScheme = (BundleFileScheme)scheme;
                BundleFile       bundle       = bundleScheme.ReadFile(collection, manager);
                m_fileLists.Add(bundle);
                OnFileListAdded(bundle);
            }
            break;

            case FileEntryType.Archive:
            {
                ArchiveFileScheme archiveScheme = (ArchiveFileScheme)scheme;
                ArchiveFile       archive       = archiveScheme.ReadFile(collection, manager);
                m_fileLists.Add(archive);
                OnFileListAdded(archive);
            }
            break;

            case FileEntryType.Web:
            {
                WebFileScheme webScheme = (WebFileScheme)scheme;
                WebFile       webFile   = webScheme.ReadFile(collection, manager);
                m_fileLists.Add(webFile);
                OnFileListAdded(webFile);
            }
            break;

            case FileEntryType.Resource:
            {
                ResourceFileScheme resourceScheme = (ResourceFileScheme)scheme;
                ResourceFile       resource       = resourceScheme.ReadFile();
                m_resourceFiles.Add(resource);
                OnResourceFileAdded(resource);
            }
            break;

            default:
                throw new NotSupportedException(scheme.SchemeType.ToString());
            }
        }
Esempio n. 8
0
            private void OnSchemeLoaded(FileScheme scheme)
            {
                m_loadedFiles.Add(scheme.Name);
                m_knownFiles.Add(scheme.Name);

                if (scheme is FileSchemeList list)
                {
                    foreach (FileScheme nestedScheme in list.Schemes)
                    {
                        OnSchemeLoaded(nestedScheme);
                    }
                }
            }
Esempio n. 9
0
        private void OnSchemeLoaded(FileScheme scheme)
        {
            if (scheme.SchemeType == FileEntryType.Serialized)
            {
                m_knownFiles.Add(scheme.Name);
            }

            if (scheme is FileSchemeList list)
            {
                foreach (FileScheme nestedScheme in list.Schemes)
                {
                    OnSchemeLoaded(nestedScheme);
                }
            }
        }
Esempio n. 10
0
        internal void AddFile(GameProcessorContext context, FileScheme scheme)
        {
            switch (scheme.SchemeType)
            {
            case FileEntryType.Serialized:
            {
                SerializedFileScheme serializedScheme = (SerializedFileScheme)scheme;
                SerializedFile       file             = serializedScheme.ReadFile(context);
                AddSerializedFile(file);
            }
            break;

            case FileEntryType.Bundle:
            {
                BundleFileScheme bundleScheme = (BundleFileScheme)scheme;
                BundleFile       bundle       = bundleScheme.ReadFile(context);
                AddFileList(bundle);
            }
            break;

            case FileEntryType.Archive:
            {
                ArchiveFileScheme archiveScheme = (ArchiveFileScheme)scheme;
                ArchiveFile       archive       = archiveScheme.ReadFile(context);
                AddFileList(archive);
            }
            break;

            case FileEntryType.Web:
            {
                WebFileScheme webScheme = (WebFileScheme)scheme;
                WebFile       webFile   = webScheme.ReadFile(context);
                AddFileList(webFile);
            }
            break;

            case FileEntryType.Resource:
            {
                ResourceFileScheme resourceScheme = (ResourceFileScheme)scheme;
                ResourceFile       resource       = resourceScheme.ReadFile();
                AddResourceFile(resource);
            }
            break;

            default:
                throw new NotSupportedException(scheme.SchemeType.ToString());
            }
        }
Esempio n. 11
0
        private void Read530Data(Stream stream, long headerSize)
        {
            if (Header.Flags.IsMetadataAtTheEnd())
            {
                stream.Position = headerSize;
            }

            using (BundleFileBlockReader blockReader = new BundleFileBlockReader(stream, Metadata))
            {
                foreach (BundleFileEntry entry in Metadata.Entries)
                {
                    SmartStream entryStream = blockReader.ReadEntry(entry);
                    FileScheme  scheme      = GameCollection.ReadScheme(entryStream, FilePath, entry.NameOrigin);
                    AddScheme(scheme);
                }
            }
        }
Esempio n. 12
0
        private void ReadScheme(Stream stream)
        {
            using (EndianReader reader = new EndianReader(stream, EndianType.LittleEndian))
            {
                Header.Read(reader);
                Metadata.Read(reader);
            }

            foreach (WebFileEntry entry in Metadata.Entries)
            {
                byte[] buffer = new byte[entry.Size];
                stream.Position = entry.Offset;
                stream.ReadBuffer(buffer, 0, buffer.Length);
                FileScheme scheme = GameCollection.ReadScheme(buffer, FilePath, entry.NameOrigin);
                AddScheme(scheme);
            }
        }
        private void ReadFileStreamData(Stream stream, long basePosition, long headerSize)
        {
            if (Header.FileStream.Flags.IsBlocksInfoAtTheEnd())
            {
                stream.Position = basePosition + headerSize;
            }

            using (BundleFileBlockReader blockReader = new BundleFileBlockReader(stream, Metadata.BlocksInfo))
            {
                foreach (Node entry in Metadata.DirectoryInfo.Nodes)
                {
                    SmartStream entryStream = blockReader.ReadEntry(entry);
                    FileScheme  scheme      = GameCollection.ReadScheme(entryStream, FilePath, entry.PathOrigin);
                    AddScheme(scheme);
                }
            }
        }
Esempio n. 14
0
			public void ProcessFile(string fileName, string filePath)
			{
				if (m_loadedFiles.Contains(fileName))
				{
					return;
				}

				FileScheme scheme = GameCollection.LoadScheme(filePath, fileName);
				OnSchemeLoaded(scheme);

				if (LoadDependencies(scheme))
				{
					m_fileCollection.AddFile(scheme, m_fileCollection, m_fileCollection.AssemblyManager);
					scheme.Dispose();
				}
				else
				{
					m_delayedSchemes.Add(fileName, scheme);
				}
			}
Esempio n. 15
0
        public void AddDependencySchemes(Func <string, string> dependencyCallback)
        {
            for (int i = 0; i < m_schemes.Count; i++)
            {
                FileScheme scheme = m_schemes[i];
                foreach (FileIdentifier dependency in scheme.Dependencies)
                {
                    if (m_knownFiles.Contains(dependency.FilePath))
                    {
                        continue;
                    }

                    string systemFilePath = dependencyCallback.Invoke(dependency.FilePath);
                    if (systemFilePath == null)
                    {
                        m_knownFiles.Add(dependency.FilePath);
                        Logger.Log(LogType.Warning, LogCategory.Import, $"Dependency '{dependency}' hasn't been found");
                        continue;
                    }

                    AddScheme(systemFilePath, dependency.FilePath);
                }
            }
        }
 protected void AddScheme(FileScheme scheme)
 {
     m_schemes.Add(scheme);
 }