From a7fa76d63aeefcc1339dbd86ad64bb513363fc67 Mon Sep 17 00:00:00 2001 From: stax76 Date: Fri, 5 Aug 2022 07:11:50 +0200 Subject: [PATCH] relative path fix --- docs/Changelog.md | 2 +- src/Misc/Player.cs | 17 ++++++++++++----- src/WinForms/MainForm.cs | 4 +--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index a3fe63f..bf90ee6 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,7 +2,7 @@ # 6.0.3.2 (2022-0?-??) - Support multiple folders input (regression fix). -- Relative file input paths are internally converted to absolute paths. +- Relative file input paths are converted to absolute paths. # 6.0.3.1 (2022-07-30) diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index a40c184..449891c 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -1210,11 +1210,7 @@ namespace mpvnet if (file.Contains("|")) file = file.Substring(0, file.IndexOf("|")); - if ((file.Contains(":/") && !file.Contains("://")) || (file.Contains(":\\") && file.Contains("/"))) - file = file.Replace("/", "\\"); - - if (!file.Contains(":") && !file.StartsWith("\\\\") && File.Exists(file)) - file = System.IO.Path.GetFullPath(file); + file = ConvertFilePath(file); string ext = file.Ext(); @@ -1249,6 +1245,17 @@ namespace mpvnet SetPropertyInt("playlist-pos", 0); } + public string ConvertFilePath(string path) + { + if ((path.Contains(":/") && !path.Contains("://")) || (path.Contains(":\\") && path.Contains("/"))) + path = path.Replace("/", "\\"); + + if (!path.Contains(":") && !path.StartsWith("\\\\") && File.Exists(path)) + path = System.IO.Path.GetFullPath(path); + + return path; + } + public void LoadISO(string path) { long gb = new FileInfo(path).Length / 1024 / 1024 / 1024; diff --git a/src/WinForms/MainForm.cs b/src/WinForms/MainForm.cs index 54e149c..d9292f3 100644 --- a/src/WinForms/MainForm.cs +++ b/src/WinForms/MainForm.cs @@ -1,7 +1,6 @@  using System; using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; using System.Globalization; using System.Linq; @@ -747,8 +746,7 @@ namespace mpvnet string path = Core.GetPropertyString("path"); - if ((path.Contains(":/") && !path.Contains("://")) || (path.Contains(":\\") && path.Contains("/"))) - path = path.Replace("/", "\\"); + path = Core.ConvertFilePath(path); if (path.Contains("://")) {