Browse Source

Fixed some reccommended code structure stuff

piracy-check
Anairkoen Schno 5 years ago
parent
commit
8e6298640c
5 changed files with 36 additions and 8 deletions
  1. +1
    -1
      IPA.Injector/ConsoleWindow.cs
  2. +1
    -1
      IPA.Loader/Loader/PluginManager.cs
  3. +32
    -5
      IPA.Loader/Logging/Printers/GZFilePrinter.cs
  4. +1
    -1
      IPA.Loader/Logging/Printers/PluginLogFilePrinter.cs
  5. +1
    -0
      IPA/Program.cs

+ 1
- 1
IPA.Injector/ConsoleWindow.cs View File

@ -77,7 +77,7 @@ namespace Ipa.Injector.Windows
[DllImport("kernel32.dll",
EntryPoint = "CreateFileW",
SetLastError = true,
CharSet = CharSet.Auto,
CharSet = CharSet.Unicode,
CallingConvention = CallingConvention.StdCall)]
private static extern IntPtr CreateFileW(
string lpFileName,


+ 1
- 1
IPA.Loader/Loader/PluginManager.cs View File

@ -300,7 +300,7 @@ namespace IPA.Loader
internal class AppInfo
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = false)]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = false)]
private static extern int GetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
private static HandleRef NullHandleRef = new HandleRef(null, IntPtr.Zero);
public static string StartupPath


+ 32
- 5
IPA.Loader/Logging/Printers/GZFilePrinter.cs View File

@ -13,7 +13,7 @@ namespace IPA.Logging.Printers
/// <summary>
/// A <see cref="LogPrinter"/> abstract class that provides the utilities to write to a GZip file.
/// </summary>
public abstract class GZFilePrinter : LogPrinter
public abstract class GZFilePrinter : LogPrinter, IDisposable
{
[DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern bool CreateHardLink(
@ -22,9 +22,6 @@ namespace IPA.Logging.Printers
IntPtr lpSecurityAttributes
);
[DllImport("Kernel32.dll")]
static extern int GetLastError();
private FileInfo fileInfo;
/// <summary>
/// The <see cref="StreamWriter"/> that writes to the GZip file.
@ -57,7 +54,8 @@ namespace IPA.Logging.Printers
{
if (!CreateHardLink(symlink.FullName, fileInfo.FullName, IntPtr.Zero))
{
Logger.log.Error($"Hardlink creation failed {GetLastError()}");
var error = Marshal.GetLastWin32Error();
Logger.log.Error($"Hardlink creation failed ({error})");
}
}
catch (Exception e)
@ -104,5 +102,34 @@ namespace IPA.Logging.Printers
zstream.Dispose();
fstream.Dispose();
}
/// <summary>
/// Disposes the file printer.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Disposes the file printer.
/// </summary>
/// <param name="disposing">does nothing</param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
fileWriter.Flush();
zstream.Flush();
fstream.Flush();
fileWriter.Close();
zstream.Close();
fstream.Close();
fileWriter.Dispose();
zstream.Dispose();
fstream.Dispose();
}
}
}
}

+ 1
- 1
IPA.Loader/Logging/Printers/PluginLogFilePrinter.cs View File

@ -51,7 +51,7 @@ namespace IPA.Logging.Printers
public override void Print(Logger.Level level, DateTime time, string logName, string message)
{
foreach (var line in message.Split(new string[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
fileWriter.WriteLine(string.Format("[{3} @ {2:HH:mm:ss}] {0}", line, logName, time, level.ToString().ToUpper()));
fileWriter.WriteLine(string.Format("[{2} @ {1:HH:mm:ss}] {0}", line, time, level.ToString().ToUpper()));
}
}
}

+ 1
- 0
IPA/Program.cs View File

@ -32,6 +32,7 @@ namespace IPA
public static ArgumentFlag ArgStart = new ArgumentFlag("--start", "-s") { DocString = "uses value as arguments to start the game after the patch/unpatch", ValueString = "ARGUMENTS" };
public static ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" };
[STAThread]
static void Main(string[] args)
{
Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch).Process();


Loading…
Cancel
Save