resolve
This commit is contained in:
commit
008b889ccd
@ -86,7 +86,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamReader st = new StreamReader(Paths.SAVES))
|
||||
using (StreamReader st = new StreamReader(Paths.GetSaves()))
|
||||
{
|
||||
string line = st.ReadLine();
|
||||
if (line.Contains("Overwatch.exe"))
|
||||
|
@ -18,7 +18,7 @@ namespace OWTrack
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
|
||||
public static string Version { get; } = "1.4.2";
|
||||
public static string Version { get; } = "1.4.3";
|
||||
//public static string Version = Application.ProductVersion;
|
||||
//public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*Copyright(c) 2018 Hesham Systems LLC.
|
||||
/*Copyright(c) 2018 Hesham Systems LLC.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@ -46,6 +46,14 @@ namespace OWTrack
|
||||
public bool TrackOW = true;
|
||||
public bool TrackSR = true;
|
||||
|
||||
struct ProgramFiles
|
||||
{
|
||||
public static readonly string C = "C:\\Program Files";
|
||||
public static readonly string D = "D:\\Program Files";
|
||||
public static readonly string E = "E:\\Program Files";
|
||||
public static readonly string F = "F:\\Program Files";
|
||||
}
|
||||
|
||||
public bool owRunning()
|
||||
{
|
||||
if (TrackOW)
|
||||
@ -69,34 +77,15 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
DriveInfo[] driveInfo = DriveInfo.GetDrives();
|
||||
List<string> paths = new List<string>();
|
||||
string[] filesC = null;
|
||||
string[] filesD = null;
|
||||
|
||||
if (ProgramFilesExist('c')) { filesC = Directory.GetFiles("C:\\Program Files", "Overwatch.exe", SearchOption.AllDirectories); }
|
||||
if (ProgramFilesExist('d')) { filesD = Directory.GetFiles("D:\\Program Files", "Overwatch.exe", SearchOption.AllDirectories); }
|
||||
|
||||
if (filesC != null)
|
||||
//Searches all drives (too long)
|
||||
foreach (var drive in driveInfo)
|
||||
{
|
||||
for (int i = 0; i < filesC.Length; i++)
|
||||
{
|
||||
if (filesC[i].Contains("Overwatch.exe"))
|
||||
{
|
||||
paths.Add(filesC[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filesD != null)
|
||||
{
|
||||
for (int i = 0; i < filesD.Length - 1; i++)
|
||||
{
|
||||
if (filesD[i].Contains("Overwatch.exe"))
|
||||
{
|
||||
paths.Add(filesD[i]);
|
||||
}
|
||||
}
|
||||
//paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe"));
|
||||
}
|
||||
paths.AddRange(GetFiles(ProgramFiles.C, "Overwatch.exe"));
|
||||
paths.AddRange(GetFiles(ProgramFiles.D, "Overwatch.exe"));
|
||||
|
||||
if (paths.Count > 1)
|
||||
{
|
||||
@ -122,5 +111,36 @@ namespace OWTrack
|
||||
{
|
||||
return Directory.Exists(drive+":\\Program Files");
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetFiles(string root, string searchPattern)
|
||||
{
|
||||
Stack<string> pending = new Stack<string>();
|
||||
pending.Push(root);
|
||||
while (pending.Count != 0)
|
||||
{
|
||||
var path = pending.Pop();
|
||||
string[] next = null;
|
||||
try
|
||||
{
|
||||
next = Directory.GetFiles(path, searchPattern);
|
||||
}
|
||||
catch { }
|
||||
if (next != null && next.Length != 0)
|
||||
foreach (var file in next) yield return file;
|
||||
try
|
||||
{
|
||||
next = Directory.GetDirectories(path);
|
||||
foreach (var subdir in next) pending.Push(subdir);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct Settings
|
||||
{
|
||||
bool TrackSR, TrackOW;
|
||||
string OWpath;
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace OWTrack
|
||||
{
|
||||
static class Paths
|
||||
public static class Paths
|
||||
{
|
||||
private static string curDir = Directory.GetCurrentDirectory();
|
||||
public static string SAVES = curDir + "/saves/data.json";
|
||||
public static string JSON = curDir + "/data.json";
|
||||
private static string SAVES = curDir + "/saves/data.json";
|
||||
private static string JSON = curDir + "/data.json";
|
||||
public static string GetJSON() { return JSON; }
|
||||
public static string GetSaves() { return SAVES; }
|
||||
public static string GetCurrentDir() { return curDir; }
|
||||
}
|
||||
|
||||
class saveManeger
|
||||
@ -45,7 +48,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.SAVES));
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.GetSaves()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -73,8 +76,8 @@ namespace OWTrack
|
||||
public static bool SaveJSON(Tracker tracker)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Paths.SAVES, JsonConvert.SerializeObject(tracker, Formatting.Indented));
|
||||
{
|
||||
File.WriteAllText(Paths.GetSaves(), JsonConvert.SerializeObject(tracker, Formatting.Indented));
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@ -91,7 +94,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(Paths.SAVES))
|
||||
if (File.Exists(Paths.GetSaves()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user