diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-08-23 12:54:40 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-08-23 12:54:40 -0500 |
| commit | 3db86c3d8e6e88697af3d7e0a7c96a89c8227e9c (patch) | |
| tree | 9aee34cb70c493729713429796bfe4f8c3557165 /src/slskd/Application/SharedFileCache.cs | |
| parent | cd564c0df2fd55803a193efe3fa67f850426406f (diff) | |
| download | slskd-3db86c3d8e6e88697af3d7e0a7c96a89c8227e9c.tar.gz | |
add List() to retrieve directory contents
Diffstat (limited to 'src/slskd/Application/SharedFileCache.cs')
| -rw-r--r-- | src/slskd/Application/SharedFileCache.cs | 21 |
1 files changed, 21 insertions, 0 deletions
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 @@ -239,6 +239,27 @@ namespace slskd } /// <summary> + /// Returns the contents of the specified <paramref name="directory"/>. + /// </summary> + /// <param name="directory">The directory for which the contents are to be listed.</param> + /// <returns>The contents of the directory.</returns> + 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); + } + + /// <summary> /// Substitutes the mask in the specified <paramref name="filename"/> with the original path, if the mask is tracked /// by the cache. /// </summary> |
