Skip to content

Commit

Permalink
Merge pull request #88 from lilyremigia/master
Browse files Browse the repository at this point in the history
Fix various issues
  • Loading branch information
brliron authored Mar 11, 2024
2 parents 759705c + 02caad2 commit c26a1c3
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 339 deletions.
5 changes: 4 additions & 1 deletion Universal THCRAP Launcher.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Shinmera/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=thcrap/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasofro/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=thcrap/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=thcrap_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Touhou/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
9 changes: 2 additions & 7 deletions Universal THCRAP Launcher/I18N.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
using Newtonsoft.Json;

namespace Universal_THCRAP_Launcher
{
Expand Down
50 changes: 23 additions & 27 deletions Universal THCRAP Launcher/Log.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Security.Permissions;
using System.Security;
using System.Security.Permissions;
using System.Windows.Forms;

namespace Universal_THCRAP_Launcher
{
class Log
internal class Log
{
private FileStream fs;
private StreamWriter sw;
private readonly FileStream _fs;
private readonly StreamWriter _sw;

public Log(string logFile)
{
Expand All @@ -29,48 +25,48 @@ public Log(string logFile)
}

// Delete log file if larger than 1 MB
if (File.Exists(logFile) && new System.IO.FileInfo(logFile).Length >= 0x100000)
if (File.Exists(logFile) && new FileInfo(logFile).Length >= 0x100000)
File.Delete(logFile);

string dirName = Path.GetDirectoryName(logFile);
if (!Directory.Exists(dirName))
Directory.CreateDirectory(dirName);

fs = new FileStream(logFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
sw = new StreamWriter(fs);
_fs = new FileStream(logFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
_sw = new StreamWriter(_fs);
}

public void WriteLine(object text)
{
Console.WriteLine($"[{DateTime.Now.ToLongTimeString()}] " + text);
if (sw == null) return;
sw.WriteLine($"[{DateTime.Now.ToLongTimeString()}] " + text);
sw.Flush();
fs.Flush();
if (_sw == null) return;
_sw.WriteLine($"[{DateTime.Now.ToLongTimeString()}] " + text);
_sw.Flush();
_fs.Flush();
}

public void Write(object text)
{
Console.Write(text);
if (sw == null) return;
sw.Write(text);
sw.Flush();
fs.Flush();
if (_sw == null) return;
_sw.Write(text);
_sw.Flush();
_fs.Flush();
}

~Log()
{
if (sw != null)
if (_sw != null)
{
sw.Flush();
sw.Close();
sw.Dispose();
_sw.Flush();
_sw.Close();
_sw.Dispose();
}
if (fs != null)
if (_fs != null)
{
fs.Flush();
fs.Close();
fs.Dispose();
_fs.Flush();
_fs.Close();
_fs.Dispose();
}
}
}
Expand Down
Loading

0 comments on commit c26a1c3

Please sign in to comment.