Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit ddb0af6

Browse files
committed
fixed Paths stuff and added Templates (forgot)
1 parent 979eeff commit ddb0af6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

UI/Windows/NewFileWindow.xaml.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Xml;
99
using MahApps.Metro;
1010
using Microsoft.Win32;
11+
using SPCode.Utils;
1112

1213
namespace SPCode.UI.Windows
1314
{
@@ -78,9 +79,9 @@ public ICommand TextBoxButtonFileCmd
7879
private void ParseTemplateFile()
7980
{
8081
TemplateDictionary = new Dictionary<string, TemplateInfo>();
81-
if (File.Exists("sourcepawn\\templates\\Templates.xml"))
82+
if (File.Exists(Paths.GetTemplatesFilePath()))
8283
{
83-
using Stream stream = File.OpenRead("sourcepawn\\templates\\Templates.xml");
84+
using Stream stream = File.OpenRead(Paths.GetTemplatesFilePath());
8485
var doc = new XmlDocument();
8586
doc.Load(stream);
8687
if (doc.ChildNodes.Count <= 0)
@@ -104,7 +105,7 @@ private void ParseTemplateFile()
104105
var NewNameStr = attributes?["NewName"].Value;
105106

106107
Debug.Assert(FileNameStr != null, nameof(FileNameStr) + " != null");
107-
var FilePathStr = Path.Combine("sourcepawn\\templates\\", FileNameStr);
108+
var FilePathStr = Path.Combine(Paths.GetTemplatesDirectory(), FileNameStr);
108109
if (File.Exists(FilePathStr))
109110
{
110111
Debug.Assert(NameStr != null, nameof(NameStr) + " != null");

Utils/Paths.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public static string GetConfigsDirectory()
3535

3636
public static string GetErrorFilesDirectory()
3737
{
38-
var appDataPath = SPCodeAppDataPath + @"\spcode\sourcepawn\errorfiles";
38+
var appDataPath = SPCodeAppDataPath + @"\sourcepawn\errorfiles";
3939
var localPath = @".\sourcepawn\errorfiles";
4040
return LocalInstallation ? localPath : appDataPath;
4141
}
4242

4343
public static string GetCrashLogDirectory()
4444
{
45-
var appDataPath = SPCodeAppDataPath + @$"\spcode\crashlogs";
45+
var appDataPath = SPCodeAppDataPath + @"\crashlogs";
4646
var localPath = @".\crashlogs";
4747
if (LocalInstallation && !Directory.Exists(localPath))
4848
{
@@ -54,11 +54,18 @@ public static string GetCrashLogDirectory()
5454

5555
public static string GetTempDirectory()
5656
{
57-
var appDataPath = SPCodeAppDataPath + @$"\spcode\sourcepawn\temp";
57+
var appDataPath = SPCodeAppDataPath + @"\sourcepawn\temp";
5858
var localPath = @".\sourcepawn\temp";
5959
return LocalInstallation ? localPath : appDataPath;
6060
}
6161

62+
public static string GetTemplatesDirectory()
63+
{
64+
var appDataPath = SPCodeAppDataPath + @"\sourcepawn\templates";
65+
var localPath = @".\sourcepawn\templates";
66+
return LocalInstallation ? localPath : appDataPath;
67+
}
68+
6269
public static string GetConfigFilePath()
6370
{
6471
var appDataPath = SPCodeAppDataPath + @"\sourcepawn\configs\Configs.xml";
@@ -68,14 +75,16 @@ public static string GetConfigFilePath()
6875

6976
public static string GetTemplatesFilePath()
7077
{
71-
var appDataPath = SPCodeAppDataPath + @"\spcode\sourcepawn\templates\Templates.xml";
78+
var appDataPath = SPCodeAppDataPath + @"\sourcepawn\templates\Templates.xml";
7279
var localPath = @".\sourcepawn\templates\Templates.xml";
7380
return LocalInstallation ? localPath : appDataPath;
7481
}
7582

7683
public static string GetOptionsFilePath()
7784
{
78-
return LocalInstallation ? @".\options_0.dat" : SPCodeAppDataPath + @"\options_0.dat";
85+
var appDataPath = SPCodeAppDataPath + @"\options_0.dat";
86+
var localPath = @".\options_0.dat";
87+
return LocalInstallation ? localPath : appDataPath;
7988
}
8089
}
8190
}

0 commit comments

Comments
 (0)