Skip to content
Open
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
12 changes: 6 additions & 6 deletions Knossos.NET/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ private NativeMenuItem CreateLaunchFSOButton(Mod mod, FsoExecType fsoExecType)

private void OpenLog()
{
if (File.Exists(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "Knossos.log"))
if (File.Exists(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "Knossos.log")))
{
try
{
var cmd = new Process();
cmd.StartInfo.FileName = KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "Knossos.log";
cmd.StartInfo.FileName = Path.Combine(KnUtils.GetKnossosDataFolderPath(), "Knossos.log");
cmd.StartInfo.UseShellExecute = true;
cmd.Start();
cmd.Dispose();
Expand All @@ -296,18 +296,18 @@ private void OpenLog()
else
{
if (MainWindow.instance != null)
MessageBox.Show(MainWindow.instance, "Log File " + KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "Knossos.log not found.", "File not found", MessageBox.MessageBoxButtons.OK);
MessageBox.Show(MainWindow.instance, "Log File " + Path.Combine(KnUtils.GetKnossosDataFolderPath(), "Knossos.log") + " not found.", "File not found", MessageBox.MessageBoxButtons.OK);
}
}

private void OpenFS2Log()
{
if (File.Exists(KnUtils.GetFSODataFolderPath() + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "fs2_open.log"))
if (File.Exists(Path.Combine(KnUtils.GetFSODataFolderPath(), "data", "fs2_open.log")))
{
try
{
var cmd = new Process();
cmd.StartInfo.FileName = KnUtils.GetFSODataFolderPath() + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "fs2_open.log";
cmd.StartInfo.FileName = Path.Combine(KnUtils.GetFSODataFolderPath(), "data", "fs2_open.log");
cmd.StartInfo.UseShellExecute = true;
cmd.Start();
cmd.Dispose();
Expand All @@ -320,7 +320,7 @@ private void OpenFS2Log()
else
{
if (MainWindow.instance != null)
MessageBox.Show(MainWindow.instance, "Log File " + KnUtils.GetFSODataFolderPath() + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "fs2_open.log not found.", "File not found", MessageBox.MessageBoxButtons.OK);
MessageBox.Show(MainWindow.instance, "Log File " + Path.Combine(KnUtils.GetFSODataFolderPath(), "data", "fs2_open.log") + " not found.", "File not found", MessageBox.MessageBoxButtons.OK);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Knossos.NET/Classes/FsoBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ public async Task<FsoResult> RunFSO(FsoExecType executableType, string cmdline,
catch (JsonException exJson)
{
//json failed try to see if it exported a binary
if(File.Exists(folderPath+Path.DirectorySeparatorChar+"flags.lch"))
if(File.Exists(Path.Combine(folderPath, "flags.lch")))
{
Log.Add(Log.LogSeverity.Error, "FsoBuild.GetFlagsV1()", "FSO build "+ this +" seems to be below the minimum supported version (3.8.1) and does not support exporting flags as Json.");
File.Delete(folderPath + Path.DirectorySeparatorChar + "flags.lch");
File.Delete(Path.Combine(folderPath, "flags.lch"));
}
else
{
Expand Down Expand Up @@ -544,7 +544,7 @@ private void LoadExecutables(Mod modJson)
FsoExecType type = GetExecType(exec.label);
FsoExecArch arch = GetExecArch(exec.properties);
if(modJson.devMode)
executables.Add(new FsoFile(package.folder+Path.DirectorySeparatorChar+exec.file.Replace(@"./",""), folderPath, type, arch, env));
executables.Add(new FsoFile(Path.Combine(package.folder ?? "", exec.file.Replace(@"./","")), folderPath, type, arch, env));
else
executables.Add(new FsoFile(exec.file, folderPath, type, arch, env));
}
Expand Down
2 changes: 1 addition & 1 deletion Knossos.NET/Classes/KnUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ public static void CreateDesktopShortcut(string shortcutName, string destFileFul
Arguments = arguments
};

shortcut.Save(@Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + shortcutName + ".lnk");
shortcut.Save(Path.Combine(@Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), shortcutName + ".lnk"));
}
}catch(Exception ex)
{
Expand Down
44 changes: 22 additions & 22 deletions Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public static async void StartUp(bool isQuickLaunch, bool forceUpdate)
else
{
// Test if we can write to the data directory
using (StreamWriter writer = new StreamWriter(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "test.txt"))
using (StreamWriter writer = new StreamWriter(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "test.txt")))
{
writer.WriteLine("test");
}
File.Delete(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "test.txt");
File.Delete(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "test.txt"));
}
}
catch (Exception ex)
Expand Down Expand Up @@ -526,7 +526,7 @@ await Dispatcher.UIThread.Invoke(async () => {
{
extension = ".tar.gz";
}
var download = await Dispatcher.UIThread.InvokeAsync(async () => await TaskViewModel.Instance!.AddFileDownloadTask(releaseAsset.browser_download_url, KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "update"+ extension, "Downloading "+latest.tag_name+" "+releaseAsset.name, true, "This is a Knossos.NET update"), DispatcherPriority.Background).ConfigureAwait(false);
var download = await Dispatcher.UIThread.InvokeAsync(async () => await TaskViewModel.Instance!.AddFileDownloadTask(releaseAsset.browser_download_url, Path.Combine(KnUtils.GetKnossosDataFolderPath(), "update" + extension), "Downloading "+latest.tag_name+" "+releaseAsset.name, true, "This is a Knossos.NET update"), DispatcherPriority.Background).ConfigureAwait(false);
if (download != null && download == true)
{
var appDirPath = Path.GetDirectoryName(Environment.ProcessPath);
Expand Down Expand Up @@ -557,7 +557,7 @@ await Dispatcher.UIThread.Invoke(async () => {

// set new filename to match old one, in case it was renamed by the user
var newFileFullPath = Path.Combine(appFolder, Path.GetFileName(execFullPath));
File.Move(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "update" + extension, newFileFullPath);
File.Move(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "update" + extension), newFileFullPath);

//Start again
KnUtils.Chmod(newFileFullPath, "+x");
Expand Down Expand Up @@ -609,12 +609,12 @@ await Dispatcher.UIThread.Invoke(async () => {

await Dispatcher.UIThread.Invoke(async () =>
{
result = await TaskViewModel.Instance!.AddFileDecompressionTask( KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "update" + extension, updateFilesFolder, false);
result = await TaskViewModel.Instance!.AddFileDecompressionTask(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "update" + extension), updateFilesFolder, false);
}).ConfigureAwait(false);

if (!result)
{
throw new Exception("Error while decompressing update file: " + KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "update" + extension);
throw new Exception("Error while decompressing update file: " + Path.Combine(KnUtils.GetKnossosDataFolderPath(), "update" + extension));
}

if (forceUpdateDownload)
Expand All @@ -623,8 +623,8 @@ await Dispatcher.UIThread.Invoke(async () =>
//Cleanup file
try
{
if (File.Exists(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "update" + extension))
File.Delete(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "update" + extension);
if (File.Exists(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "update" + extension)))
File.Delete(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "update" + extension));
}
catch { }
}
Expand Down Expand Up @@ -1147,11 +1147,11 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
{
if (modFlag.Length > 0)
{
modFlag += "," + Path.GetRelativePath(rootPath, mod.fullPath + Path.DirectorySeparatorChar + pkg.folder).TrimEnd('/').TrimEnd('\\');
modFlag += "," + Path.GetRelativePath(rootPath, Path.Combine(mod.fullPath, pkg.folder ?? "")).TrimEnd('/').TrimEnd('\\');
}
else
{
modFlag += Path.GetRelativePath(rootPath, mod.fullPath + Path.DirectorySeparatorChar + pkg.folder).TrimEnd('/').TrimEnd('\\');
modFlag += Path.GetRelativePath(rootPath, Path.Combine(mod.fullPath, pkg.folder ?? "")).TrimEnd('/').TrimEnd('\\');
}
}
}
Expand Down Expand Up @@ -1198,11 +1198,11 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
{
if (modFlag.Length > 0)
{
modFlag += "," + Path.GetRelativePath(rootPath, depMod.fullPath + Path.DirectorySeparatorChar + pkg.folder).TrimEnd('/').TrimEnd('\\');
modFlag += "," + Path.GetRelativePath(rootPath, Path.Combine(depMod.fullPath, pkg.folder ?? "")).TrimEnd('/').TrimEnd('\\');
}
else
{
modFlag += Path.GetRelativePath(rootPath, depMod.fullPath + Path.DirectorySeparatorChar + pkg.folder).TrimEnd('/').TrimEnd('\\');
modFlag += Path.GetRelativePath(rootPath, Path.Combine(depMod.fullPath, pkg.folder ?? "")).TrimEnd('/').TrimEnd('\\');
}
}
}
Expand Down Expand Up @@ -1239,11 +1239,11 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
{
if (modFlag.Length > 0)
{
modFlag += "," + Path.GetRelativePath(rootPath, newerOpt.fullPath + Path.DirectorySeparatorChar + pkg.folder).TrimEnd('/').TrimEnd('\\');
modFlag += "," + Path.GetRelativePath(rootPath, Path.Combine(newerOpt.fullPath, pkg.folder ?? "")).TrimEnd('/').TrimEnd('\\');
}
else
{
modFlag += Path.GetRelativePath(rootPath, newerOpt.fullPath + Path.DirectorySeparatorChar + pkg.folder).TrimEnd('/').TrimEnd('\\');
modFlag += Path.GetRelativePath(rootPath, Path.Combine(newerOpt.fullPath, pkg.folder ?? "")).TrimEnd('/').TrimEnd('\\');
}
}
}
Expand Down Expand Up @@ -1546,17 +1546,17 @@ private static async Task FolderSearchRecursive(string path, bool isQuickLaunch,
}
}

if(File.Exists(path + Path.DirectorySeparatorChar + "knossos_net_download.token"))
if(File.Exists(Path.Combine(path, "knossos_net_download.token")))
{
/* This is a incomplete download, delete the folder */
Log.Add(Log.LogSeverity.Warning, "Knossos.FolderSearchRecursive()", "Deleting incomplete download found at "+path);
Directory.Delete(path, true);
}
else if (File.Exists(path + Path.DirectorySeparatorChar + "tool.json"))
else if (File.Exists(Path.Combine(path, "tool.json")))
{
Knossos.AddTool(new Tool(path));
}
else if (File.Exists(path + Path.DirectorySeparatorChar + "mod.json"))
else if (File.Exists(Path.Combine(path, "mod.json")))
{
try
{
Expand Down Expand Up @@ -1597,7 +1597,7 @@ private static async Task FolderSearchRecursive(string path, bool isQuickLaunch,
Log.Add(Log.LogSeverity.Error, "Knossos.ModSearchRecursive", ex);
}
}
else if(File.Exists(path + Path.DirectorySeparatorChar + "mod.ini"))
else if(File.Exists(Path.Combine(path, "mod.ini")))
{
var modLegacy = new Mod(path, di.Name, ModType.modlegacy);
installedMods.Add(modLegacy);
Expand Down Expand Up @@ -1751,19 +1751,19 @@ public async static void Tts(string text, int? voice_index = null, string? voice
}
if (text != string.Empty)
{
if (!File.Exists(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "KSapi.exe"))
if (!File.Exists(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "KSapi.exe")))
{
if (KnUtils.CpuArch == "X86")
{
using (var fileStream = File.Create(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "KSapi.exe"))
using (var fileStream = File.Create(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "KSapi.exe")))
{
AssetLoader.Open(new Uri("avares://Knossos.NET.Desktop/Assets/utils/win/KSapi_x86.exe")).CopyTo(fileStream);
fileStream.Close();
}
}
else
{
using (var fileStream = File.Create(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "KSapi.exe"))
using (var fileStream = File.Create(Path.Combine(KnUtils.GetKnossosDataFolderPath(), "KSapi.exe")))
{
AssetLoader.Open(new Uri("avares://Knossos.NET.Desktop/Assets/utils/win/KSapi.exe")).CopyTo(fileStream);
fileStream.Close();
Expand All @@ -1785,7 +1785,7 @@ await Task.Run(async () =>
if (volume.HasValue)
vol = volume.Value;
using var ttsProcess = new Process();
ttsProcess.StartInfo.FileName = KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "KSapi.exe";
ttsProcess.StartInfo.FileName = Path.Combine(KnUtils.GetKnossosDataFolderPath(), "KSapi.exe");
ttsProcess.StartInfo.Arguments = "-text \"" + text + "\" -voice " + voice + " -vol " + vol;
ttsProcess.StartInfo.UseShellExecute = false;
ttsProcess.StartInfo.CreateNoWindow = true;
Expand Down
Loading