/ src / modules / launcher / Plugins / Microsoft.Plugin.Folder / Sources / Path / DriveInformation.cs
DriveInformation.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using System.Collections.Generic;
 6  using System.Globalization;
 7  using System.IO.Abstractions;
 8  using System.Linq;
 9  
10  namespace Microsoft.Plugin.Folder.Sources
11  {
12      internal class DriveInformation : IDriveInformation
13      {
14          private static readonly IFileSystem _fileSystem = new FileSystem();
15          private static readonly List<string> DriverNames = InitialDriverList().ToList();
16  
17          private static IEnumerable<string> InitialDriverList()
18          {
19              // Using InvariantCulture since this is internal
20              var directorySeparatorChar = _fileSystem.Path.DirectorySeparatorChar;
21              return _fileSystem.DriveInfo.GetDrives()
22                  .Select(driver => driver.Name.ToLower(CultureInfo.InvariantCulture).TrimEnd(directorySeparatorChar));
23          }
24  
25          public IEnumerable<string> GetDriveNames() => DriverNames;
26      }
27  }