| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using Jellyfin.Extensions; |
| | 4 | |
|
| | 5 | | namespace Emby.Naming.Video |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// Object holding list of files paths with additional information. |
| | 9 | | /// </summary> |
| | 10 | | public class FileStack |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Initializes a new instance of the <see cref="FileStack"/> class. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="name">The stack name.</param> |
| | 16 | | /// <param name="isDirectory">Whether the stack files are directories.</param> |
| | 17 | | /// <param name="files">The stack files.</param> |
| | 18 | | public FileStack(string name, bool isDirectory, IReadOnlyList<string> files) |
| | 19 | | { |
| | 20 | | Name = name; |
| | 21 | | IsDirectoryStack = isDirectory; |
| | 22 | | Files = files; |
| 58 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Gets the name of file stack. |
| | 27 | | /// </summary> |
| | 28 | | public string Name { get; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Gets the list of paths in stack. |
| | 32 | | /// </summary> |
| | 33 | | public IReadOnlyList<string> Files { get; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Gets a value indicating whether stack is directory stack. |
| | 37 | | /// </summary> |
| | 38 | | public bool IsDirectoryStack { get; } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Helper function to determine if path is in the stack. |
| | 42 | | /// </summary> |
| | 43 | | /// <param name="file">Path of desired file.</param> |
| | 44 | | /// <param name="isDirectory">Requested type of stack.</param> |
| | 45 | | /// <returns>True if file is in the stack.</returns> |
| | 46 | | public bool ContainsFile(string file, bool isDirectory) |
| | 47 | | { |
| 42 | 48 | | if (string.IsNullOrEmpty(file)) |
| | 49 | | { |
| 0 | 50 | | return false; |
| | 51 | | } |
| | 52 | |
|
| 42 | 53 | | return IsDirectoryStack == isDirectory && Files.Contains(file, StringComparison.OrdinalIgnoreCase); |
| | 54 | | } |
| | 55 | | } |
| | 56 | | } |