2019-01-13 12:54:44 -07:00
|
|
|
using System;
|
2018-09-12 10:26:21 -07:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace Emby.Naming.Video
|
|
|
|
{
|
2020-11-10 11:23:10 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Object holding list of files paths with additional information.
|
|
|
|
/// </summary>
|
2018-09-12 10:26:21 -07:00
|
|
|
public class FileStack
|
|
|
|
{
|
2020-11-10 11:23:10 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="FileStack"/> class.
|
|
|
|
/// </summary>
|
2018-09-12 10:26:21 -07:00
|
|
|
public FileStack()
|
|
|
|
{
|
|
|
|
Files = new List<string>();
|
|
|
|
}
|
|
|
|
|
2020-11-10 11:23:10 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets name of file stack.
|
|
|
|
/// </summary>
|
2020-11-01 02:47:31 -07:00
|
|
|
public string Name { get; set; } = string.Empty;
|
2019-12-13 12:11:37 -07:00
|
|
|
|
2020-11-10 11:23:10 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets list of paths in stack.
|
|
|
|
/// </summary>
|
2019-12-13 12:11:37 -07:00
|
|
|
public List<string> Files { get; set; }
|
|
|
|
|
2020-11-10 11:23:10 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a value indicating whether stack is directory stack.
|
|
|
|
/// </summary>
|
2019-12-13 12:11:37 -07:00
|
|
|
public bool IsDirectoryStack { get; set; }
|
|
|
|
|
2020-11-10 11:23:10 -07: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 11:37:42 -07:00
|
|
|
public bool ContainsFile(string file, bool isDirectory)
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
2019-05-10 11:37:42 -07:00
|
|
|
if (IsDirectoryStack == isDirectory)
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
|
|
|
return Files.Contains(file, StringComparer.OrdinalIgnoreCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|