Refractor a bunch of code, change projects names, update icon, upgrade to .net 8

This commit is contained in:
2024-11-10 16:57:24 -05:00
parent 72dfef9f9e
commit c0b8b92c21
41 changed files with 882 additions and 1076 deletions
@@ -0,0 +1,3 @@
namespace OpenHarbor.Abstractions;
public class FileAlreadyExistsException(string path) : Exception($"{path} already exists..");
@@ -0,0 +1,3 @@
namespace OpenHarbor.Abstractions;
public class FileDoesNotExistException(string path) : Exception($"{path} does not exist.");
+6
View File
@@ -0,0 +1,6 @@
namespace OpenHarbor.Abstractions;
public interface IDirectoryInfo: IDirectoryOrFile
{
}
@@ -0,0 +1,7 @@
namespace OpenHarbor.Abstractions;
public interface IDirectoryOrFile
{
string Path { get; }
bool IsDirectory { get; }
}
+14
View File
@@ -0,0 +1,14 @@
namespace OpenHarbor.Abstractions;
public interface IFileInfo : IDirectoryOrFile
{
string FileName { get; }
string Extension { get; }
long FileSize { get; }
DateTimeOffset? CreatedTime { get; }
DateTimeOffset? LastModifiedTime { get; }
DateTimeOffset? LastAccessTime { get; }
DateTime? CreatedTimeUtc { get; }
DateTime? LastModifiedTimeUtc { get; }
DateTime? LastAccessTimeUtc { get; }
}
@@ -0,0 +1,26 @@
using System.Text;
namespace OpenHarbor.Abstractions;
public interface IStorageProvider
{
Task<List<IDirectoryOrFile>> GetListAsync(string path, CancellationToken cancellationToken);
Task<List<IDirectoryInfo>> GetDirectoriesAsync(string path, CancellationToken cancellationToken);
Task<List<IFileInfo>> GetFilesAsync(string path, string? pattern = null, SearchOption searchOption = SearchOption.TopDirectoryOnly, CancellationToken cancellationToken = default);
Task<IFileInfo> WriteFileAsync(string sourcePath, string path, bool overrideIfExists = true, CancellationToken cancellationToken = default);
Task<IFileInfo> WriteFileAsync(byte[] bytes, string path, bool overrideIfExists = true, CancellationToken cancellationToken = default);
Task<IFileInfo> WriteFileAsync(Stream stream, string path, bool overrideIfExists = true, CancellationToken cancellationToken = default);
Task<IFileInfo> WriteFileAsync(string sourcePath, string path, IWriteFileOptions options, CancellationToken cancellationToken);
Task<IFileInfo> WriteFileAsync(byte[] bytes, string path, IWriteFileOptions options, CancellationToken cancellationToken);
Task<IFileInfo> WriteFileAsync(Stream stream, string path, IWriteFileOptions options, CancellationToken cancellationToken);
Task<Stream> GetFileStreamAsync(string path, CancellationToken cancellationToken);
Task<byte[]> GetFileBytesAsync(string path, CancellationToken cancellationToken);
Task<string> GetFileContentAsync(string path, Encoding encoding, CancellationToken cancellationToken);
Task<bool> FileExistsAsync(string path, CancellationToken cancellationToken);
Task DeleteFileAsync(string path, CancellationToken cancellationToken);
Task DeleteDirectoryAsync(string path, bool force = false, CancellationToken cancellationToken = default);
Task<IDirectoryInfo> CreateDirectoryAsync(string path, CancellationToken cancellationToken);
bool IsFileNameAllowed(string fileName);
string SanitizeFileName(string key, string replacement);
}
@@ -0,0 +1,11 @@
namespace OpenHarbor.Abstractions;
public interface IWriteFileOptions
{
bool OverrideIfExists { get; }
}
public class DefaultWriteOptions : IWriteFileOptions
{
public bool OverrideIfExists { get; set; }
}
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Company>Open Harbor</Company>
<PackageIconUrl>https://www.gravatar.com/avatar/9cecda5822fc5d4d2e61ec03da571b3d</PackageIconUrl>
</PropertyGroup>
</Project>