/// <inheritdoc /> public async Task <IEntry> GetChildAsync(string name, CancellationToken ct) { if (name.StartsWith("._") || name == ".DS_Store") { return(null); } var engine = Program.BinsyncEngine; var next = _isRoot ? "" : System.Net.WebUtility.UrlDecode(this.Path.ToString()); if (next.Length > 0 && next.Substring(next.Length - 1, 1) == "/") { next = next.Substring(0, next.Length - 1); } //next = (_isRoot ? "" : (this.Path.ToString())).Trim('/'); //Console.WriteLine("next: " + next + ", name; " + name); var m = await engine.DownloadMetaForPath(next); if (m == null) { return(null); } foreach (var c in m.Commands) { if (c.FOLDER_ORIGIN == null) { throw new InvalidDataException("folder origin must be set"); } var n = c.FOLDER_ORIGIN?.Name; if (name != n) { continue; } var isFile = c.TYPE == Binsync.Core.Formats.MetaSegment.Command.TYPEV.FILE; if (isFile) { var fileSize = c.FOLDER_ORIGIN.FileSize; var newItem = new BinsyncFile(BinsyncFS, this, Path.Append(name, false), name, fileSize); return(newItem); } else { var coll = new BinsyncDirectory(BinsyncFS, this, Path.AppendDirectory(name), name) as ICollection; return(await coll.GetMountTargetAsync(BinsyncFS).ConfigureAwait(false)); } } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="BinsyncFileSystem"/> class. /// </summary> /// <param name="mountPoint">The mount point where this file system should be included</param> /// <param name="pathTraversalEngine">The engine to traverse paths</param> /// <param name="systemClock">Interface for the access to the systems clock</param> /// <param name="lockManager">The global lock manager</param> /// <param name="propertyStoreFactory">The store for dead properties</param> public BinsyncFileSystem( ICollection mountPoint, IPathTraversalEngine pathTraversalEngine, ISystemClock systemClock, ILockManager lockManager = null, IPropertyStoreFactory propertyStoreFactory = null) { SystemClock = systemClock; LockManager = lockManager; _pathTraversalEngine = pathTraversalEngine; var rootPath = mountPoint?.Path ?? new Uri(string.Empty, UriKind.Relative); RootCollection = new BinsyncDirectory(this, mountPoint, rootPath, mountPoint?.Name ?? rootPath.GetName(), true); Root = new AsyncLazy <ICollection>(() => Task.FromResult <ICollection>(RootCollection)); PropertyStore = propertyStoreFactory?.Create(this); }