WindowsDynamicVolumeHelper.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace DiskAccessLibrary.LogicalDiskManager
  12. {
  13. public class WindowsDynamicVolumeHelper
  14. {
  15. public static List<DynamicVolume> GetDynamicVolumes()
  16. {
  17. List<DynamicDisk> disks = WindowsDynamicDiskHelper.GetPhysicalDynamicDisks();
  18. return DynamicVolumeHelper.GetDynamicVolumes(disks);
  19. }
  20. public static List<DynamicVolume> GetLockableDynamicVolumes(List<DynamicDisk> dynamicDisks)
  21. {
  22. List<DynamicVolume> result = new List<DynamicVolume>();
  23. List<DynamicDisk> disks = new List<DynamicDisk>();
  24. foreach (DynamicDisk dynamicDisk in dynamicDisks)
  25. {
  26. if (dynamicDisk.Disk is PhysicalDisk)
  27. {
  28. disks.Add(dynamicDisk);
  29. }
  30. }
  31. List<DynamicVolume> dynamicVolumes = DynamicVolumeHelper.GetDynamicVolumes(disks);
  32. for (int index = 0; index < dynamicVolumes.Count; index++)
  33. {
  34. // non-operational volumes cannot be locked
  35. if (!dynamicVolumes[index].IsOperational)
  36. {
  37. dynamicVolumes.RemoveAt(index);
  38. index--;
  39. }
  40. }
  41. return dynamicVolumes;
  42. }
  43. }
  44. }