aboutsummaryrefslogtreecommitdiff
path: root/src/Emby.Server/ApplicationPathHelper.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-14 02:29:42 -0500
committerGitHub <noreply@github.com>2016-11-14 02:29:42 -0500
commit54d3c2eed767b6d030961f9a75216c447f94abef (patch)
tree1855731242b35ffbed16beb1c96de1e6442a797e /src/Emby.Server/ApplicationPathHelper.cs
parente8379b865c301cb8ab65eb5b883c44abdbedcf79 (diff)
parent43c69713835afee3d27ced041e5f96ec36fa0ce3 (diff)
Merge pull request #2288 from MediaBrowser/dev
Dev
Diffstat (limited to 'src/Emby.Server/ApplicationPathHelper.cs')
-rw-r--r--src/Emby.Server/ApplicationPathHelper.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Emby.Server/ApplicationPathHelper.cs b/src/Emby.Server/ApplicationPathHelper.cs
new file mode 100644
index 000000000..c611ff372
--- /dev/null
+++ b/src/Emby.Server/ApplicationPathHelper.cs
@@ -0,0 +1,40 @@
+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 appDirectory)
+ {
+ 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))
+ {
+ programDataPath = Path.Combine(appDirectory, programDataPath);
+
+ programDataPath = Path.GetFullPath(programDataPath);
+ }
+
+ Directory.CreateDirectory(programDataPath);
+
+ return programDataPath;
+ }
+ }
+}