fix abstraction project name (big oopsie!), rename master branch to main
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
namespace OpenHarbor.Storage.Abstractions;
|
||||
|
||||
public class FileAlreadyExistsException(string path) : Exception($"{path} already exists..");
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace OpenHarbor.Storage.Abstractions;
|
||||
|
||||
public class FileDoesNotExistException(string path) : Exception($"{path} does not exist.");
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace OpenHarbor.Storage.Abstractions;
|
||||
|
||||
public interface IDirectoryInfo: IDirectoryOrFile
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace OpenHarbor.Storage.Abstractions;
|
||||
|
||||
public interface IDirectoryOrFile
|
||||
{
|
||||
string Path { get; }
|
||||
bool IsDirectory { get; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace OpenHarbor.Storage.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.Storage.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.Storage.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>
|
||||
Reference in New Issue
Block a user