Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the paths compatible with Linux #691

Merged
merged 2 commits into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PoGo.NecroBot.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#region using directives

using System;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
Expand Down Expand Up @@ -38,7 +39,7 @@ private static void Main(string[] args)
{
string subPath = "";
if (args.Length > 0)
subPath = "\\" + args[0];
subPath = Path.DirectorySeparatorChar + args[0];

Logger.SetLogger(new ConsoleLogger(LogLevel.Info), subPath);

Expand Down
10 changes: 6 additions & 4 deletions PoGo.NecroBot.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ internal class AuthSettings
{
public AuthSettings()
{
if (File.Exists(Directory.GetCurrentDirectory() + "\\config\\auth.json")) return;
if (File.Exists(Directory.GetCurrentDirectory()
+ Path.DirectorySeparatorChar +"config"
+ Path.DirectorySeparatorChar + "auth.json")) return;
string type;
do
{
Expand Down Expand Up @@ -108,9 +110,9 @@ public class GlobalSettings
public static GlobalSettings Load(string path)
{
ProfilePath = Directory.GetCurrentDirectory() + path;
ConfigPath = ProfilePath + "\\config";
ConfigPath = ProfilePath + Path.DirectorySeparatorChar + "config";

var fullPath = ConfigPath + "\\config.json";
var fullPath = ConfigPath + Path.DirectorySeparatorChar + "config.json";

GlobalSettings settings = null;
if (File.Exists(fullPath))
Expand All @@ -130,7 +132,7 @@ public static GlobalSettings Load(string path)
settings = new GlobalSettings();
}
settings.Save(fullPath);
settings.Auth.Load(ConfigPath + "\\auth.json");
settings.Auth.Load(ConfigPath + Path.DirectorySeparatorChar + "auth.json");

return settings;
}
Expand Down
4 changes: 2 additions & 2 deletions PoGo.NecroBot.Logic/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public static class Logger
private static void Log(string message)
{
// maybe do a new log rather than appending?
Directory.CreateDirectory(Directory.GetCurrentDirectory() + _subPath + "\\Logs");
Directory.CreateDirectory(Directory.GetCurrentDirectory() + _subPath + Path.DirectorySeparatorChar + "Logs");


using (
var log =
File.AppendText(Directory.GetCurrentDirectory() + _subPath +
$"\\Logs\\NecroBot-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.txt")
$"{Path.DirectorySeparatorChar}Logs{Path.DirectorySeparatorChar}NecroBot-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.txt")
)
{
log.WriteLine(message);
Expand Down
8 changes: 4 additions & 4 deletions PoGo.NecroBot.Logic/State/PositionCheckState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PositionCheckState : IState
{
public IState Execute(Context ctx, StateMachine machine)
{
var coordsPath = Directory.GetCurrentDirectory() + "\\Configs\\Coords.ini";
var coordsPath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Configs"+ Path.DirectorySeparatorChar+ "Coords.ini";
if (File.Exists(coordsPath))
{
var latLngFromFile = LoadPositionFromDisk(machine);
Expand Down Expand Up @@ -63,10 +63,10 @@ public IState Execute(Context ctx, StateMachine machine)

private static Tuple<double, double> LoadPositionFromDisk(StateMachine machine)
{
if (File.Exists(Directory.GetCurrentDirectory() + "\\Configs\\Coords.ini") &&
File.ReadAllText(Directory.GetCurrentDirectory() + "\\Configs\\Coords.ini").Contains(":"))
if (File.Exists(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Configs"+ Path.DirectorySeparatorChar + "Coords.ini") &&
File.ReadAllText(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar+"Configs"+ Path.DirectorySeparatorChar + "Coords.ini").Contains(":"))
{
var latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Configs\\Coords.ini");
var latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Configs"+ Path.DirectorySeparatorChar + "Coords.ini");
var latlng = latlngFromFile.Split(':');
if (latlng[0].Length != 0 && latlng[1].Length != 0)
{
Expand Down