2016-11-13 04:33:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Emby.Server
|
|
|
|
|
{
|
|
|
|
|
public class ApplicationPathHelper
|
|
|
|
|
{
|
2016-11-13 21:04:21 +00:00
|
|
|
|
public static string GetProgramDataPath(string appDirectory)
|
2016-11-13 04:33:51 +00:00
|
|
|
|
{
|
|
|
|
|
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))
|
|
|
|
|
{
|
2016-11-13 21:04:21 +00:00
|
|
|
|
programDataPath = Path.Combine(appDirectory, programDataPath);
|
2016-11-13 04:33:51 +00:00
|
|
|
|
|
|
|
|
|
programDataPath = Path.GetFullPath(programDataPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(programDataPath);
|
|
|
|
|
|
|
|
|
|
return programDataPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|