21
21
using static Files . App . Helpers . Win32PInvoke ;
22
22
using DispatcherQueue = Microsoft . UI . Dispatching . DispatcherQueue ;
23
23
using FileAttributes = System . IO . FileAttributes ;
24
+ using ByteSize = ByteSizeLib . ByteSize ;
25
+ using Windows . Win32 . System . SystemServices ;
24
26
25
27
namespace Files . App . ViewModels
26
28
{
@@ -1209,6 +1211,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
1209
1211
var fileFRN = await FileTagsHelper . GetFileFRN ( matchingStorageFolder ) ;
1210
1212
var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
1211
1213
var itemType = ( item . ItemType == Strings . Folder . GetLocalizedResource ( ) ) ? item . ItemType : matchingStorageFolder . DisplayType ;
1214
+ var extraProperties = await GetExtraProperties ( matchingStorageFolder ) ;
1212
1215
1213
1216
cts . Token . ThrowIfCancellationRequested ( ) ;
1214
1217
@@ -1219,7 +1222,30 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
1219
1222
item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
1220
1223
item . FileFRN = fileFRN ;
1221
1224
item . FileTags = fileTag ;
1222
- item . ContextualProperty = $ "{ Strings . Modified . GetLocalizedResource ( ) } : { item . ItemDateModified } ";
1225
+
1226
+ if ( extraProperties is not null )
1227
+ {
1228
+ // Drive Storage Details
1229
+ if ( extraProperties . Result [ "System.SFGAOFlags" ] is uint attributesRaw &&
1230
+ extraProperties . Result [ "System.Capacity" ] is ulong capacityRaw &&
1231
+ extraProperties . Result [ "System.FreeSpace" ] is ulong freeSpaceRaw &&
1232
+ ( ( SFGAO_FLAGS ) attributesRaw ) . HasFlag ( SFGAO_FLAGS . SFGAO_REMOVABLE ) &&
1233
+ ! ( ( SFGAO_FLAGS ) attributesRaw ) . HasFlag ( SFGAO_FLAGS . SFGAO_FILESYSTEM ) )
1234
+ {
1235
+ var maxSpace = ByteSize . FromBytes ( capacityRaw ) ;
1236
+ var freeSpace = ByteSize . FromBytes ( freeSpaceRaw ) ;
1237
+
1238
+ item . MaxSpace = maxSpace ;
1239
+ item . SpaceUsed = maxSpace - freeSpace ;
1240
+ item . FileSize = string . Format ( Strings . DriveFreeSpaceAndCapacity . GetLocalizedResource ( ) , freeSpace . ToSizeString ( ) , maxSpace . ToSizeString ( ) ) ;
1241
+ item . ShowDriveStorageDetails = true ;
1242
+ }
1243
+
1244
+ }
1245
+ else
1246
+ {
1247
+ item . ContextualProperty = $ "{ Strings . Modified . GetLocalizedResource ( ) } : { item . ItemDateModified } ";
1248
+ }
1223
1249
} ,
1224
1250
Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
1225
1251
@@ -1937,6 +1963,9 @@ public async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageI
1937
1963
if ( matchingStorageItem is BaseStorageFile file && file . Properties != null )
1938
1964
return await FilesystemTasks . Wrap ( ( ) => file . Properties . RetrievePropertiesAsync ( [ "System.Image.Dimensions" , "System.Media.Duration" , "System.FileVersion" ] ) . AsTask ( ) ) ;
1939
1965
1966
+ else if ( matchingStorageItem is BaseStorageFolder folder && folder . Properties != null )
1967
+ return await FilesystemTasks . Wrap ( ( ) => folder . Properties . RetrievePropertiesAsync ( [ "System.FreeSpace" , "System.Capacity" , "System.SFGAOFlags" ] ) . AsTask ( ) ) ;
1968
+
1940
1969
return null ;
1941
1970
}
1942
1971
0 commit comments