ServerApplicationPaths.cs 11 KB

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