// Copyright (C) 2024, The Duplicati Team // https://duplicati.com, hello@duplicati.com // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. using System; using System.Collections.Generic; using System.IO; namespace Duplicati.Library.Snapshots { /// /// An interface for a snapshot implementation /// public interface ISnapshotService : IDisposable { /// /// Enumerates all files and folders in the snapshot, restricted to sources /// /// Sources to enumerate /// The callback to invoke with each found path /// The callback used to report errors IEnumerable EnumerateFilesAndFolders(IEnumerable sources, Utility.Utility.EnumerationFilterDelegate callback, Utility.Utility.ReportAccessError errorCallback); /// /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-snapshot format /// The last write time of the file DateTime GetLastWriteTimeUtc(string localPath); /// /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-snapshot format /// The last write time of the file DateTime GetCreationTimeUtc(string localPath); /// /// Opens a file for reading /// /// The full path to the file in non-snapshot format /// An open filestream that can be read and seeked Stream OpenRead(string localPath); /// /// Returns the size of a file /// /// The full path to the file in non-snapshot format /// The length of the file long GetFileSize(string localPath); /// /// Returns the symlink target if the entry is a symlink, and null otherwise /// /// The file or folder to examine /// The symlink target string GetSymlinkTarget(string localPath); /// /// Gets the attributes for the given file or folder /// /// The file attributes /// The file or folder to examine FileAttributes GetAttributes(string localPath); /// /// Gets the metadata for the given file or folder /// /// The metadata for the given file or folder /// The file or folder to examine /// A flag indicating if the target is a symlink /// A flag indicating if a symlink should be followed Dictionary GetMetadata(string localPath, bool isSymlink, bool followSymlink); /// /// Gets a value indicating if the path points to a block device /// /// true if this instance is a block device; otherwise, false. /// The file or folder to examine bool IsBlockDevice(string localPath); /// /// Gets a unique hardlink target ID /// /// The hardlink ID /// The file or folder to examine string HardlinkTargetID(string localPath); /// /// Converts a snapshot path to a local path /// /// The snapshot-local path /// The local path string ConvertToLocalPath(string snapshotPath); /// /// Converts a local path to a snapshot-local path /// /// The local path /// The snapshot path string ConvertToSnapshotPath(string localPath); /// /// Tests if a file exists in the snapshot /// /// The local path /// True if file exists, false otherwise bool FileExists(string localFilePath); /// /// Tests if a folder exists in the snapshot /// /// The local path /// True if folder exists, false otherwise bool DirectoryExists(string localFolderPath); /// /// Tests if a file or folder exists in the snapshot /// /// The local path /// True if file or folder exists, false otherwise bool PathExists(string localFileOrFolderPath); /// /// Is true if the actual service is a real snapshot service /// bool IsSnapshot { get; } } }