2019-01-13 19:54:44 +00:00
|
|
|
using System;
|
2018-09-12 17:26:21 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace Emby.Naming.Video
|
|
|
|
{
|
2020-11-10 18:23:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Object holding list of files paths with additional information.
|
|
|
|
/// </summary>
|
2018-09-12 17:26:21 +00:00
|
|
|
public class FileStack
|
|
|
|
{
|
2020-11-10 18:23:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="FileStack"/> class.
|
|
|
|
/// </summary>
|
2018-09-12 17:26:21 +00:00
|
|
|
public FileStack()
|
|
|
|
{
|
|
|
|
Files = new List<string>();
|
|
|
|
}
|
|
|
|
|
2020-11-10 18:23:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets name of file stack.
|
|
|
|
/// </summary>
|
2020-11-01 09:47:31 +00:00
|
|
|
public string Name { get; set; } = string.Empty;
|
2019-12-13 19:11:37 +00:00
|
|
|
|
2020-11-10 18:23:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets list of paths in stack.
|
|
|
|
/// </summary>
|
2019-12-13 19:11:37 +00:00
|
|
|
public List<string> Files { get; set; }
|
|
|
|
|
2020-11-10 18:23:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a value indicating whether stack is directory stack.
|
|
|
|
/// </summary>
|
2019-12-13 19:11:37 +00:00
|
|
|
public bool IsDirectoryStack { get; set; }
|
|
|
|
|
2020-11-10 18:23:10 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Helper function to determine if path is in the stack.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="file">Path of desired file.</param>
|
|
|
|
/// <param name="isDirectory">Requested type of stack.</param>
|
|
|
|
/// <returns>True if file is in the stack.</returns>
|
2019-05-10 18:37:42 +00:00
|
|
|
public bool ContainsFile(string file, bool isDirectory)
|
2018-09-12 17:26:21 +00:00
|
|
|
{
|
2021-12-07 14:18:17 +00:00
|
|
|
if (string.IsNullOrEmpty(file))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-10 18:37:42 +00:00
|
|
|
if (IsDirectoryStack == isDirectory)
|
2018-09-12 17:26:21 +00:00
|
|
|
{
|
|
|
|
return Files.Contains(file, StringComparer.OrdinalIgnoreCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|