-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StorageFileHelper - Add GetFilesInDirectoryAsync #16341
base: master
Are you sure you want to change the base?
Conversation
@nickrandolph Can you confirm if you agree with the code? |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-16341/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-16341/index.html |
@jeromelaban one of the questions we had here is whether we can make StorageFileHelper public. We need to access it, so we can either make it public or internal, with internals access granted to the appropriate library. Thoughts? |
/// </summary> | ||
/// <param name="extensionsFilter">An array of strings representing the file extensions to filter the files.If null, all files in the directory are considered.</param> | ||
/// <returns>An array of strings containing the paths of the filtered files within the directory.</returns> | ||
public static async Task<string[]> GetFilesInDirectoryAsync(string[] extensionsFilter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Folder
instead of Directory
to preserve WinUI convention
I think |
What do you need from storage helper? |
@MartinZikmund / @jeromelaban any chance we can get someone to give @rafael-rosa-knowcode a had to finalise this PR. Currently we have a workaround for this but it would be preferrable to see it as part of Uno |
@morning4coffe-dev could you help? |
/// </summary> | ||
/// <param name="extensionsFilter">An array of strings representing the file extensions to filter the files.If null, all files in the directory are considered.</param> | ||
/// <returns>An array of strings containing the paths of the filtered files within the directory.</returns> | ||
public static async Task<string[]> GetFilesInDirectoryAsync(string[] extensionsFilter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafael-rosa-knowcode By the look of the implementation, it means that you want all the files that GetFileFromApplicationUriAsync
would provide. In this case, the method should be best called GetFilesFromApplicationAsync
.
{ | ||
List<string> assetsFiles = new(); | ||
string path = string.Empty; | ||
var executingPath = Assembly.GetExecutingAssembly().Location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely going to cause trouble when we'll run as a single file. Let's use the same APIs that:
uno/src/Uno.UWP/Storage/StorageFile.cs
Line 28 in 23feb21
public static IAsyncOperation<StorageFile> GetFileFromApplicationUriAsync(Uri uri) |
is using.
/// <returns>Returns an array of strings containing the paths of the filtered assets.</returns> | ||
private static Task<string[]> GetFilesInDirectory(Func<string, bool> predicate) | ||
{ | ||
string rootPath = AppDomain.CurrentDomain.BaseDirectory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let's use the same APIs that GetFileFromApplicationUriAsync
is using.
GitHub Issue (If applicable): closes #
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The StorageFileHelper just have one method for Determines if an asset or resource exists within application package.
But could be a nice feature to retrieves the paths of files within a directory.
What is the new behavior?
So this PR is for allow to retrieves the paths of files within a directory based on a specified filter for file extensions (If null, all files in the directory are considered.)
And the result is an array of strings containing the paths of the filtered files within the directory.
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Other information
Internal Issue (If applicable):