// Copyright (C) 2025, 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. #nullable enable using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using Duplicati.Library.Common.IO; using Duplicati.Library.Interface; namespace Duplicati.Library.Snapshots.MacOS; /// /// Implements a subfolder within a MacOS Photos library export structure /// /// The library parent /// The subfolder path /// The child entries within the subfolder [SupportedOSPlatform("macOS")] internal class MacOSPhotoSubFolder(MacOSPhotosLibraryEntry parent, string subpath, IReadOnlyList children) : ISourceProviderEntry { /// public bool IsFolder => true; /// public bool IsMetaEntry => false; /// public bool IsRootEntry => false; /// public DateTime CreatedUtc => parent.CreatedUtc; /// public DateTime LastModificationUtc => parent.LastModificationUtc; /// public string Path => Util.AppendDirSeparator(SystemIO.IO_OS.PathCombine(parent.Path, subpath)); /// public long Size => -1; /// public bool IsSymlink => false; /// public string? SymlinkTarget => null; /// public FileAttributes Attributes => parent.Attributes; /// public bool IsBlockDevice => false; /// public bool IsCharacterDevice => false; /// public bool IsAlternateStream => false; /// public string? HardlinkTargetId => null; /// public IAsyncEnumerable Enumerate(CancellationToken cancellationToken) => children.ToAsyncEnumerable(); /// public Task FileExists(string filename, CancellationToken cancellationToken) { var fullpath = System.IO.Path.Combine(Path, filename); return Task.FromResult(children.Any(e => e.Path.Equals(fullpath, Utility.Utility.ClientFilenameStringComparison))); } /// public Task OpenRead(CancellationToken cancellationToken) => throw new InvalidOperationException("Cannot open a folder for reading"); public Task> GetMinorMetadata(CancellationToken cancellationToken) => Task.FromResult(new Dictionary()); }