diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-12 23:33:51 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-12 23:33:51 -0500 |
| commit | 95341c5c96059e4bd70f290ff05ae3abc9c49257 (patch) | |
| tree | 720dfca45628aea49a0a554afa40cfa062121cd5 /src/Emby.Server/ApplicationPathHelper.cs | |
| parent | 3e06bda46b2569c1df47d9ab0c7a763dcf3b1451 (diff) | |
update .net core startup
Diffstat (limited to 'src/Emby.Server/ApplicationPathHelper.cs')
| -rw-r--r-- | src/Emby.Server/ApplicationPathHelper.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Emby.Server/ApplicationPathHelper.cs b/src/Emby.Server/ApplicationPathHelper.cs new file mode 100644 index 000000000..4da87b6a0 --- /dev/null +++ b/src/Emby.Server/ApplicationPathHelper.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +namespace Emby.Server +{ + public class ApplicationPathHelper + { + public static string GetProgramDataPath(string applicationPath) + { + var useDebugPath = false; + +#if DEBUG + useDebugPath = true; +#endif + + var programDataPath = useDebugPath ? + "programdata" : + "programdata"; + + programDataPath = programDataPath + .Replace('/', Path.DirectorySeparatorChar) + .Replace('\\', Path.DirectorySeparatorChar); + + // If it's a relative path, e.g. "..\" + if (!Path.IsPathRooted(programDataPath)) + { + var path = Path.GetDirectoryName(applicationPath); + + if (string.IsNullOrEmpty(path)) + { + throw new Exception("Unable to determine running assembly location"); + } + + programDataPath = Path.Combine(path, programDataPath); + + programDataPath = Path.GetFullPath(programDataPath); + } + + Directory.CreateDirectory(programDataPath); + + return programDataPath; + } + } +} |
