mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-08-01 13:49:11 +00:00
Compare commits
No commits in common. "d58d3af8fc00dcbf46cc8e2872bee1228dc1be96" and "58fcedb3d2b8b9bc34da1f473787eaee4964239a" have entirely different histories.
d58d3af8fc
...
58fcedb3d2
2 changed files with 3 additions and 59 deletions
AutoTrackR2
|
@ -54,7 +54,7 @@
|
||||||
Width="75"
|
Width="75"
|
||||||
Height="30"
|
Height="30"
|
||||||
FontFamily="{StaticResource Orbitron}"
|
FontFamily="{StaticResource Orbitron}"
|
||||||
Margin="0,0"
|
Margin="5,0"
|
||||||
Style="{StaticResource ButtonStyle}"
|
Style="{StaticResource ButtonStyle}"
|
||||||
Click="LogFileOpenButton_Click"/>
|
Click="LogFileOpenButton_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
Width="75"
|
Width="75"
|
||||||
Height="30"
|
Height="30"
|
||||||
FontFamily="{StaticResource Orbitron}"
|
FontFamily="{StaticResource Orbitron}"
|
||||||
Margin="0,0"
|
Margin="5,0"
|
||||||
Style="{StaticResource ButtonStyle}"
|
Style="{StaticResource ButtonStyle}"
|
||||||
Click="VideoPathOpenButton_Click"/>
|
Click="VideoPathOpenButton_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -17,64 +17,8 @@ public class KillHistoryManager
|
||||||
{
|
{
|
||||||
File.WriteAllText(_killHistoryPath, _headers);
|
File.WriteAllText(_killHistoryPath, _headers);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
CheckAndFixMalformedCsv();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckAndFixMalformedCsv()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Try to read the file to check if it's malformed
|
|
||||||
using var reader = new StreamReader(_killHistoryPath);
|
|
||||||
var firstLine = reader.ReadLine();
|
|
||||||
|
|
||||||
// If the file is empty or doesn't start with the correct headers, it's malformed
|
|
||||||
if (string.IsNullOrEmpty(firstLine) || firstLine != _headers.TrimEnd('\n'))
|
|
||||||
{
|
|
||||||
// Create a backup of the malformed file
|
|
||||||
string backupPath = Path.Combine(
|
|
||||||
Path.GetDirectoryName(_killHistoryPath)!,
|
|
||||||
"Kill-log.old"
|
|
||||||
);
|
|
||||||
|
|
||||||
// If Kill-log.old already exists, delete it
|
|
||||||
if (File.Exists(backupPath))
|
|
||||||
{
|
|
||||||
File.Delete(backupPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename the malformed file
|
|
||||||
File.Move(_killHistoryPath, backupPath);
|
|
||||||
|
|
||||||
// Create a new file with correct headers
|
|
||||||
File.WriteAllText(_killHistoryPath, _headers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// If there's any error reading the file, consider it malformed
|
|
||||||
string backupPath = Path.Combine(
|
|
||||||
Path.GetDirectoryName(_killHistoryPath)!,
|
|
||||||
"Kill-log.old"
|
|
||||||
);
|
|
||||||
|
|
||||||
// If Kill-log.old already exists, delete it
|
|
||||||
if (File.Exists(backupPath))
|
|
||||||
{
|
|
||||||
File.Delete(backupPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename the malformed file
|
|
||||||
File.Move(_killHistoryPath, backupPath);
|
|
||||||
|
|
||||||
// Create a new file with correct headers
|
|
||||||
File.WriteAllText(_killHistoryPath, _headers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddKill(KillData killData)
|
public void AddKill(KillData killData)
|
||||||
{
|
{
|
||||||
// Ensure the CSV file exists
|
// Ensure the CSV file exists
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue