Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
Updated the Example
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Dec 3, 2019
1 parent 2276d28 commit d532184
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions OMODFramework.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ internal class Program
private static void Main(string[] args)
{
// set the temp folder if you don't want it at %temp%/OMODFramework/
Framework.TempDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestTempDir");
Framework.Settings.TempPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestTempDir");

Framework.OblivionINIFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Framework.Settings.ScriptExecutionSettings.OblivionINIPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"Oblivion.ini");

Framework.CodeProgress = new Progress();
Framework.Settings.CodeProgress = new Progress();

var settings = new FrameworkSettings()
{

};

if(Directory.Exists(Framework.TempDir))
if(Directory.Exists(Framework.Settings.TempPath))
Framework.CleanTempDir();

var omod = new OMOD("DarNified UI 1.3.2.omod");

var data = omod.GetDataFiles(); // extracts all data files
var plugins = omod.GetPlugins(); // extracts all plugins
var data = omod.GetDataFiles().Result; // extracts all data files
var plugins = omod.GetPlugins().Result; // extracts all plugins

var scriptFunctions = new ScriptFunctions();
var srd = omod.RunScript(scriptFunctions, data, plugins);
Expand Down
34 changes: 17 additions & 17 deletions OMODFramework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ public static void CleanTempDir(bool deleteRoot = false)
if (!Directory.Exists(Settings.TempPath))
return;

var dInfo = new DirectoryInfo(Settings.TempPath);
dInfo.GetFiles().Do(f =>
try
{
if (!f.Exists || f.IsReadOnly)
return;

try
var dInfo = new DirectoryInfo(Settings.TempPath);
dInfo.GetFiles().Do(f =>
{
if (!f.Exists || f.IsReadOnly)
return;

f.Delete();
}
catch
});
dInfo.GetDirectories().Do(d =>
{
// ignored, file is used by another process or something/someone fucked up
}
});
dInfo.GetDirectories().Do(d =>
{
if (d.Exists && !d.Attributes.HasFlag(FileAttributes.ReadOnly)) d.Delete(true);
});
if (d.Exists && !d.Attributes.HasFlag(FileAttributes.ReadOnly)) d.Delete(true);
});

if (deleteRoot)
Directory.Delete(Settings.TempPath);
if (deleteRoot)
Directory.Delete(Settings.TempPath);
}
catch
{
// ignored, file is used by another process or something/someone fucked up
}
}
}

Expand Down

0 comments on commit d532184

Please sign in to comment.