Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 4e0dea94 authored by Harald Martini's avatar Harald Martini
Browse files

Added GetAbsolutePath to PathHelper

parent a43cc984
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,12 @@ namespace TUGraz.VectoCore.Utils
return Path.Combine(result, pathFileName);
}
public static string GetAbsolutePath(string relativeTo, string relativePath)
{
var uri = new Uri(baseUri: new Uri(relativeTo), relativeUri: relativePath);
return Path.GetFullPath(uri.AbsolutePath);
}
private static string GetRelativePath(IEnumerable<string> relativeTo, IEnumerable<string> path)
{
var relList = relativeTo.ToList();
......
......@@ -23,6 +23,8 @@ namespace TUGraz.VectoCore.Tests.Utils
Assert.AreEqual("PrimaryAndStageInput", result );
Assert.AreEqual(path, PathHelper.GetAbsolutePath(relativeTo, result));
}
[Test]
......@@ -39,6 +41,8 @@ namespace TUGraz.VectoCore.Tests.Utils
Assert.AreEqual("PrimaryAndStageInput\\file1.file", result);
Assert.AreEqual(path, PathHelper.GetAbsolutePath(relativeTo, result));
}
[Test]
public void RelativePathTest3()
......@@ -52,7 +56,8 @@ namespace TUGraz.VectoCore.Tests.Utils
var result = PathHelper.GetRelativePath(relativeTo, path);
Assert.AreEqual("PrimaryAndStageInput\\file1.file", result);
Assert.AreEqual("..\\..\\..\\..\\file.file", result);
Assert.AreEqual(path, PathHelper.GetAbsolutePath(relativeTo, result));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment