-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathUtil.cs
29 lines (26 loc) · 855 Bytes
/
Util.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Meadow.SolCodeGen
{
static class Util
{
public static string GetRelativeFilePath(string solSourceDir, string absolutePath)
{
if (string.IsNullOrEmpty(solSourceDir))
{
return absolutePath;
}
if (absolutePath.StartsWith(solSourceDir, StringComparison.OrdinalIgnoreCase))
{
absolutePath = absolutePath.Substring(solSourceDir.Length).TrimStart(new[] { '\\', '/' });
}
else if (Path.IsPathRooted(absolutePath))
{
throw new Exception($"Unexpected source file path from solc output: {absolutePath}, source dir: {solSourceDir}");
}
return absolutePath;
}
}
}