Esempio n. 1
0
        private static async Task <Dictionary <RelativePath, T> > GatheringExtractWithOMOD <T>(Stream archive, Predicate <RelativePath> shouldExtract, Func <RelativePath, IStreamFactory, ValueTask <T> > mapfn)
        {
            var tmpFile = new TempFile();
            await tmpFile.Path.WriteAllAsync(archive);

            var dest = await TempFolder.Create();

            Utils.Log($"Extracting {(string)tmpFile.Path}");

            Framework.Settings.TempPath     = (string)dest.Dir;
            Framework.Settings.CodeProgress = new OMODProgress();

            var omod = new OMOD((string)tmpFile.Path);

            omod.GetDataFiles();
            omod.GetPlugins();

            var results = new Dictionary <RelativePath, T>();

            foreach (var file in dest.Dir.EnumerateFiles())
            {
                var path = file.RelativeTo(dest.Dir);
                if (!shouldExtract(path))
                {
                    continue;
                }

                var result = await mapfn(path, new NativeFileStreamFactory(file, path));

                results.Add(path, result);
            }

            return(results);
        }
Esempio n. 2
0
        private static void ExtractAllWithOMOD(string source, string dest)
        {
            Utils.Log($"Extracting {Path.GetFileName(source)}");

            Framework.Settings.TempPath     = dest;
            Framework.Settings.CodeProgress = new OMODProgress();

            var omod = new OMOD(source);

            omod.GetDataFiles();
            omod.GetPlugins();
        }
Esempio n. 3
0
        private static void ExtractAllWithOMOD(AbsolutePath source, AbsolutePath dest)
        {
            Utils.Log($"Extracting {(string)source.FileName}");

            Framework.Settings.TempPath     = (string)dest;
            Framework.Settings.CodeProgress = new OMODProgress();

            var omod = new OMOD((string)source);

            omod.GetDataFiles();
            omod.GetPlugins();
        }
Esempio n. 4
0
        private static async Task <ExtractedFiles> ExtractAllWithOMOD(AbsolutePath source)
        {
            var dest = await TempFolder.Create();

            Utils.Log($"Extracting {(string)source.FileName}");

            Framework.Settings.TempPath     = (string)dest.Dir;
            Framework.Settings.CodeProgress = new OMODProgress();

            var omod = new OMOD((string)source);

            omod.GetDataFiles();
            omod.GetPlugins();

            return(new ExtractedFiles(dest));
        }
Esempio n. 5
0
        public void TestExtraction()
        {
            Files.Do(f =>
            {
                var omod = new OMOD(f.FileName);

                Assert.IsNotNull(omod);

                var data = omod.GetDataFiles();
                Assert.IsNotNull(data);

                var plugins = omod.GetPlugins();
                Assert.IsTrue(omod.AllPlugins.Count == 0 && plugins == null ||
                              omod.AllPlugins.Count >= 1 && plugins != null);
            });
        }
Esempio n. 6
0
        public void TestOBMMScript()
        {
            Files.Do(f =>
            {
                var omod = new OMOD(f.FileName);

                Assert.IsNotNull(omod);

                var data    = omod.GetDataFiles();
                var plugins = omod.GetPlugins();

                var scriptFunctions = new ScriptFunctions();

                var srd = ScriptRunner.RunScript(omod, scriptFunctions, data, plugins);

                Assert.IsNotNull(srd);
                Assert.IsTrue(!srd.CancelInstall);

                srd.Pretty(omod, data, plugins);

                Assert.IsNotNull(srd.InstallFiles);
            });
        }
Esempio n. 7
0
 public static ScriptReturnData RunScript(OMOD omod, IScriptFunctions scriptFunctions, string data)
 {
     return(ExecuteScript(omod.GetScript(), data, omod.GetPlugins(), scriptFunctions));
 }
Esempio n. 8
0
 public static ScriptReturnData RunScript(OMOD omod, IScriptFunctions scriptFunctions)
 {
     return(ExecuteScript(omod.GetScript(), omod.GetDataFiles(), omod.GetPlugins(), scriptFunctions));
 }