ManagedFileSystem.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using MediaBrowser.Common.IO;
  7. using MediaBrowser.Model.IO;
  8. using Patterns.Logging;
  9. namespace MediaBrowser.Common.Implementations.IO
  10. {
  11. /// <summary>
  12. /// Class ManagedFileSystem
  13. /// </summary>
  14. public class ManagedFileSystem : IFileSystem
  15. {
  16. protected ILogger Logger;
  17. private readonly bool _supportsAsyncFileStreams;
  18. private char[] _invalidFileNameChars;
  19. private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
  20. protected bool EnableFileSystemRequestConcat = true;
  21. public ManagedFileSystem(ILogger logger, bool supportsAsyncFileStreams, bool enableManagedInvalidFileNameChars)
  22. {
  23. Logger = logger;
  24. _supportsAsyncFileStreams = supportsAsyncFileStreams;
  25. SetInvalidFileNameChars(enableManagedInvalidFileNameChars);
  26. }
  27. public void AddShortcutHandler(IShortcutHandler handler)
  28. {
  29. _shortcutHandlers.Add(handler);
  30. }
  31. protected void SetInvalidFileNameChars(bool enableManagedInvalidFileNameChars)
  32. {
  33. if (enableManagedInvalidFileNameChars)
  34. {
  35. _invalidFileNameChars = Path.GetInvalidFileNameChars();
  36. }
  37. else
  38. {
  39. // GetInvalidFileNameChars is less restrictive in Linux/Mac than Windows, this mimic Windows behavior for mono under Linux/Mac.
  40. _invalidFileNameChars = new char[41] { '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
  41. '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D', '\x0E', '\x0F', '\x10', '\x11', '\x12',
  42. '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D',
  43. '\x1E', '\x1F', '\x22', '\x3C', '\x3E', '\x7C', ':', '*', '?', '\\', '/' };
  44. }
  45. }
  46. /// <summary>
  47. /// Determines whether the specified filename is shortcut.
  48. /// </summary>
  49. /// <param name="filename">The filename.</param>
  50. /// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
  51. /// <exception cref="System.ArgumentNullException">filename</exception>
  52. public virtual bool IsShortcut(string filename)
  53. {
  54. if (string.IsNullOrEmpty(filename))
  55. {
  56. throw new ArgumentNullException("filename");
  57. }
  58. var extension = Path.GetExtension(filename);
  59. return _shortcutHandlers.Any(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
  60. }
  61. /// <summary>
  62. /// Resolves the shortcut.
  63. /// </summary>
  64. /// <param name="filename">The filename.</param>
  65. /// <returns>System.String.</returns>
  66. /// <exception cref="System.ArgumentNullException">filename</exception>
  67. public virtual string ResolveShortcut(string filename)
  68. {
  69. if (string.IsNullOrEmpty(filename))
  70. {
  71. throw new ArgumentNullException("filename");
  72. }
  73. var extension = Path.GetExtension(filename);
  74. var handler = _shortcutHandlers.FirstOrDefault(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
  75. if (handler != null)
  76. {
  77. return handler.Resolve(filename);
  78. }
  79. return null;
  80. }
  81. /// <summary>
  82. /// Creates the shortcut.
  83. /// </summary>
  84. /// <param name="shortcutPath">The shortcut path.</param>
  85. /// <param name="target">The target.</param>
  86. /// <exception cref="System.ArgumentNullException">
  87. /// shortcutPath
  88. /// or
  89. /// target
  90. /// </exception>
  91. public void CreateShortcut(string shortcutPath, string target)
  92. {
  93. if (string.IsNullOrEmpty(shortcutPath))
  94. {
  95. throw new ArgumentNullException("shortcutPath");
  96. }
  97. if (string.IsNullOrEmpty(target))
  98. {
  99. throw new ArgumentNullException("target");
  100. }
  101. var extension = Path.GetExtension(shortcutPath);
  102. var handler = _shortcutHandlers.FirstOrDefault(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
  103. if (handler != null)
  104. {
  105. handler.Create(shortcutPath, target);
  106. }
  107. else
  108. {
  109. throw new NotImplementedException();
  110. }
  111. }
  112. /// <summary>
  113. /// Returns a <see cref="FileSystemMetadata"/> object for the specified file or directory path.
  114. /// </summary>
  115. /// <param name="path">A path to a file or directory.</param>
  116. /// <returns>A <see cref="FileSystemMetadata"/> object.</returns>
  117. /// <remarks>If the specified path points to a directory, the returned <see cref="FileSystemMetadata"/> object's
  118. /// <see cref="FileSystemMetadata.IsDirectory"/> property will be set to true and all other properties will reflect the properties of the directory.</remarks>
  119. public FileSystemMetadata GetFileSystemInfo(string path)
  120. {
  121. if (string.IsNullOrEmpty(path))
  122. {
  123. throw new ArgumentNullException("path");
  124. }
  125. // Take a guess to try and avoid two file system hits, but we'll double-check by calling Exists
  126. if (Path.HasExtension(path))
  127. {
  128. var fileInfo = new FileInfo(path);
  129. if (fileInfo.Exists)
  130. {
  131. return GetFileSystemMetadata(fileInfo);
  132. }
  133. return GetFileSystemMetadata(new DirectoryInfo(path));
  134. }
  135. else
  136. {
  137. var fileInfo = new DirectoryInfo(path);
  138. if (fileInfo.Exists)
  139. {
  140. return GetFileSystemMetadata(fileInfo);
  141. }
  142. return GetFileSystemMetadata(new FileInfo(path));
  143. }
  144. }
  145. /// <summary>
  146. /// Returns a <see cref="FileSystemMetadata"/> object for the specified file path.
  147. /// </summary>
  148. /// <param name="path">A path to a file.</param>
  149. /// <returns>A <see cref="FileSystemMetadata"/> object.</returns>
  150. /// <remarks><para>If the specified path points to a directory, the returned <see cref="FileSystemMetadata"/> object's
  151. /// <see cref="FileSystemMetadata.IsDirectory"/> property and the <see cref="FileSystemMetadata.Exists"/> property will both be set to false.</para>
  152. /// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo"/>.</para></remarks>
  153. public FileSystemMetadata GetFileInfo(string path)
  154. {
  155. if (string.IsNullOrEmpty(path))
  156. {
  157. throw new ArgumentNullException("path");
  158. }
  159. var fileInfo = new FileInfo(path);
  160. return GetFileSystemMetadata(fileInfo);
  161. }
  162. /// <summary>
  163. /// Returns a <see cref="FileSystemMetadata"/> object for the specified directory path.
  164. /// </summary>
  165. /// <param name="path">A path to a directory.</param>
  166. /// <returns>A <see cref="FileSystemMetadata"/> object.</returns>
  167. /// <remarks><para>If the specified path points to a file, the returned <see cref="FileSystemMetadata"/> object's
  168. /// <see cref="FileSystemMetadata.IsDirectory"/> property will be set to true and the <see cref="FileSystemMetadata.Exists"/> property will be set to false.</para>
  169. /// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo"/>.</para></remarks>
  170. public FileSystemMetadata GetDirectoryInfo(string path)
  171. {
  172. if (string.IsNullOrEmpty(path))
  173. {
  174. throw new ArgumentNullException("path");
  175. }
  176. var fileInfo = new DirectoryInfo(path);
  177. return GetFileSystemMetadata(fileInfo);
  178. }
  179. private FileSystemMetadata GetFileSystemMetadata(FileSystemInfo info)
  180. {
  181. var result = new FileSystemMetadata();
  182. result.Exists = info.Exists;
  183. result.FullName = info.FullName;
  184. result.Extension = info.Extension;
  185. result.Name = info.Name;
  186. if (result.Exists)
  187. {
  188. var attributes = info.Attributes;
  189. result.IsDirectory = info is DirectoryInfo || (attributes & FileAttributes.Directory) == FileAttributes.Directory;
  190. result.IsHidden = (attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
  191. result.IsReadOnly = (attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
  192. var fileInfo = info as FileInfo;
  193. if (fileInfo != null)
  194. {
  195. result.Length = fileInfo.Length;
  196. result.DirectoryName = fileInfo.DirectoryName;
  197. }
  198. result.CreationTimeUtc = GetCreationTimeUtc(info);
  199. result.LastWriteTimeUtc = GetLastWriteTimeUtc(info);
  200. }
  201. else
  202. {
  203. result.IsDirectory = info is DirectoryInfo;
  204. }
  205. return result;
  206. }
  207. /// <summary>
  208. /// The space char
  209. /// </summary>
  210. private const char SpaceChar = ' ';
  211. /// <summary>
  212. /// Takes a filename and removes invalid characters
  213. /// </summary>
  214. /// <param name="filename">The filename.</param>
  215. /// <returns>System.String.</returns>
  216. /// <exception cref="System.ArgumentNullException">filename</exception>
  217. public string GetValidFilename(string filename)
  218. {
  219. if (string.IsNullOrEmpty(filename))
  220. {
  221. throw new ArgumentNullException("filename");
  222. }
  223. var builder = new StringBuilder(filename);
  224. foreach (var c in _invalidFileNameChars)
  225. {
  226. builder = builder.Replace(c, SpaceChar);
  227. }
  228. return builder.ToString();
  229. }
  230. /// <summary>
  231. /// Gets the creation time UTC.
  232. /// </summary>
  233. /// <param name="info">The info.</param>
  234. /// <returns>DateTime.</returns>
  235. public DateTime GetCreationTimeUtc(FileSystemInfo info)
  236. {
  237. // This could throw an error on some file systems that have dates out of range
  238. try
  239. {
  240. return info.CreationTimeUtc;
  241. }
  242. catch (Exception ex)
  243. {
  244. Logger.ErrorException("Error determining CreationTimeUtc for {0}", ex, info.FullName);
  245. return DateTime.MinValue;
  246. }
  247. }
  248. /// <summary>
  249. /// Gets the creation time UTC.
  250. /// </summary>
  251. /// <param name="path">The path.</param>
  252. /// <returns>DateTime.</returns>
  253. public DateTime GetCreationTimeUtc(string path)
  254. {
  255. return GetCreationTimeUtc(GetFileSystemInfo(path));
  256. }
  257. public DateTime GetCreationTimeUtc(FileSystemMetadata info)
  258. {
  259. return info.CreationTimeUtc;
  260. }
  261. public DateTime GetLastWriteTimeUtc(FileSystemMetadata info)
  262. {
  263. return info.LastWriteTimeUtc;
  264. }
  265. /// <summary>
  266. /// Gets the creation time UTC.
  267. /// </summary>
  268. /// <param name="info">The info.</param>
  269. /// <returns>DateTime.</returns>
  270. public DateTime GetLastWriteTimeUtc(FileSystemInfo info)
  271. {
  272. // This could throw an error on some file systems that have dates out of range
  273. try
  274. {
  275. return info.LastWriteTimeUtc;
  276. }
  277. catch (Exception ex)
  278. {
  279. Logger.ErrorException("Error determining LastAccessTimeUtc for {0}", ex, info.FullName);
  280. return DateTime.MinValue;
  281. }
  282. }
  283. /// <summary>
  284. /// Gets the last write time UTC.
  285. /// </summary>
  286. /// <param name="path">The path.</param>
  287. /// <returns>DateTime.</returns>
  288. public DateTime GetLastWriteTimeUtc(string path)
  289. {
  290. return GetLastWriteTimeUtc(GetFileSystemInfo(path));
  291. }
  292. /// <summary>
  293. /// Gets the file stream.
  294. /// </summary>
  295. /// <param name="path">The path.</param>
  296. /// <param name="mode">The mode.</param>
  297. /// <param name="access">The access.</param>
  298. /// <param name="share">The share.</param>
  299. /// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
  300. /// <returns>FileStream.</returns>
  301. public Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false)
  302. {
  303. if (_supportsAsyncFileStreams && isAsync)
  304. {
  305. return new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 262144, true);
  306. }
  307. return new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 262144);
  308. }
  309. private FileMode GetFileMode(FileOpenMode mode)
  310. {
  311. switch (mode)
  312. {
  313. case FileOpenMode.Append:
  314. return FileMode.Append;
  315. case FileOpenMode.Create:
  316. return FileMode.Create;
  317. case FileOpenMode.CreateNew:
  318. return FileMode.CreateNew;
  319. case FileOpenMode.Open:
  320. return FileMode.Open;
  321. case FileOpenMode.OpenOrCreate:
  322. return FileMode.OpenOrCreate;
  323. case FileOpenMode.Truncate:
  324. return FileMode.Truncate;
  325. default:
  326. throw new Exception("Unrecognized FileOpenMode");
  327. }
  328. }
  329. private FileAccess GetFileAccess(FileAccessMode mode)
  330. {
  331. var val = (int)mode;
  332. return (FileAccess)val;
  333. }
  334. private FileShare GetFileShare(FileShareMode mode)
  335. {
  336. var val = (int)mode;
  337. return (FileShare)val;
  338. }
  339. public void SetHidden(string path, bool isHidden)
  340. {
  341. var info = GetFileInfo(path);
  342. if (info.Exists && info.IsHidden != isHidden)
  343. {
  344. if (isHidden)
  345. {
  346. FileAttributes attributes = File.GetAttributes(path);
  347. attributes = RemoveAttribute(attributes, FileAttributes.Hidden);
  348. File.SetAttributes(path, attributes);
  349. }
  350. else
  351. {
  352. File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
  353. }
  354. }
  355. }
  356. private static FileAttributes RemoveAttribute(FileAttributes attributes, FileAttributes attributesToRemove)
  357. {
  358. return attributes & ~attributesToRemove;
  359. }
  360. /// <summary>
  361. /// Swaps the files.
  362. /// </summary>
  363. /// <param name="file1">The file1.</param>
  364. /// <param name="file2">The file2.</param>
  365. public void SwapFiles(string file1, string file2)
  366. {
  367. if (string.IsNullOrEmpty(file1))
  368. {
  369. throw new ArgumentNullException("file1");
  370. }
  371. if (string.IsNullOrEmpty(file2))
  372. {
  373. throw new ArgumentNullException("file2");
  374. }
  375. var temp1 = Path.GetTempFileName();
  376. var temp2 = Path.GetTempFileName();
  377. // Copying over will fail against hidden files
  378. RemoveHiddenAttribute(file1);
  379. RemoveHiddenAttribute(file2);
  380. CopyFile(file1, temp1, true);
  381. CopyFile(file2, temp2, true);
  382. CopyFile(temp1, file2, true);
  383. CopyFile(temp2, file1, true);
  384. DeleteFile(temp1);
  385. DeleteFile(temp2);
  386. }
  387. /// <summary>
  388. /// Removes the hidden attribute.
  389. /// </summary>
  390. /// <param name="path">The path.</param>
  391. private void RemoveHiddenAttribute(string path)
  392. {
  393. if (string.IsNullOrEmpty(path))
  394. {
  395. throw new ArgumentNullException("path");
  396. }
  397. var currentFile = new FileInfo(path);
  398. // This will fail if the file is hidden
  399. if (currentFile.Exists)
  400. {
  401. if ((currentFile.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
  402. {
  403. currentFile.Attributes &= ~FileAttributes.Hidden;
  404. }
  405. }
  406. }
  407. public bool ContainsSubPath(string parentPath, string path)
  408. {
  409. if (string.IsNullOrEmpty(parentPath))
  410. {
  411. throw new ArgumentNullException("parentPath");
  412. }
  413. if (string.IsNullOrEmpty(path))
  414. {
  415. throw new ArgumentNullException("path");
  416. }
  417. return path.IndexOf(parentPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) != -1;
  418. }
  419. public bool IsRootPath(string path)
  420. {
  421. if (string.IsNullOrEmpty(path))
  422. {
  423. throw new ArgumentNullException("path");
  424. }
  425. var parent = Path.GetDirectoryName(path);
  426. if (!string.IsNullOrEmpty(parent))
  427. {
  428. return false;
  429. }
  430. return true;
  431. }
  432. public string NormalizePath(string path)
  433. {
  434. if (string.IsNullOrEmpty(path))
  435. {
  436. throw new ArgumentNullException("path");
  437. }
  438. if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
  439. {
  440. return path;
  441. }
  442. return path.TrimEnd(Path.DirectorySeparatorChar);
  443. }
  444. public string GetFileNameWithoutExtension(FileSystemMetadata info)
  445. {
  446. if (info.IsDirectory)
  447. {
  448. return info.Name;
  449. }
  450. return Path.GetFileNameWithoutExtension(info.FullName);
  451. }
  452. public string GetFileNameWithoutExtension(string path)
  453. {
  454. return Path.GetFileNameWithoutExtension(path);
  455. }
  456. public bool IsPathFile(string path)
  457. {
  458. if (string.IsNullOrWhiteSpace(path))
  459. {
  460. throw new ArgumentNullException("path");
  461. }
  462. // Cannot use Path.IsPathRooted because it returns false under mono when using windows-based paths, e.g. C:\\
  463. if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) != -1 &&
  464. !path.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
  465. {
  466. return false;
  467. }
  468. return true;
  469. //return Path.IsPathRooted(path);
  470. }
  471. public void DeleteFile(string path)
  472. {
  473. File.Delete(path);
  474. }
  475. public void DeleteDirectory(string path, bool recursive)
  476. {
  477. Directory.Delete(path, recursive);
  478. }
  479. public void CreateDirectory(string path)
  480. {
  481. Directory.CreateDirectory(path);
  482. }
  483. public IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false)
  484. {
  485. var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
  486. return ToMetadata(path, new DirectoryInfo(path).EnumerateDirectories("*", searchOption));
  487. }
  488. public IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false)
  489. {
  490. var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
  491. return ToMetadata(path, new DirectoryInfo(path).EnumerateFiles("*", searchOption));
  492. }
  493. public IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false)
  494. {
  495. var directoryInfo = new DirectoryInfo(path);
  496. var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
  497. if (EnableFileSystemRequestConcat)
  498. {
  499. return ToMetadata(path, directoryInfo.EnumerateDirectories("*", searchOption))
  500. .Concat(ToMetadata(path, directoryInfo.EnumerateFiles("*", searchOption)));
  501. }
  502. return ToMetadata(path, directoryInfo.EnumerateFileSystemInfos("*", searchOption));
  503. }
  504. private IEnumerable<FileSystemMetadata> ToMetadata(string parentPath, IEnumerable<FileSystemInfo> infos)
  505. {
  506. return infos.Select(i =>
  507. {
  508. try
  509. {
  510. return GetFileSystemMetadata(i);
  511. }
  512. catch (PathTooLongException)
  513. {
  514. // Can't log using the FullName because it will throw the PathTooLongExceptiona again
  515. //Logger.Warn("Path too long: {0}", i.FullName);
  516. Logger.Warn("File or directory path too long. Parent folder: {0}", parentPath);
  517. return null;
  518. }
  519. }).Where(i => i != null);
  520. }
  521. public Stream OpenRead(string path)
  522. {
  523. return File.OpenRead(path);
  524. }
  525. public void CopyFile(string source, string target, bool overwrite)
  526. {
  527. File.Copy(source, target, overwrite);
  528. }
  529. public void MoveFile(string source, string target)
  530. {
  531. File.Move(source, target);
  532. }
  533. public void MoveDirectory(string source, string target)
  534. {
  535. Directory.Move(source, target);
  536. }
  537. public bool DirectoryExists(string path)
  538. {
  539. return Directory.Exists(path);
  540. }
  541. public bool FileExists(string path)
  542. {
  543. return File.Exists(path);
  544. }
  545. public string ReadAllText(string path)
  546. {
  547. return File.ReadAllText(path);
  548. }
  549. public void WriteAllText(string path, string text, Encoding encoding)
  550. {
  551. File.WriteAllText(path, text, encoding);
  552. }
  553. public void WriteAllText(string path, string text)
  554. {
  555. File.WriteAllText(path, text);
  556. }
  557. public string ReadAllText(string path, Encoding encoding)
  558. {
  559. return File.ReadAllText(path, encoding);
  560. }
  561. public IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false)
  562. {
  563. var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
  564. return Directory.EnumerateDirectories(path, "*", searchOption);
  565. }
  566. public IEnumerable<string> GetFilePaths(string path, bool recursive = false)
  567. {
  568. var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
  569. return Directory.EnumerateFiles(path, "*", searchOption);
  570. }
  571. public IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false)
  572. {
  573. var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
  574. return Directory.EnumerateFileSystemEntries(path, "*", searchOption);
  575. }
  576. }
  577. }