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-04-02 14:22:42 +00:00
|
|
|
|
namespace ConsoleInterface
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2022-02-12 20:12:57 +00:00
|
|
|
|
/// LocalFileBrowser reads files from the provided directory on the local system.
|
2022-01-23 17:30:05 +00:00
|
|
|
|
/// </summary>
|
2022-02-12 20:12:57 +00:00
|
|
|
|
public class LocalFileBrowser : IFileBrowser
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
|
|
|
|
public static ILogger Logger = NullLogger.Instance;
|
|
|
|
|
|
2022-02-12 20:12:57 +00:00
|
|
|
|
private LocalFileBrowser()
|
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 20:12:57 +00:00
|
|
|
|
public static LocalFileBrowser Create()
|
2022-01-23 17:30:05 +00:00
|
|
|
|
{
|
2022-02-12 20:12:57 +00:00
|
|
|
|
return new LocalFileBrowser();
|
2022-01-23 17:30:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|