2022-01-23 17:30:05 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
|
|
2022-01-25 20:57:22 +00:00
|
|
|
|
namespace Image.Files
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2022-02-12 19:58:57 +00:00
|
|
|
|
/// LocalSystemFileBrowser reads files from the provided directory on the local system.
|
2022-01-23 17:30:05 +00:00
|
|
|
|
/// </summary>
|
2022-02-12 19:58:57 +00:00
|
|
|
|
public class LocalSystemFileBrowser : IFilesBrowser
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
|
|
|
|
public static ILogger Logger = NullLogger.Instance;
|
|
|
|
|
|
2022-02-12 19:58:57 +00:00
|
|
|
|
private LocalSystemFileBrowser()
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Give a directory path it returns all the filenames.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="directoryPath">An absolute path pointing to a directory.</param>
|
|
|
|
|
/// <returns>A list of file names found in the directory.</returns>
|
|
|
|
|
public IEnumerable<string> GetFilenamesFromPath(string directoryPath)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInformation($"Getting files from {directoryPath}.");
|
|
|
|
|
return Directory.GetFiles(directoryPath, "*.*");
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-12 19:58:57 +00:00
|
|
|
|
public static LocalSystemFileBrowser Create()
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
2022-02-12 19:58:57 +00:00
|
|
|
|
return new LocalSystemFileBrowser();
|
2022-01-23 17:30:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|