mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[Peek] Open file in Read only (#25945)
* Only open FilStream in read-only mode; Release propertyStore handle after getting the file properties
(cherry picked from commit 3b1481da2c)
* Update calls to PropertyStoreHelper
* Add disposable property store
* Make GetPropertyStoreFromPath return Disposable property store
* correct typo
* correct typo
* Remove nullable in DisposablePropertyStore
* Add property getters
* Remove usued method
* Correct typo
* Correct typo again...
* Update description
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Peek.Common.Extensions;
|
||||
using Peek.Common.Helpers;
|
||||
using Windows.Storage;
|
||||
|
||||
@@ -15,18 +17,13 @@ namespace Peek.Common.Models
|
||||
{
|
||||
private StorageFile? storageFile;
|
||||
|
||||
private Lazy<IPropertyStore> _propertyStore;
|
||||
|
||||
public FileItem(string path)
|
||||
{
|
||||
Path = path;
|
||||
_propertyStore = new(() => PropertyStoreHelper.GetPropertyStoreFromPath(Path));
|
||||
}
|
||||
|
||||
public string Path { get; init; }
|
||||
|
||||
public IPropertyStore PropertyStore => _propertyStore.Value;
|
||||
|
||||
public async Task<IStorageItem?> GetStorageItemAsync()
|
||||
{
|
||||
return await GetStorageFileAsync();
|
||||
|
||||
Reference in New Issue
Block a user