@@ -14,6 +14,8 @@ namespace Files.App.Helpers
1414 [ SupportedOSPlatform ( "Windows10.0.10240" ) ]
1515 public class CloudDrivesDetector
1616 {
17+ private readonly static string programFilesFolder = Environment . GetEnvironmentVariable ( "ProgramFiles" ) ;
18+
1719 public static async Task < IEnumerable < ICloudProvider > > DetectCloudDrives ( )
1820 {
1921 var tasks = new Task < IEnumerable < ICloudProvider > > [ ]
@@ -23,6 +25,7 @@ public static async Task<IEnumerable<ICloudProvider>> DetectCloudDrives()
2325 SafetyExtensions . IgnoreExceptions ( DetectGenericCloudDrive , App . Logger ) ,
2426 SafetyExtensions . IgnoreExceptions ( DetectYandexDisk , App . Logger ) ,
2527 SafetyExtensions . IgnoreExceptions ( DetectpCloudDrive , App . Logger ) ,
28+ SafetyExtensions . IgnoreExceptions ( DetectNutstoreDrive , App . Logger ) ,
2629 } ;
2730
2831 await Task . WhenAll ( tasks ) ;
@@ -222,7 +225,7 @@ private static Task<IEnumerable<ICloudProvider>> DetectpCloudDrive()
222225 var syncedFolder = ( string ) pCloudDriveKey ? . GetValue ( "SyncDrive" ) ;
223226 if ( syncedFolder is not null )
224227 {
225- string iconPath = Path . Combine ( Environment . GetEnvironmentVariable ( "ProgramFiles" ) , "pCloud Drive" , "pCloud.exe" ) ;
228+ string iconPath = Path . Combine ( programFilesFolder , "pCloud Drive" , "pCloud.exe" ) ;
226229 var iconFile = Win32API . ExtractSelectedIconsFromDLL ( iconPath , new List < int > ( ) { 32512 } , 32 ) . FirstOrDefault ( ) ;
227230
228231 results . Add ( new CloudProvider ( CloudProviders . pCloud )
@@ -235,5 +238,36 @@ private static Task<IEnumerable<ICloudProvider>> DetectpCloudDrive()
235238
236239 return Task . FromResult < IEnumerable < ICloudProvider > > ( results ) ;
237240 }
241+
242+ private static Task < IEnumerable < ICloudProvider > > DetectNutstoreDrive ( )
243+ {
244+ var results = new List < ICloudProvider > ( ) ;
245+ using var NutstoreKey = Registry . CurrentUser . OpenSubKey ( @"SOFTWARE\Nutstore" ) ;
246+
247+ if ( NutstoreKey is not null )
248+ {
249+ string iconPath = Path . Combine ( programFilesFolder , "Nutstore" , "Nutstore.exe" ) ;
250+ var iconFile = Win32API . ExtractSelectedIconsFromDLL ( iconPath , new List < int > ( ) { 101 } ) . FirstOrDefault ( ) ;
251+
252+ // get every folder under the Nutstore folder in %userprofile%
253+ var mainFolder = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) , "Nutstore" ) ;
254+ var nutstoreFolders = Directory . GetDirectories ( mainFolder , "Nutstore" , SearchOption . AllDirectories ) ;
255+ foreach ( var nutstoreFolder in nutstoreFolders )
256+ {
257+ var folderName = Path . GetFileName ( nutstoreFolder ) ;
258+ if ( folderName is not null && folderName . StartsWith ( "Nutstore" , StringComparison . OrdinalIgnoreCase ) )
259+ {
260+ results . Add ( new CloudProvider ( CloudProviders . Nutstore )
261+ {
262+ Name = $ "Nutstore",
263+ SyncFolder = nutstoreFolder ,
264+ IconData = iconFile ? . IconData
265+ } ) ;
266+ }
267+ }
268+ }
269+
270+ return Task . FromResult < IEnumerable < ICloudProvider > > ( results ) ;
271+ }
238272 }
239273}
0 commit comments