[Constants, Skippers/, Tools/] Fix header extract

Use full paths in the name of the database to avoid output folder issues during script runs and make sure that Skippers are created with the absolute bare minimum set.
This commit is contained in:
Matt Nadareski
2018-01-23 10:54:29 -08:00
parent 6b32360488
commit 6e47a1d809
5 changed files with 12 additions and 13 deletions

View File

@@ -3,6 +3,12 @@ using System.Reflection;
using SabreTools.Library.Tools; using SabreTools.Library.Tools;
#if MONO
using System.IO;
#else
using Alphaleonis.Win32.Filesystem;
#endif
namespace SabreTools.Library.Data namespace SabreTools.Library.Data
{ {
/// <summary> /// <summary>
@@ -92,8 +98,8 @@ namespace SabreTools.Library.Data
#region Database schema #region Database schema
public const string HeadererDbSchema = "Headerer"; public const string HeadererDbSchema = "Headerer";
public const string HeadererFileName = "Headerer.sqlite"; public static string HeadererFileName = Path.Combine(Globals.ExeDir, "Headerer.sqlite");
public const string HeadererConnectionString = "Data Source=" + HeadererFileName + ";Version = 3;"; public static string HeadererConnectionString = "Data Source=" + HeadererFileName + ";Version = 3;";
#endregion #endregion

View File

@@ -107,8 +107,8 @@ namespace SabreTools.Library.Skippers
// Get the information from the rule first // Get the information from the rule first
SkipperRule rule = new SkipperRule SkipperRule rule = new SkipperRule
{ {
StartOffset = 0, StartOffset = null,
EndOffset = 0, EndOffset = null,
Operation = HeaderSkipOperation.None, Operation = HeaderSkipOperation.None,
Tests = new List<SkipperTest>(), Tests = new List<SkipperTest>(),
SourceFile = Path.GetFileNameWithoutExtension(filename), SourceFile = Path.GetFileNameWithoutExtension(filename),

View File

@@ -44,10 +44,7 @@ namespace SabreTools.Library.Skippers
} }
// Create the output directory if it doesn't already // Create the output directory if it doesn't already
if (!Directory.Exists(Path.GetDirectoryName(output))) Utilities.EnsureOutputDirectory(Path.GetDirectoryName(output));
{
Directory.CreateDirectory(Path.GetDirectoryName(output));
}
Globals.Logger.User("Attempting to apply rule to '{0}'", input); Globals.Logger.User("Attempting to apply rule to '{0}'", input);
success = TransformStream(Utilities.TryOpenRead(input), Utilities.TryCreate(output)); success = TransformStream(Utilities.TryOpenRead(input), Utilities.TryCreate(output));

View File

@@ -67,7 +67,6 @@ namespace SabreTools.Library.Tools
type = type.ToLowerInvariant(); type = type.ToLowerInvariant();
// Make sure the file exists // Make sure the file exists
db = Path.Combine(Globals.ExeDir, db);
if (!File.Exists(db)) if (!File.Exists(db))
{ {
SqliteConnection.CreateFile(db); SqliteConnection.CreateFile(db);

View File

@@ -1437,10 +1437,7 @@ namespace SabreTools.Library.Tools
public static bool DetectSkipperAndTransform(string file, string outDir, bool nostore) public static bool DetectSkipperAndTransform(string file, string outDir, bool nostore)
{ {
// Create the output directory if it doesn't exist // Create the output directory if it doesn't exist
if (!String.IsNullOrWhiteSpace(outDir) && !Directory.Exists(outDir)) EnsureOutputDirectory(outDir, create: true);
{
Directory.CreateDirectory(outDir);
}
Globals.Logger.User("\nGetting skipper information for '{0}'", file); Globals.Logger.User("\nGetting skipper information for '{0}'", file);