// Kyoo - A portable and vast media library solution. // Copyright (c) Kyoo. // // See AUTHORS.md and LICENSE file in the project root for full license information. // // Kyoo is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // Kyoo is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Kyoo. If not, see . using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using JetBrains.Annotations; using Kyoo.Abstractions.Models; using Microsoft.AspNetCore.Mvc; namespace Kyoo.Abstractions.Controllers { /// /// A service to abstract the file system to allow custom file systems /// (like distant file systems or external providers). /// public interface IFileSystem { // TODO find a way to handle Transmux/Transcode with this system. /// /// Used for http queries returning a file. This should be used to return local files /// or proxy them from a distant server. /// /// /// If no file exists at the given path or if the path is null, a NotFoundResult is returned /// to handle it gracefully. /// /// The path of the file. /// /// Should the file be downloaded at once or is the client allowed to request only part of the file /// /// /// You can manually specify the content type of your file. /// For example you can force a file to be returned as plain text using text/plain. /// If the type is not specified, it will be deduced automatically (from the extension or by sniffing the file). /// /// An representing the file returned. public IActionResult FileResult([CanBeNull] string path, bool rangeSupport = false, string type = null); /// /// Read a file present at . The reader can be used in an arbitrary context. /// To return files from an http endpoint, use . /// /// The path of the file /// If the file could not be found. /// A reader to read the file. public Task GetReader([NotNull] string path); /// /// Read a file present at . The reader can be used in an arbitrary context. /// To return files from an http endpoint, use . /// /// The path of the file /// The mime type of the opened file. /// If the file could not be found. /// A reader to read the file. public Task GetReader([NotNull] string path, AsyncRef mime); /// /// Create a new file at . /// /// The path of the new file. /// A writer to write to the new file. public Task NewFile([NotNull] string path); /// /// Create a new directory at the given path /// /// The path of the directory /// The path of the newly created directory is returned. public Task CreateDirectory([NotNull] string path); /// /// Combine multiple paths. /// /// The paths to combine /// The combined path. public string Combine(params string[] paths); /// /// List files in a directory. /// /// The path of the directory /// Should the search be recursive or not. /// A list of files's path. public Task> ListFiles([NotNull] string path, SearchOption options = SearchOption.TopDirectoryOnly); /// /// Check if a file exists at the given path. /// /// The path to check /// True if the path exists, false otherwise public Task Exists([NotNull] string path); /// /// Get the extra directory of a resource . /// This method is in this system to allow a filesystem to use a different metadata policy for one. /// It can be useful if the filesystem is readonly. /// /// The resource to proceed /// The type of the resource. /// The extra directory of the resource. public Task GetExtraDirectory([NotNull] T resource); } }