using BITKit;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BITKit.IO
{
public interface IStorageProvider
{
///
/// Retrieves a file within the storage provider.
///
/// The relative path to the file within the storage provider.
/// The file.
/// If the file is not found.
Task GetFile(string path);
///
/// Lists the files within a storage provider's path.
///
/// The relative path to the folder which files to list.
/// The list of files in the folder.
Task> ListFiles(string path);
///
/// Lists the folders within a storage provider's path.
///
/// The relative path to the folder which folders to list.
/// The list of folders in the folder.
Task> ListFolders(string path);
///
/// Tries to create a folder in the storage provider.
///
/// The relative path to the folder to be created.
/// True if success; False otherwise.
Task TryCreateFolder(string path);
///
/// Creates a folder in the storage provider.
///
/// The relative path to the folder to be created.
/// If the folder already exists.
void CreateFolder(string path);
///
/// Deletes a folder in the storage provider.
///
/// The relative path to the folder to be deleted.
/// If the folder doesn't exist.
void DeleteFolder(string path);
///
/// Renames a folder in the storage provider.
///
/// The relative path to the folder to be renamed.
/// The relative path to the new folder.
void RenameFolder(string oldPath, string newPath);
///
/// Deletes a file in the storage provider.
///
/// The relative path to the file to be deleted.
/// If the file doesn't exist.
void DeleteFile(string path);
///
/// Renames a file in the storage provider.
///
/// The relative path to the file to be renamed.
/// The relative path to the new file.
void RenameFile(string oldPath, string newPath);
///
/// Creates a file in the storage provider.
///
/// The relative path to the file to be created.
/// If the file already exists.
/// The created file.
Task CreateFile(string path);
///
/// Tries to save a stream in the storage provider.
///
/// The relative path to the file to be created.
/// The stream to be saved.
/// True if success; False otherwise.
Task TrySaveStream(string path, Stream inputStream);
///
/// Saves a stream in the storage provider.
///
/// The relative path to the file to be created.
/// The stream to be saved.
/// If the stream can't be saved due to access permissions.
void SaveStream(string path, Stream inputStream);
///
/// Combines to paths.
///
/// The parent path.
/// The child path.
/// The combined path.
Task Combine(string path1, string path2);
Task FileExists(string path);
///
/// Gets or sets the default shared access expiration date.
///
///
/// The default shared access expiration date.
///
DateTimeOffset? DefaultSharedAccessExpiration { get; set; }
}
public abstract class StorageProvider : IStorageProvider
{
public DateTimeOffset? DefaultSharedAccessExpiration { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public abstract Task Combine(string path1, string path2);
public abstract Task CreateFile(string path);
public abstract void CreateFolder(string path);
public abstract void DeleteFile(string path);
public abstract void DeleteFolder(string path);
public abstract Task FileExists(string path);
public abstract Task GetFile(string path);
public abstract Task> ListFiles(string path);
public abstract Task> ListFolders(string path);
public abstract void RenameFile(string oldPath, string newPath);
public abstract void RenameFolder(string oldPath, string newPath);
public abstract void SaveStream(string path, Stream inputStream);
public abstract Task TryCreateFolder(string path);
public abstract Task TrySaveStream(string path, Stream inputStream);
}
}