From 3db86c3d8e6e88697af3d7e0a7c96a89c8227e9c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 23 Aug 2021 12:54:40 -0500 Subject: add List() to retrieve directory contents --- src/slskd/Application/SharedFileCache.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/slskd/Application/SharedFileCache.cs') diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index 049d80fe..c2200daf 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -238,6 +238,27 @@ namespace slskd } } + /// + /// Returns the contents of the specified . + /// + /// The directory for which the contents are to be listed. + /// The contents of the directory. + public Directory List(string directory) + { + var files = MaskedFiles.Where(f => f.Key.StartsWith(directory)).Select(kvp => + { + var f = kvp.Value; + return new File( + f.Code, + Path.GetFileName(f.Filename), + f.Size, + f.Extension, + f.Attributes); + }); + + return new Directory(directory, files); + } + /// /// Substitutes the mask in the specified with the original path, if the mask is tracked /// by the cache. -- cgit v1.2.3