1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using DiskAccessLibrary.LogicalDiskManager;
- using Utilities;
- namespace DiskAccessLibrary
- {
- public class WindowsDynamicVolumeHelper
- {
- public static List<DynamicVolume> GetDynamicVolumes()
- {
- List<DynamicDisk> disks = WindowsDynamicDiskHelper.GetPhysicalDynamicDisks();
- return DynamicVolumeHelper.GetDynamicVolumes(disks);
- }
- public static List<DynamicVolume> GetLockableDynamicVolumes(List<DynamicDisk> dynamicDisks)
- {
- List<DynamicVolume> result = new List<DynamicVolume>();
- List<DynamicDisk> disks = new List<DynamicDisk>();
- foreach (DynamicDisk dynamicDisk in dynamicDisks)
- {
- if (dynamicDisk.Disk is PhysicalDisk)
- {
- disks.Add(dynamicDisk);
- }
- }
- return DynamicVolumeHelper.GetDynamicVolumes(disks);
- }
- public static bool LockAllMountedOrNone(List<DynamicVolume> volumes)
- {
- bool success = true;
- int lockIndex;
- for (lockIndex = 0; lockIndex < volumes.Count; lockIndex++)
- {
-
- success = WindowsVolumeManager.ExclusiveLockIfMounted(volumes[lockIndex].VolumeGuid);
- if (!success)
- {
- break;
- }
- }
- if (!success)
- {
-
- for (int index = 0; index < lockIndex; index++)
- {
- WindowsVolumeManager.ReleaseLock(volumes[index].VolumeGuid);
- }
- }
- return success;
- }
- }
- }
|