Ejemplo n.º 1
0
    public void Save(string basePath, string currentSaveDir)
    {
        if (GameState == null)
        {
            throw new CorruptSaveException("Missing GameState.");
        }

        if (UiState == null)
        {
            throw new CorruptSaveException("Missing UiState.");
        }

        var serializedGameState = SavedGameState.Save(GameState, Co8State != null);

        var serializedUiState = SavedUiState.Save(UiState, Co8State != null);

        // Write the files to the current save directory so they are added to the save archive afterwards
        WriteStateToDirectory(serializedGameState, serializedUiState, currentSaveDir);

        try
        {
            ArchiveWriter.Compress(basePath + ".tfai", basePath + ".tfaf", currentSaveDir);
        }
        finally
        {
            DeleteStateFromDirectory(currentSaveDir);
        }
    }
Ejemplo n.º 2
0
        public int Run()
        {
            using (var writer = new ArchiveWriter("test_archive.pak", false))
            {
                writer.Compress(Assembly.GetExecutingAssembly(), "examples.Resources.lorem_ipsum.txt", "lorem_ipsum.txt");
            }

            using (var reader = new ArchiveReader("test_archive.pak"))
            {
                var file = reader.GetFile("lorem_ipsum.txt");
                var data = reader.Decompress(file);

                string content = Encoding.ASCII.GetString(data);
                Console.WriteLine(content);
            }

            return(0);
        }