2121using static Files . App . Helpers . Win32PInvoke ;
2222using DispatcherQueue = Microsoft . UI . Dispatching . DispatcherQueue ;
2323using FileAttributes = System . IO . FileAttributes ;
24+ using ByteSize = ByteSizeLib . ByteSize ;
25+ using Windows . Win32 . System . SystemServices ;
2426
2527namespace Files . App . ViewModels
2628{
@@ -1209,6 +1211,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
12091211 var fileFRN = await FileTagsHelper . GetFileFRN ( matchingStorageFolder ) ;
12101212 var fileTag = FileTagsHelper . ReadFileTag ( item . ItemPath ) ;
12111213 var itemType = ( item . ItemType == Strings . Folder . GetLocalizedResource ( ) ) ? item . ItemType : matchingStorageFolder . DisplayType ;
1214+ var extraProperties = await GetExtraProperties ( matchingStorageFolder ) ;
12121215
12131216 cts . Token . ThrowIfCancellationRequested ( ) ;
12141217
@@ -1219,7 +1222,30 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
12191222 item . SyncStatusUI = CloudDriveSyncStatusUI . FromCloudDriveSyncStatus ( syncStatus ) ;
12201223 item . FileFRN = fileFRN ;
12211224 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+ }
12231249 } ,
12241250 Microsoft . UI . Dispatching . DispatcherQueuePriority . Low ) ;
12251251
@@ -1937,6 +1963,9 @@ public async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageI
19371963 if ( matchingStorageItem is BaseStorageFile file && file . Properties != null )
19381964 return await FilesystemTasks . Wrap ( ( ) => file . Properties . RetrievePropertiesAsync ( [ "System.Image.Dimensions" , "System.Media.Duration" , "System.FileVersion" ] ) . AsTask ( ) ) ;
19391965
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+
19401969 return null ;
19411970 }
19421971
0 commit comments