ServerApplicationPaths.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. using MediaBrowser.Common.Implementations;
  2. using MediaBrowser.Controller;
  3. using System.IO;
  4. namespace MediaBrowser.Server.Implementations
  5. {
  6. /// <summary>
  7. /// Extends BaseApplicationPaths to add paths that are only applicable on the server
  8. /// </summary>
  9. public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
  10. {
  11. #if (DEBUG)
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class.
  14. /// </summary>
  15. public ServerApplicationPaths()
  16. : base(true)
  17. {
  18. }
  19. #else
  20. public ServerApplicationPaths()
  21. : base(false)
  22. {
  23. }
  24. #endif
  25. /// <summary>
  26. /// The _root folder path
  27. /// </summary>
  28. private string _rootFolderPath;
  29. /// <summary>
  30. /// Gets the path to the base root media directory
  31. /// </summary>
  32. /// <value>The root folder path.</value>
  33. public string RootFolderPath
  34. {
  35. get
  36. {
  37. if (_rootFolderPath == null)
  38. {
  39. _rootFolderPath = Path.Combine(ProgramDataPath, "Root");
  40. if (!Directory.Exists(_rootFolderPath))
  41. {
  42. Directory.CreateDirectory(_rootFolderPath);
  43. }
  44. }
  45. return _rootFolderPath;
  46. }
  47. }
  48. /// <summary>
  49. /// The _default user views path
  50. /// </summary>
  51. private string _defaultUserViewsPath;
  52. /// <summary>
  53. /// Gets the path to the default user view directory. Used if no specific user view is defined.
  54. /// </summary>
  55. /// <value>The default user views path.</value>
  56. public string DefaultUserViewsPath
  57. {
  58. get
  59. {
  60. if (_defaultUserViewsPath == null)
  61. {
  62. _defaultUserViewsPath = Path.Combine(RootFolderPath, "Default");
  63. if (!Directory.Exists(_defaultUserViewsPath))
  64. {
  65. Directory.CreateDirectory(_defaultUserViewsPath);
  66. }
  67. }
  68. return _defaultUserViewsPath;
  69. }
  70. }
  71. /// <summary>
  72. /// The _localization path
  73. /// </summary>
  74. private string _localizationPath;
  75. /// <summary>
  76. /// Gets the path to localization data.
  77. /// </summary>
  78. /// <value>The localization path.</value>
  79. public string LocalizationPath
  80. {
  81. get
  82. {
  83. if (_localizationPath == null)
  84. {
  85. _localizationPath = Path.Combine(ProgramDataPath, "Localization");
  86. if (!Directory.Exists(_localizationPath))
  87. {
  88. Directory.CreateDirectory(_localizationPath);
  89. }
  90. }
  91. return _localizationPath;
  92. }
  93. }
  94. /// <summary>
  95. /// The _ibn path
  96. /// </summary>
  97. private string _ibnPath;
  98. /// <summary>
  99. /// Gets the path to the Images By Name directory
  100. /// </summary>
  101. /// <value>The images by name path.</value>
  102. public string ImagesByNamePath
  103. {
  104. get
  105. {
  106. if (_ibnPath == null)
  107. {
  108. _ibnPath = Path.Combine(ProgramDataPath, "ImagesByName");
  109. if (!Directory.Exists(_ibnPath))
  110. {
  111. Directory.CreateDirectory(_ibnPath);
  112. }
  113. }
  114. return _ibnPath;
  115. }
  116. }
  117. /// <summary>
  118. /// The _people path
  119. /// </summary>
  120. private string _peoplePath;
  121. /// <summary>
  122. /// Gets the path to the People directory
  123. /// </summary>
  124. /// <value>The people path.</value>
  125. public string PeoplePath
  126. {
  127. get
  128. {
  129. if (_peoplePath == null)
  130. {
  131. _peoplePath = Path.Combine(ImagesByNamePath, "People");
  132. if (!Directory.Exists(_peoplePath))
  133. {
  134. Directory.CreateDirectory(_peoplePath);
  135. }
  136. }
  137. return _peoplePath;
  138. }
  139. }
  140. /// <summary>
  141. /// The _genre path
  142. /// </summary>
  143. private string _genrePath;
  144. /// <summary>
  145. /// Gets the path to the Genre directory
  146. /// </summary>
  147. /// <value>The genre path.</value>
  148. public string GenrePath
  149. {
  150. get
  151. {
  152. if (_genrePath == null)
  153. {
  154. _genrePath = Path.Combine(ImagesByNamePath, "Genre");
  155. if (!Directory.Exists(_genrePath))
  156. {
  157. Directory.CreateDirectory(_genrePath);
  158. }
  159. }
  160. return _genrePath;
  161. }
  162. }
  163. /// <summary>
  164. /// The _studio path
  165. /// </summary>
  166. private string _studioPath;
  167. /// <summary>
  168. /// Gets the path to the Studio directory
  169. /// </summary>
  170. /// <value>The studio path.</value>
  171. public string StudioPath
  172. {
  173. get
  174. {
  175. if (_studioPath == null)
  176. {
  177. _studioPath = Path.Combine(ImagesByNamePath, "Studio");
  178. if (!Directory.Exists(_studioPath))
  179. {
  180. Directory.CreateDirectory(_studioPath);
  181. }
  182. }
  183. return _studioPath;
  184. }
  185. }
  186. /// <summary>
  187. /// The _year path
  188. /// </summary>
  189. private string _yearPath;
  190. /// <summary>
  191. /// Gets the path to the Year directory
  192. /// </summary>
  193. /// <value>The year path.</value>
  194. public string YearPath
  195. {
  196. get
  197. {
  198. if (_yearPath == null)
  199. {
  200. _yearPath = Path.Combine(ImagesByNamePath, "Year");
  201. if (!Directory.Exists(_yearPath))
  202. {
  203. Directory.CreateDirectory(_yearPath);
  204. }
  205. }
  206. return _yearPath;
  207. }
  208. }
  209. /// <summary>
  210. /// The _general path
  211. /// </summary>
  212. private string _generalPath;
  213. /// <summary>
  214. /// Gets the path to the General IBN directory
  215. /// </summary>
  216. /// <value>The general path.</value>
  217. public string GeneralPath
  218. {
  219. get
  220. {
  221. if (_generalPath == null)
  222. {
  223. _generalPath = Path.Combine(ImagesByNamePath, "General");
  224. if (!Directory.Exists(_generalPath))
  225. {
  226. Directory.CreateDirectory(_generalPath);
  227. }
  228. }
  229. return _generalPath;
  230. }
  231. }
  232. /// <summary>
  233. /// The _ratings path
  234. /// </summary>
  235. private string _ratingsPath;
  236. /// <summary>
  237. /// Gets the path to the Ratings IBN directory
  238. /// </summary>
  239. /// <value>The ratings path.</value>
  240. public string RatingsPath
  241. {
  242. get
  243. {
  244. if (_ratingsPath == null)
  245. {
  246. _ratingsPath = Path.Combine(ImagesByNamePath, "Ratings");
  247. if (!Directory.Exists(_ratingsPath))
  248. {
  249. Directory.CreateDirectory(_ratingsPath);
  250. }
  251. }
  252. return _ratingsPath;
  253. }
  254. }
  255. /// <summary>
  256. /// The _user configuration directory path
  257. /// </summary>
  258. private string _userConfigurationDirectoryPath;
  259. /// <summary>
  260. /// Gets the path to the user configuration directory
  261. /// </summary>
  262. /// <value>The user configuration directory path.</value>
  263. public string UserConfigurationDirectoryPath
  264. {
  265. get
  266. {
  267. if (_userConfigurationDirectoryPath == null)
  268. {
  269. _userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "users");
  270. if (!Directory.Exists(_userConfigurationDirectoryPath))
  271. {
  272. Directory.CreateDirectory(_userConfigurationDirectoryPath);
  273. }
  274. }
  275. return _userConfigurationDirectoryPath;
  276. }
  277. }
  278. /// <summary>
  279. /// The _f F MPEG stream cache path
  280. /// </summary>
  281. private string _fFMpegStreamCachePath;
  282. /// <summary>
  283. /// Gets the FF MPEG stream cache path.
  284. /// </summary>
  285. /// <value>The FF MPEG stream cache path.</value>
  286. public string FFMpegStreamCachePath
  287. {
  288. get
  289. {
  290. if (_fFMpegStreamCachePath == null)
  291. {
  292. _fFMpegStreamCachePath = Path.Combine(CachePath, "ffmpeg-streams");
  293. if (!Directory.Exists(_fFMpegStreamCachePath))
  294. {
  295. Directory.CreateDirectory(_fFMpegStreamCachePath);
  296. }
  297. }
  298. return _fFMpegStreamCachePath;
  299. }
  300. }
  301. /// <summary>
  302. /// The _media tools path
  303. /// </summary>
  304. private string _mediaToolsPath;
  305. /// <summary>
  306. /// Gets the folder path to tools
  307. /// </summary>
  308. /// <value>The media tools path.</value>
  309. public string MediaToolsPath
  310. {
  311. get
  312. {
  313. if (_mediaToolsPath == null)
  314. {
  315. _mediaToolsPath = Path.Combine(ProgramDataPath, "MediaTools");
  316. if (!Directory.Exists(_mediaToolsPath))
  317. {
  318. Directory.CreateDirectory(_mediaToolsPath);
  319. }
  320. }
  321. return _mediaToolsPath;
  322. }
  323. }
  324. }
  325. }