Skip to content

Commit 026d42b

Browse files
committed
Merge branch 'multiple_file_perms' of https://github.com/hecksmosis/Files into rev_propmulti
2 parents 89bcf75 + b339799 commit 026d42b

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/Files.App/Helpers/CloudDrivesDetector.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Files.Shared/Cloud/CloudProviders.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public enum CloudProviders
1616
Jottacloud,
1717
SynologyDrive,
1818
pCloud,
19-
AdobeCreativeCloud
19+
AdobeCreativeCloud,
20+
Nutstore
2021
}
2122
}

0 commit comments

Comments
 (0)