diff --git a/AlphaFS.Doc/AlphaFS.Doc.shfbproj b/AlphaFS.Doc/AlphaFS.Doc.shfbproj
index 65553abdc..f34370faf 100644
--- a/AlphaFS.Doc/AlphaFS.Doc.shfbproj
+++ b/AlphaFS.Doc/AlphaFS.Doc.shfbproj
@@ -39,8 +39,8 @@
Standard2.2
-
-
+
+ https://github.com/alphaleonis/AlphaFS/False
@@ -49,11 +49,11 @@
The Filesystem namespace contains classes to access and work with the local filesystem. Many of the classes in this namespace are replicas of the ones available in the System.IO namespace, but with added functionality. All methods in this namespace accept long windows unicode paths (i.e. paths starting with <c>\\?\</c>).
Additional classes and methods are provided to provide more advanced functionality than that of System.IO.
- This namespace contains classes directly related to security such as authentication, authorization and privilege tokens that may be needed for some file operations. For an example the SE_SECURITY_NAME privilege needs to be held to be able to modify the SACL of any file.
-
- This namespace contains general classes related to the Win32 Api.
- This namespace contains network related classes.
-
+This namespace contains classes directly related to security such as authentication, authorization and privilege tokens that may be needed for some file operations. For an example the SE_SECURITY_NAME privilege needs to be held to be able to modify the SACL of any file.
+
+This namespace contains general classes related to the Win32 Api.
+The Network namespace contains network related classes.
+The Device namespace contains device related classes.HtmlHelp1, Website
diff --git a/AlphaFS.UnitTest/AlphaFS BackupFileStream Class/AlphaFS_BackupFileStream_InitializeInstance.cs b/AlphaFS.UnitTest/AlphaFS BackupFileStream Class/AlphaFS_BackupFileStream_CreateInstance.cs
similarity index 87%
rename from AlphaFS.UnitTest/AlphaFS BackupFileStream Class/AlphaFS_BackupFileStream_InitializeInstance.cs
rename to AlphaFS.UnitTest/AlphaFS BackupFileStream Class/AlphaFS_BackupFileStream_CreateInstance.cs
index 695215841..911cca85b 100644
--- a/AlphaFS.UnitTest/AlphaFS BackupFileStream Class/AlphaFS_BackupFileStream_InitializeInstance.cs
+++ b/AlphaFS.UnitTest/AlphaFS BackupFileStream Class/AlphaFS_BackupFileStream_CreateInstance.cs
@@ -30,14 +30,14 @@ public partial class AlphaFS_BackupFileStreamTest
[TestMethod]
- public void AlphaFS_BackupFileStream_InitializeInstance_LocalAndNetwork_Success()
+ public void AlphaFS_BackupFileStream_CreateInstance_LocalAndNetwork_Success()
{
- AlphaFS_BackupFileStream_InitializeInstance(false);
- AlphaFS_BackupFileStream_InitializeInstance(true);
+ AlphaFS_BackupFileStream_CreateInstance_(false);
+ AlphaFS_BackupFileStream_CreateInstance_(true);
}
- private void AlphaFS_BackupFileStream_InitializeInstance(bool isNetwork)
+ private void AlphaFS_BackupFileStream_CreateInstance_(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_Device.EnumeratePhysicalDisks_ReturnsStorageDeviceInfoForDevice.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_Device.EnumeratePhysicalDisks_ReturnsStorageDeviceInfoForDevice.cs
new file mode 100644
index 000000000..ed1b6c250
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_Device.EnumeratePhysicalDisks_ReturnsStorageDeviceInfoForDevice.cs
@@ -0,0 +1,125 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ public partial class EnumerationTest
+ {
+ // Pattern: ___
+
+
+ [TestMethod]
+ public void AlphaFS_Device_EnumeratePhysicalDisks_ReturnsStorageDeviceInfoForDevice()
+ {
+ UnitTestConstants.PrintUnitTestHeader(false);
+
+ var driveCount = 0;
+
+ var physicalDrives = Alphaleonis.Win32.Filesystem.Volume.QueryAllDosDevices().Where(device => device.StartsWith("PhysicalDrive", StringComparison.OrdinalIgnoreCase)).ToArray();
+
+ var cdRoms = Alphaleonis.Win32.Filesystem.Volume.QueryAllDosDevices().Where(device => device.StartsWith("CdRom", StringComparison.OrdinalIgnoreCase)).ToArray();
+
+ var pDrives = Alphaleonis.Win32.Device.Local.EnumeratePhysicalDisks().OrderBy(pDiskInfo => pDiskInfo.StorageDeviceInfo.DeviceNumber).ThenByDescending(pDiskInfo => pDiskInfo.StorageDeviceInfo.PartitionNumber).ToArray();
+
+ var allPhysicalDrives = physicalDrives.Length + cdRoms.Length;
+
+
+ Console.WriteLine("Found: [{0}] physical drives.\n", allPhysicalDrives);
+
+ Assert.AreEqual(allPhysicalDrives, pDrives.Length);
+
+
+ foreach (var pDiskInfo in pDrives)
+ {
+ Console.WriteLine("#{0:000}\tPhysical Disk: [{1}]", driveCount, pDiskInfo.StorageDeviceInfo.DeviceNumber);
+
+ UnitTestConstants.Dump(pDiskInfo);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageAdapterInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageDeviceInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StoragePartitionInfo, true);
+
+
+ Assert.IsNotNull(pDiskInfo);
+
+ Assert.IsNotNull(pDiskInfo.LogicalDrives);
+
+ Assert.IsNotNull(pDiskInfo.VolumeGuids);
+
+
+ // DosDeviceName should be the same for device.
+
+ Assert.AreEqual(pDiskInfo.DosDeviceName, pDiskInfo.PhysicalDeviceObjectName);
+
+
+ // PartitionNumber should be 0 for logical drive on dynamic disk.
+
+ if (pDiskInfo.StoragePartitionInfo.OnDynamicDisk)
+ Assert.AreNotEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+ else
+ {
+ // PartitionNumber should be -1 for CDRom.
+
+ if (pDiskInfo.StorageDeviceInfo.DeviceType == Alphaleonis.Win32.Device.DeviceType.CDRom)
+ Assert.AreEqual(-1, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+ // PartitionNumber should be > 0 for logical drive because it is not the device.
+ else
+ Assert.AreEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+ }
+
+
+ // TotalSize depends on dynamic disk on device.
+
+ if (pDiskInfo.StoragePartitionInfo.OnDynamicDisk)
+ Assert.AreNotEqual(pDiskInfo.StorageDeviceInfo.TotalSize, pDiskInfo.StoragePartitionInfo.TotalSize);
+ else
+ Assert.AreEqual(pDiskInfo.StorageDeviceInfo.TotalSize, pDiskInfo.StoragePartitionInfo.TotalSize);
+
+
+ // Show all partition information.
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+
+ driveCount++;
+
+ Console.WriteLine();
+ }
+
+
+ Assert.IsTrue(driveCount > 0, "No physical disks enumerated, but it is expected.");
+ }
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingDevicePathFromSystemDrive_ReturnsStorageDeviceInfoForDevice.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingDevicePathFromSystemDrive_ReturnsStorageDeviceInfoForDevice.cs
new file mode 100644
index 000000000..3ad49349b
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingDevicePathFromSystemDrive_ReturnsStorageDeviceInfoForDevice.cs
@@ -0,0 +1,108 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ public partial class AlphaFS_PhysicalDiskInfoTest
+ {
+ // Pattern: ___
+
+
+ [TestMethod]
+ public void AlphaFS_PhysicalDiskInfo_CreateInstance_UsingDevicePathFromSystemDrive_ReturnsStorageDeviceInfoForDevice()
+ {
+ UnitTestConstants.PrintUnitTestHeader(false);
+
+ var deviceCount = 0;
+
+ var sourceDrive = UnitTestConstants.SysDrive;
+
+ var sourceVolume = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(sourceDrive);
+
+ var devicePath = new Alphaleonis.Win32.Device.PhysicalDiskInfo(sourceDrive).DevicePath;
+
+ Console.WriteLine("#{0:000}\tInput Device Path: [{1}]", ++deviceCount, devicePath);
+
+
+ var pDiskInfo = new Alphaleonis.Win32.Device.PhysicalDiskInfo(devicePath);
+
+
+ UnitTestConstants.Dump(pDiskInfo);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageAdapterInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageDeviceInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StoragePartitionInfo, true);
+
+
+ Assert.IsNotNull(pDiskInfo);
+
+ Assert.IsNotNull(pDiskInfo.LogicalDrives);
+
+ Assert.IsNotNull(pDiskInfo.VolumeGuids);
+
+
+ // DosDeviceName should be the same for device.
+
+ Assert.AreEqual(pDiskInfo.DosDeviceName, pDiskInfo.PhysicalDeviceObjectName);
+
+ // PartitionNumber should be 0 for device.
+
+ Assert.AreEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+
+ // TotalSize should always match for device.
+
+ Assert.AreEqual(pDiskInfo.StorageDeviceInfo.TotalSize, pDiskInfo.StoragePartitionInfo.TotalSize);
+
+
+ // ContainsVolume should find volumes/logical drives.
+
+ Assert.IsTrue(pDiskInfo.LogicalDrives.Contains(sourceDrive, StringComparer.OrdinalIgnoreCase));
+
+ Assert.IsTrue(pDiskInfo.ContainsVolume(sourceDrive));
+
+
+ Assert.IsTrue(pDiskInfo.VolumeGuids.Contains(sourceVolume, StringComparer.OrdinalIgnoreCase));
+
+ Assert.IsTrue(pDiskInfo.ContainsVolume(sourceVolume));
+
+
+ // Show all partition information.
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+
+ Console.WriteLine();
+ }
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingLogicalDrivePath_ReturnsStorageDeviceInfoForVolume.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingLogicalDrivePath_ReturnsStorageDeviceInfoForVolume.cs
new file mode 100644
index 000000000..55763c6b0
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingLogicalDrivePath_ReturnsStorageDeviceInfoForVolume.cs
@@ -0,0 +1,117 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ public partial class AlphaFS_PhysicalDiskInfoTest
+ {
+ // Pattern: ___
+
+
+ [TestMethod]
+ public void AlphaFS_PhysicalDiskInfo_CreateInstance_UsingLogicalDrivePath_ReturnsStorageDeviceInfoForVolume()
+ {
+ UnitTestConstants.PrintUnitTestHeader(false);
+
+ var driveCount = 0;
+ Alphaleonis.Win32.Device.PhysicalDiskInfo prevDiskInfo = null;
+
+ foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
+ {
+ // System.UnauthorizedAccessException: (5) Access is denied.
+ if (driveInfo.DriveType == System.IO.DriveType.Network)
+ {
+ Console.WriteLine("#{0:000}\tSkipped Network drive: [{1}]\n", ++driveCount, driveInfo.Name);
+ continue;
+ }
+
+ if (driveInfo.DriveType == System.IO.DriveType.NoRootDirectory)
+ {
+ Console.WriteLine("#{0:000}\tSkipped NoRootDirectory drive: [{1}]\n", ++driveCount, driveInfo.Name);
+ continue;
+ }
+
+
+ Console.WriteLine("#{0:000}\tInput Logical Drive Path: [{1}]", ++driveCount, driveInfo.Name);
+
+
+ var pDiskInfo = new Alphaleonis.Win32.Device.PhysicalDiskInfo(driveInfo.Name);
+
+ Assert.AreNotEqual(prevDiskInfo, pDiskInfo);
+
+ prevDiskInfo = pDiskInfo;
+
+
+ UnitTestConstants.Dump(pDiskInfo);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageAdapterInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageDeviceInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StoragePartitionInfo, true);
+
+
+ Assert.IsNotNull(pDiskInfo);
+
+ Assert.IsNotNull(pDiskInfo.LogicalDrives);
+
+ Assert.IsNotNull(pDiskInfo.VolumeGuids);
+
+
+ // DosDeviceName should be different for logical drive.
+
+ Assert.AreNotEqual(pDiskInfo.DosDeviceName, pDiskInfo.PhysicalDeviceObjectName);
+
+
+ // PartitionNumber should be -1 for CDRom.
+
+ if (pDiskInfo.StorageDeviceInfo.DeviceType == Alphaleonis.Win32.Device.DeviceType.CDRom)
+ Assert.AreEqual(-1, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+ // PartitionNumber should be > 0 for logical drive because it is not the device.
+ else
+ Assert.AreNotEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+
+ Assert.AreEqual(pDiskInfo.StorageDeviceInfo.DeviceNumber, pDiskInfo.StorageAdapterInfo.DeviceNumber);
+
+ Assert.AreEqual(pDiskInfo.StorageDeviceInfo.DeviceNumber, pDiskInfo.StoragePartitionInfo.DeviceNumber);
+
+
+ // Show all partition information.
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+
+ Console.WriteLine();
+ }
+ }
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingPhysicalDriveNumber_ReturnsStorageDeviceInfoForDevice.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingPhysicalDriveNumber_ReturnsStorageDeviceInfoForDevice.cs
new file mode 100644
index 000000000..cb6346321
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingPhysicalDriveNumber_ReturnsStorageDeviceInfoForDevice.cs
@@ -0,0 +1,120 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Globalization;
+
+namespace AlphaFS.UnitTest
+{
+ public partial class AlphaFS_PhysicalDiskInfoTest
+ {
+ // Pattern: ___
+
+
+ [TestMethod]
+ public void AlphaFS_PhysicalDiskInfo_CreateInstance_UsingPhysicalDriveNumber_ReturnsStorageDeviceInfoForDevice()
+ {
+ UnitTestConstants.PrintUnitTestHeader(false);
+
+ var physicalDisks = Alphaleonis.Win32.Filesystem.Volume.QueryAllDosDevices().Where(device => device.StartsWith("PhysicalDrive", StringComparison.OrdinalIgnoreCase)).ToArray();
+
+ Console.WriteLine("Found: [{0}] physical drives.\n", physicalDisks.Length);
+
+
+ for (var physicalDiskNumber = 0; physicalDiskNumber < physicalDisks.Length; physicalDiskNumber++)
+ {
+ Console.WriteLine("#{0:000}\tInput Physical Disk Path: [{1}{2}]", physicalDiskNumber + 1, Alphaleonis.Win32.Filesystem.Path.PhysicalDrivePrefix, physicalDiskNumber);
+
+ var pDiskInfo = new Alphaleonis.Win32.Device.PhysicalDiskInfo(physicalDiskNumber);
+
+ UnitTestConstants.Dump(pDiskInfo);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageAdapterInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageDeviceInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StoragePartitionInfo, true);
+
+
+ Assert.IsNotNull(pDiskInfo);
+
+ Assert.IsNotNull(pDiskInfo.LogicalDrives);
+
+ Assert.IsNotNull(pDiskInfo.VolumeGuids);
+
+
+ // DosDeviceName should contain "X\DR" for device.
+
+ Assert.IsTrue(pDiskInfo.DosDeviceName.Contains(string.Format(CultureInfo.InvariantCulture, @"{0}\DR", physicalDiskNumber)));
+
+
+ // PartitionNumber should be 0 for device on dynamic disk.
+
+ if (pDiskInfo.StoragePartitionInfo.OnDynamicDisk)
+ Assert.AreNotEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+ else
+ {
+ // PartitionNumber should be -1 for CDRom.
+
+ if (pDiskInfo.StorageDeviceInfo.DeviceType == Alphaleonis.Win32.Device.DeviceType.CDRom)
+ Assert.AreEqual(-1, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+ // PartitionNumber should be 0 for device.
+ else
+ Assert.AreEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+ }
+
+
+ // TotalSize depends on dynamic disk on device.
+
+ if (pDiskInfo.StoragePartitionInfo.OnDynamicDisk)
+ Assert.AreNotEqual(pDiskInfo.StorageDeviceInfo.TotalSize, pDiskInfo.StoragePartitionInfo.TotalSize);
+ else
+ Assert.AreEqual(pDiskInfo.StorageDeviceInfo.TotalSize, pDiskInfo.StoragePartitionInfo.TotalSize);
+
+
+
+ Assert.AreEqual(physicalDiskNumber, pDiskInfo.StorageAdapterInfo.DeviceNumber);
+
+ Assert.AreEqual(physicalDiskNumber, pDiskInfo.StorageDeviceInfo.DeviceNumber);
+
+ Assert.AreEqual(physicalDiskNumber, pDiskInfo.StoragePartitionInfo.DeviceNumber);
+
+
+ // Show all partition information.
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+
+ Console.WriteLine();
+ }
+ }
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingVolumePathFromSystemDrive_ReturnsStorageDeviceInfoForVolume.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingVolumePathFromSystemDrive_ReturnsStorageDeviceInfoForVolume.cs
new file mode 100644
index 000000000..94a7fc7ed
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfo.CreateInstance_UsingVolumePathFromSystemDrive_ReturnsStorageDeviceInfoForVolume.cs
@@ -0,0 +1,102 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ public partial class AlphaFS_PhysicalDiskInfoTest
+ {
+ // Pattern: ___
+
+
+ [TestMethod]
+ public void AlphaFS_PhysicalDiskInfo_CreateInstance_UsingVolumePathFromSystemDrive_ReturnsStorageDeviceInfoForVolume()
+ {
+ UnitTestConstants.PrintUnitTestHeader(false);
+
+ var volumeCount = 0;
+
+ var sourceDrive = UnitTestConstants.SysDrive;
+
+ var sourceVolume = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(sourceDrive);
+
+ Console.WriteLine("#{0:000}\tInput Volume Path: [{1}]", ++volumeCount, sourceVolume);
+
+
+ var pDiskInfo = new Alphaleonis.Win32.Device.PhysicalDiskInfo(sourceVolume);
+
+
+ UnitTestConstants.Dump(pDiskInfo);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageAdapterInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StorageDeviceInfo, true);
+
+ UnitTestConstants.Dump(pDiskInfo.StoragePartitionInfo, true);
+
+
+ Assert.IsNotNull(pDiskInfo);
+
+ Assert.IsNotNull(pDiskInfo.LogicalDrives);
+
+ Assert.IsNotNull(pDiskInfo.VolumeGuids);
+
+
+ // DosDeviceName should be different for volume.
+
+ Assert.AreNotEqual(pDiskInfo.DosDeviceName, pDiskInfo.PhysicalDeviceObjectName);
+
+
+ // PartitionNumber should be > 0 for volume because it is not the device.
+
+ Assert.AreNotEqual(0, pDiskInfo.StorageDeviceInfo.PartitionNumber);
+
+
+ // ContainsVolume should find volumes/logical drives.
+
+ Assert.IsTrue(pDiskInfo.LogicalDrives.Contains(sourceDrive, StringComparer.OrdinalIgnoreCase));
+
+ Assert.IsTrue(pDiskInfo.ContainsVolume(sourceDrive));
+
+
+ Assert.IsTrue(pDiskInfo.VolumeGuids.Contains(sourceVolume, StringComparer.OrdinalIgnoreCase));
+
+ Assert.IsTrue(pDiskInfo.ContainsVolume(sourceVolume));
+
+
+ // Show all partition information.
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.GptPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+ if (null != pDiskInfo.StoragePartitionInfo && null != pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ foreach (var partition in pDiskInfo.StoragePartitionInfo.MbrPartitionInfo)
+ UnitTestConstants.Dump(partition, true);
+
+
+ Console.WriteLine();
+ }
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfoTest.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfoTest.cs
new file mode 100644
index 000000000..8edca9ed0
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS PhysicalDisk Class/AlphaFS_PhysicalDiskInfoTest.cs
@@ -0,0 +1,31 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ /// This is a test class for PhysicalDiskInfo and is intended to contain all PhysicalDiskInfo Unit Tests.
+ [TestClass]
+ public partial class AlphaFS_PhysicalDiskInfoTest
+ {
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.DefineDosDevice_SymbolicLinkDriveMapping.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.DefineDosDevice_SymbolicLinkDriveMapping.cs
index 8240b4d65..0603b46d1 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.DefineDosDevice_SymbolicLinkDriveMapping.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.DefineDosDevice_SymbolicLinkDriveMapping.cs
@@ -50,7 +50,7 @@ private void AlphaFS_Volume_DefineDosDevice_SymbolicLinkDriveMapping(bool isNetw
try
{
- Alphaleonis.Win32.Filesystem.Volume.DefineDosDevice(drive, folder.FullName, Alphaleonis.Win32.Filesystem.DosDeviceAttributes.RawTargetPath);
+ Alphaleonis.Win32.Filesystem.Volume.DefineDosDevice(drive, folder.FullName, Alphaleonis.Win32.Device.DosDeviceAttributes.RawTargetPath);
// Remove Symbolic Link, no exact match: fail.
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.EnumerateVolumes.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.EnumerateVolumes.cs
index 6aa0f06b3..27561db57 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.EnumerateVolumes.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.EnumerateVolumes.cs
@@ -47,7 +47,7 @@ public void AlphaFS_Volume_EnumerateVolumes_Local_Success()
foreach (var displayName in Alphaleonis.Win32.Filesystem.Volume.EnumerateVolumePathNames(volume))
{
- Console.WriteLine("\t\tVolume points to logcal drive: [{0}]", displayName);
+ Console.WriteLine("\t\tVolume points to logical drive: [{0}]", displayName);
Console.WriteLine();
}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveFormat.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveFormat.cs
index ecf2429ea..4ea93774b 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveFormat.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveFormat.cs
@@ -42,15 +42,15 @@ private void AlphaFS_Volume_GetDriveFormat(bool isNetwork)
UnitTestConstants.PrintUnitTestHeader(isNetwork);
- var logicalDriveCount = 0;
+ var driveCount = 0;
foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
var driveName = isNetwork ? Alphaleonis.Win32.Filesystem.Path.LocalToUnc(driveInfo.Name) : driveInfo.Name;
- Console.Write("#{0:000}\tInput Logical Drive Path: [{1}]", ++logicalDriveCount, driveName);
-
+ Console.Write("#{0:000}\tInput Logical Drive Path: [{1}]", ++driveCount, driveName);
+
var driveFormat = Alphaleonis.Win32.Filesystem.Volume.GetDriveFormat(driveName);
Console.WriteLine("\t\tDrive Format: [{0}]", driveFormat);
@@ -64,7 +64,7 @@ private void AlphaFS_Volume_GetDriveFormat(bool isNetwork)
}
- Assert.IsTrue(logicalDriveCount > 0, "No logical drives enumerated, but it is expected.");
+ Assert.IsTrue(driveCount > 0, "No logical drives enumerated, but it is expected.");
Console.WriteLine();
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveNameForNtDeviceName.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveNameForNtDeviceName.cs
index 534cf546a..7eccdd565 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveNameForNtDeviceName.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveNameForNtDeviceName.cs
@@ -37,17 +37,17 @@ public void AlphaFS_Volume_GetDriveNameForNtDeviceName_And_GetVolumeGuidForNtDev
var logicalDriveCount = 0;
- foreach (var drive in System.IO.DriveInfo.GetDrives())
+ foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
// Skip mapped drives and network drives.
- if (drive.DriveType == System.IO.DriveType.NoRootDirectory || drive.DriveType == System.IO.DriveType.Network)
+ if (driveInfo.DriveType == System.IO.DriveType.NoRootDirectory || driveInfo.DriveType == System.IO.DriveType.Network)
continue;
- var driveName = drive.Name;
+ var driveName = driveInfo.Name;
- var dosDeviceName = Alphaleonis.Win32.Filesystem.Volume.GetVolumeDeviceName(driveName);
+ var dosDeviceName = Alphaleonis.Win32.Filesystem.Volume.QueryDosDevice(driveName);
var deviceGuid = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(driveName);
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveType.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveType.cs
index 7fa7162c8..773f9918e 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveType.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetDriveType.cs
@@ -42,15 +42,15 @@ private void AlphaFS_Volume_GetDriveType(bool isNetwork)
UnitTestConstants.PrintUnitTestHeader(isNetwork);
- var logicalDriveCount = 0;
+ var driveCount = 0;
- foreach (var logicalDrive in System.IO.DriveInfo.GetDrives())
+ foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
- var driveName = isNetwork ? Alphaleonis.Win32.Filesystem.Path.LocalToUnc(logicalDrive.Name) : logicalDrive.Name;
+ var driveName = isNetwork ? Alphaleonis.Win32.Filesystem.Path.LocalToUnc(driveInfo.Name) : driveInfo.Name;
- Console.Write("#{0:000}\tInput Logical Drive Path: [{1}]", ++logicalDriveCount, driveName);
+ Console.Write("#{0:000}\tInput Logical Drive Path: [{1}]", ++driveCount, driveName);
- if (logicalDrive.DriveType == System.IO.DriveType.CDRom)
+ if (driveInfo.DriveType == System.IO.DriveType.CDRom)
{
Console.WriteLine();
continue;
@@ -68,12 +68,12 @@ private void AlphaFS_Volume_GetDriveType(bool isNetwork)
}
else
- Assert.AreEqual(logicalDrive.DriveType, driveType);
+ Assert.AreEqual(driveInfo.DriveType, driveType);
}
- Assert.IsTrue(logicalDriveCount > 0, "No logical drives enumerated, but it is expected.");
+ Assert.IsTrue(driveCount > 0, "No logical drives enumerated, but it is expected.");
Console.WriteLine();
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetUniqueVolumeNameForPath.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetUniqueVolumeNameForPath.cs
index 711e6f76a..3731ac6a4 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetUniqueVolumeNameForPath.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetUniqueVolumeNameForPath.cs
@@ -37,7 +37,7 @@ public void AlphaFS_Volume_GetUniqueVolumeNameForPath_Local_Success()
var logicalDriveCount = 0;
-
+
foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
// Skip mapped drives and network drives.
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeInfo.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeInfo_UsingLogicalDrivePath.cs
similarity index 60%
rename from AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeInfo.cs
rename to AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeInfo_UsingLogicalDrivePath.cs
index 5ce801260..540f62c29 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeInfo.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeInfo_UsingLogicalDrivePath.cs
@@ -30,35 +30,35 @@ public partial class AlphaFS_VolumeTest
[TestMethod]
- public void AlphaFS_Volume_GetVolumeInfo_LocalAndNetwork_Success()
+ public void AlphaFS_Volume_GetVolumeInfo_UsingLogicalDrivePath_LocalAndNetwork_Success()
{
- AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(false);
- AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(true);
+ AlphaFS_Volume_GetVolumeInfo_UsingLogicalDrivePath(false);
+ AlphaFS_Volume_GetVolumeInfo_UsingLogicalDrivePath(true);
}
- private void AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(bool isNetwork)
+ private void AlphaFS_Volume_GetVolumeInfo_UsingLogicalDrivePath(bool isNetwork)
{
UnitTestConstants.PrintUnitTestHeader(isNetwork);
- var logicalDriveCount = 0;
+ var driveCount = 0;
- foreach (var logicalDrive in System.IO.DriveInfo.GetDrives())
+ foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
- var driveName = isNetwork ? Alphaleonis.Win32.Filesystem.Path.LocalToUnc(logicalDrive.Name) : logicalDrive.Name;
+ var driveName = isNetwork ? Alphaleonis.Win32.Filesystem.Path.LocalToUnc(driveInfo.Name) : driveInfo.Name;
- Console.WriteLine("#{0:000}\tInput Logical Drive Path: [{1}]", ++logicalDriveCount, driveName);
+ Console.WriteLine("#{0:000}\tInput Logical Drive Path: [{1}]", ++driveCount, driveName);
- // Skip mapped drives and CDRom drives.
-
- if (logicalDrive.DriveType == System.IO.DriveType.NoRootDirectory || logicalDrive.DriveType == System.IO.DriveType.CDRom)
- {
- Console.WriteLine();
- continue;
- }
+ //// Skip mapped drives and CDRom drives.
+ //if (logicalDrive.DriveType == System.IO.DriveType.NoRootDirectory || logicalDrive.DriveType == System.IO.DriveType.CDRom)
+ //{
+ // Console.WriteLine();
+ // continue;
+ //}
+
if (isNetwork)
{
@@ -79,7 +79,7 @@ private void AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(bool isNetwork)
Assert.AreEqual(driveInfo2.VolumeLabel, volInfo.Name);
Assert.AreEqual(driveInfo2.DriveFormat, volInfo.FileSystemName);
- if (logicalDrive.DriveType != System.IO.DriveType.Network)
+ if (driveInfo.DriveType != System.IO.DriveType.Network)
Assert.AreEqual(driveInfo2.Name, volInfo.FullPath);
Assert.IsNull(volInfo.Guid);
@@ -87,18 +87,7 @@ private void AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(bool isNetwork)
else
{
- Alphaleonis.Win32.Filesystem.VolumeInfo volInfo;
-
- try
- {
- volInfo = Alphaleonis.Win32.Filesystem.Volume.GetVolumeInfo(driveName);
- }
- catch (Exception ex)
- {
- Console.WriteLine("\nCaught (UNEXPECTED) {0}: [{1}]\n", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " "));
-
- continue;
- }
+ var volInfo = Alphaleonis.Win32.Filesystem.Volume.GetVolumeInfo(driveName, true);
UnitTestConstants.Dump(volInfo);
@@ -107,15 +96,21 @@ private void AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(bool isNetwork)
var driveInfo2 = new System.IO.DriveInfo(driveName);
- Assert.AreEqual(driveInfo2.VolumeLabel, volInfo.Name);
- Assert.AreEqual(driveInfo2.DriveFormat, volInfo.FileSystemName);
- Assert.AreEqual(driveInfo2.Name, volInfo.FullPath);
+
+ // Prevent System.IO.IOException: (1005) The volume does not contain a recognized file system.
- if (logicalDrive.DriveType != System.IO.DriveType.Network)
+ if (null != volInfo && null != volInfo.FileSystemName)
{
- Assert.IsNotNull(volInfo.Guid);
+ Assert.AreEqual(driveInfo2.VolumeLabel, volInfo.Name);
+ Assert.AreEqual(driveInfo2.DriveFormat, volInfo.FileSystemName);
+ Assert.AreEqual(driveInfo2.Name, volInfo.FullPath);
+
+ if (driveInfo.DriveType != System.IO.DriveType.Network)
+ {
+ Assert.IsNotNull(volInfo.Guid);
- Assert.IsTrue(volInfo.Guid.StartsWith(Alphaleonis.Win32.Filesystem.Path.VolumePrefix));
+ Assert.IsTrue(volInfo.Guid.StartsWith(Alphaleonis.Win32.Filesystem.Path.VolumePrefix));
+ }
}
}
@@ -124,7 +119,7 @@ private void AlphaFS_Volume_GetVolumeInfo_FromLogicalDrive(bool isNetwork)
}
- Assert.IsTrue(logicalDriveCount > 0, "No logical drives enumerated, but it is expected.");
+ Assert.IsTrue(driveCount > 0, "No logical drives enumerated, but it is expected.");
Console.WriteLine();
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeLabel.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeLabel_UsingLogicalDrivePath.cs
similarity index 89%
rename from AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeLabel.cs
rename to AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeLabel_UsingLogicalDrivePath.cs
index 0bb7f3c8c..7eb5b4a16 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeLabel.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetVolumeLabel_UsingLogicalDrivePath.cs
@@ -30,12 +30,12 @@ public partial class AlphaFS_VolumeTest
[TestMethod]
- public void AlphaFS_Volume_GetVolumeLabel_Local_Success()
+ public void AlphaFS_Volume_GetVolumeLabel_UsingLogicalDrivePath_Local_Success()
{
UnitTestConstants.PrintUnitTestHeader(false);
- var logicalDriveCount = 0;
+ var driveCount = 0;
foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
@@ -43,7 +43,7 @@ public void AlphaFS_Volume_GetVolumeLabel_Local_Success()
continue;
- Console.Write("#{0:000}\tInput Logical Drive Path: [{1}]", ++logicalDriveCount, driveInfo.Name);
+ Console.Write("#{0:000}\tInput Logical Drive Path: [{1}]", ++driveCount, driveInfo.Name);
var volumeLabel = Alphaleonis.Win32.Filesystem.Volume.GetVolumeLabel(driveInfo.Name);
@@ -55,7 +55,7 @@ public void AlphaFS_Volume_GetVolumeLabel_Local_Success()
}
- Assert.IsTrue(logicalDriveCount > 0, "No logical drives enumerated, but it is expected.");
+ Assert.IsTrue(driveCount > 0, "No logical drives enumerated, but it is expected.");
}
}
}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetXxx.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetXxx.cs
index 448b31413..1c970e7ff 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetXxx.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS Volume Class/AlphaFS_Volume.GetXxx.cs
@@ -42,22 +42,21 @@ public void AlphaFS_Volume_GetXxx_Local_Success()
var logicalDriveCount = 0;
- foreach (var logicalDrive in System.IO.DriveInfo.GetDrives())
+ foreach (var driveInfo in System.IO.DriveInfo.GetDrives())
{
- Console.WriteLine("#{0:000}\tInput Logical Drive Path: [{1}]\n", ++logicalDriveCount, logicalDrive.Name);
+ var isCDRom = driveInfo.DriveType == System.IO.DriveType.CDRom;
+ var isNetwork = driveInfo.DriveType == System.IO.DriveType.Network;
+ var isNoRootDirectory = driveInfo.DriveType == System.IO.DriveType.NoRootDirectory;
- if (logicalDrive.DriveType == System.IO.DriveType.CDRom)
- {
- Console.WriteLine();
- continue;
- }
+
+ Console.WriteLine("#{0:000}\tInput Logical Drive Path: [{1}]\n", ++logicalDriveCount, driveInfo.Name);
+
-
// GetVolumeDeviceName: "C:\" --> "\Device\HarddiskVolume4"
- var deviceNameFromLogicalDrive = Alphaleonis.Win32.Filesystem.Volume.GetVolumeDeviceName(logicalDrive.Name);
+ var deviceNameFromLogicalDrive = Alphaleonis.Win32.Filesystem.Volume.QueryDosDevice(driveInfo.Name);
Console.WriteLine("\tGetVolumeDeviceName\t\t\t: [{0}]", deviceNameFromLogicalDrive);
@@ -65,16 +64,29 @@ public void AlphaFS_Volume_GetXxx_Local_Success()
Assert.IsNotNull(deviceNameFromLogicalDrive);
- // Skip mapped drives and network drives.
+ if (isNetwork)
+ {
+ Assert.IsTrue(deviceNameFromLogicalDrive.StartsWith(Alphaleonis.Win32.Filesystem.Path.DosDeviceLanmanPrefix + @";" + driveInfo.Name[0] + ":", StringComparison.OrdinalIgnoreCase));
+ }
+
+
+
- if (logicalDrive.DriveType != System.IO.DriveType.NoRootDirectory && logicalDrive.DriveType != System.IO.DriveType.Network)
+ if (!isNoRootDirectory && !isNetwork)
{
- Assert.IsTrue(deviceNameFromLogicalDrive.StartsWith(deviceNamePrefix));
+
+ if (isCDRom)
+ Assert.IsTrue(deviceNameFromLogicalDrive.StartsWith(Alphaleonis.Win32.Filesystem.Path.DevicePrefix, StringComparison.OrdinalIgnoreCase));
+
+ else
+ Assert.IsTrue(deviceNameFromLogicalDrive.StartsWith(deviceNamePrefix, StringComparison.OrdinalIgnoreCase));
+
+
// GetVolumeGuid: "C:\" --> "\\?\Volume{db5044f9-bd1f-4243-ab97-4b985eb29e80}\"
- var volumeGuidFromLogicalDrive = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(logicalDrive.Name);
+ var volumeGuidFromLogicalDrive = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(driveInfo.Name);
Console.WriteLine("\tGetVolumeGuid\t\t\t\t: [{0}]", volumeGuidFromLogicalDrive);
@@ -87,7 +99,7 @@ public void AlphaFS_Volume_GetXxx_Local_Success()
// GetUniqueVolumeNameForPath: "C:\" --> "\\?\Volume{db5044f9-bd1f-4243-ab97-4b985eb29e80}\"
- var uniqueVolumeNameFromlDriveInputPath = Alphaleonis.Win32.Filesystem.Volume.GetUniqueVolumeNameForPath(logicalDrive.Name);
+ var uniqueVolumeNameFromlDriveInputPath = Alphaleonis.Win32.Filesystem.Volume.GetUniqueVolumeNameForPath(driveInfo.Name);
Console.WriteLine("\tGetUniqueVolumeNameForPath\t: [{0}]", uniqueVolumeNameFromlDriveInputPath);
@@ -97,15 +109,21 @@ public void AlphaFS_Volume_GetXxx_Local_Success()
}
- // GetVolumePathName: "C:\" or "C:\Windows" --> "C:\"
+ if (isCDRom)
+ Console.WriteLine("\tSkipped Logical Drive.\n");
+
+ else
+ {
+ // GetVolumePathName: "C:\" or "C:\Windows" --> "C:\"
- var volumePathNameFromLogicalDrive = Alphaleonis.Win32.Filesystem.Volume.GetVolumePathName(logicalDrive.Name);
+ var volumePathNameFromLogicalDrive = Alphaleonis.Win32.Filesystem.Volume.GetVolumePathName(driveInfo.Name);
- Console.WriteLine("\tGetVolumePathName\t\t\t: [{0}]\n", volumePathNameFromLogicalDrive);
+ Console.WriteLine("\tGetVolumePathName\t\t\t: [{0}]\n", volumePathNameFromLogicalDrive);
- Assert.IsNotNull(volumePathNameFromLogicalDrive);
+ Assert.IsNotNull(volumePathNameFromLogicalDrive);
- Assert.AreEqual(logicalDrive.Name, volumePathNameFromLogicalDrive);
+ Assert.AreEqual(driveInfo.Name, volumePathNameFromLogicalDrive);
+ }
}
if (logicalDriveCount == 0)
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_Device.EnumerateDevices.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_Device.EnumerateDevices.cs
index e3cea4ad7..4013b9574 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_Device.EnumerateDevices.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_Device.EnumerateDevices.cs
@@ -45,14 +45,14 @@ private void AlphaFS_Device_EnumerateDevices()
{
UnitTestConstants.PrintUnitTestHeader(false);
- var tempPath = Environment.MachineName;
+ var hostName = Environment.MachineName;
var classCnt = 0;
- foreach (var deviceClass in EnumMemberToList())
+ foreach (var deviceClass in EnumMemberToList())
{
Console.WriteLine("#{0:000}\tClass: [{1}]", ++classCnt, deviceClass);
- foreach (var device in Alphaleonis.Win32.Filesystem.Device.EnumerateDevices(tempPath, deviceClass))
+ foreach (var device in Alphaleonis.Win32.Device.Local.EnumerateDevices(hostName, deviceClass))
UnitTestConstants.Dump(device);
Console.WriteLine();
@@ -67,7 +67,7 @@ private static IEnumerable EnumMemberToList()
{
var enumType = typeof(T);
- // Can't use generic type constraints on value types, so have to do check like this.
+ // Cannot use generic type constraints on value types, so have to do check like this.
if (enumType.BaseType != typeof(Enum))
throw new ArgumentException("T must be of type System.Enum", "T");
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_DeviceTest.GetDevicePowerState.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_DeviceTest.GetDevicePowerState.cs
new file mode 100644
index 000000000..d33143748
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_DeviceTest.GetDevicePowerState.cs
@@ -0,0 +1,50 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ public partial class AlphaFS_DeviceTest
+ {
+ // Pattern: ___
+
+
+ [TestMethod]
+ public void AlphaFS_Local_GetDevicePowerState()
+ {
+ UnitTestConstants.PrintUnitTestHeader(false);
+
+ var devicePath = UnitTestConstants.SysDrive;
+
+
+ // We may assume that the system drive is awake when running unit tests.
+
+ var isOn = Alphaleonis.Win32.Device.Local.GetDevicePowerState(devicePath);
+
+
+ Console.WriteLine("\tInput Device Path: [{0}] Power State On: [{1}]", devicePath, isOn);
+
+ Assert.IsTrue(isOn);
+ }
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_DeviceTest.cs b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_DeviceTest.cs
new file mode 100644
index 000000000..00e838b3a
--- /dev/null
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/AlphaFS_DeviceTest.cs
@@ -0,0 +1,31 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace AlphaFS.UnitTest
+{
+ /// This is a test class for Device.Local and is intended to contain all Device.Local Unit Tests.
+ [TestClass]
+ public partial class AlphaFS_DeviceTest
+ {
+ }
+}
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.InitializeInstance.cs b/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.CreateInstance_UsingLogicalDrivePathFromSystemDrive.cs
similarity index 91%
rename from AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.InitializeInstance.cs
rename to AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.CreateInstance_UsingLogicalDrivePathFromSystemDrive.cs
index 9d1d3255b..bef282d12 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.InitializeInstance.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.CreateInstance_UsingLogicalDrivePathFromSystemDrive.cs
@@ -30,14 +30,14 @@ public partial class DriveInfoTest
[TestMethod]
- public void DriveInfo_InitializeInstance_LocalAndNetwork_Success()
+ public void DriveInfo_CreateInstance_UsingLogicalDrivePathFromSystemDrive_LocalAndNetwork_Success()
{
- DriveInfo_InitializeInstance(false);
- DriveInfo_InitializeInstance(true);
+ DriveInfo_CreateInstance_UsingLogicalDrivePathFromSystemDrive(false);
+ DriveInfo_CreateInstance_UsingLogicalDrivePathFromSystemDrive(true);
}
- private void DriveInfo_InitializeInstance(bool isNetwork)
+ private void DriveInfo_CreateInstance_UsingLogicalDrivePathFromSystemDrive(bool isNetwork)
{
UnitTestConstants.PrintUnitTestHeader(isNetwork);
diff --git a/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.GetDrives.cs b/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.GetDrives.cs
index f7f471723..ca6cca1dc 100644
--- a/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.GetDrives.cs
+++ b/AlphaFS.UnitTest/AlphaFS Device Class/DriveInfo Class/DriveInfo.GetDrives.cs
@@ -29,7 +29,7 @@ public partial class DriveInfoTest
{
// Pattern: ___
-
+
[TestMethod]
public void DriveInfo_GetDrives_Local_Success()
{
@@ -41,7 +41,7 @@ public void DriveInfo_GetDrives_Local_Success()
foreach (var drivePath in drivesAlphaFS)
Console.WriteLine("Logical Drive: [{0}]\n", drivePath);
-
+
CollectionAssert.AreEqual(drivesSystemIO, drivesAlphaFS);
}
diff --git a/AlphaFS.UnitTest/AlphaFS FileSystemEntryInfo Class/AlphaFS_Directory.GetFileSystemEntryInfo_LogicalDrives.cs b/AlphaFS.UnitTest/AlphaFS FileSystemEntryInfo Class/AlphaFS_Directory.GetFileSystemEntryInfo_LogicalDrives.cs
index 35da9f84b..771219da1 100644
--- a/AlphaFS.UnitTest/AlphaFS FileSystemEntryInfo Class/AlphaFS_Directory.GetFileSystemEntryInfo_LogicalDrives.cs
+++ b/AlphaFS.UnitTest/AlphaFS FileSystemEntryInfo Class/AlphaFS_Directory.GetFileSystemEntryInfo_LogicalDrives.cs
@@ -41,11 +41,11 @@ private void AlphaFS_Directory_GetFileSystemEntryInfo_LogicalDrives()
{
UnitTestConstants.PrintUnitTestHeader(false);
- var drives = Alphaleonis.Win32.Filesystem.DriveInfo.GetDrives().ToArray();
+ var drives = System.IO.DriveInfo.GetDrives().ToArray();
foreach (var driveInfo in drives)
{
- Console.WriteLine("Input Logical Drive: [{0}]", driveInfo.Name);
+ Console.WriteLine("Input Logical Drive Path: [{0}]", driveInfo.Name);
try
{
diff --git a/AlphaFS.UnitTest/AlphaFS Shell32 Class/AlphaFS_Shell32Info.InitializeInstance.cs b/AlphaFS.UnitTest/AlphaFS Shell32 Class/AlphaFS_Shell32Info.CreateInstance.cs
similarity index 87%
rename from AlphaFS.UnitTest/AlphaFS Shell32 Class/AlphaFS_Shell32Info.InitializeInstance.cs
rename to AlphaFS.UnitTest/AlphaFS Shell32 Class/AlphaFS_Shell32Info.CreateInstance.cs
index 7005438a0..b85bddacb 100644
--- a/AlphaFS.UnitTest/AlphaFS Shell32 Class/AlphaFS_Shell32Info.InitializeInstance.cs
+++ b/AlphaFS.UnitTest/AlphaFS Shell32 Class/AlphaFS_Shell32Info.CreateInstance.cs
@@ -30,14 +30,14 @@ public partial class AlphaFS_Shell32Test
[TestMethod]
- public void AlphaFS_Shell32Info_InitializeInstance_LocalAndNetwork_Success()
+ public void AlphaFS_Shell32Info_CreateInstance_LocalAndNetwork_Success()
{
- AlphaFS_Shell32Info_InitializeInstance(false);
- AlphaFS_Shell32Info_InitializeInstance(true);
+ AlphaFS_Shell32Info_CreateInstance(false);
+ AlphaFS_Shell32Info_CreateInstance(true);
}
- private void AlphaFS_Shell32Info_InitializeInstance(bool isNetwork)
+ private void AlphaFS_Shell32Info_CreateInstance(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/AlphaFS.UnitTest.csproj b/AlphaFS.UnitTest/AlphaFS.UnitTest.csproj
index 3f4154d8b..f26063125 100644
--- a/AlphaFS.UnitTest/AlphaFS.UnitTest.csproj
+++ b/AlphaFS.UnitTest/AlphaFS.UnitTest.csproj
@@ -143,6 +143,14 @@
AssemblyVersionInfo.cs
+
+
+
+
+
+
+
+
@@ -161,7 +169,7 @@
-
+
@@ -177,7 +185,7 @@
-
+
@@ -228,7 +236,7 @@
-
+
@@ -257,7 +265,7 @@
-
+
@@ -389,19 +397,19 @@
-
-
+
+
-
+
-
+
@@ -458,10 +466,10 @@
-
+
-
+
@@ -491,13 +499,13 @@
-
+
-
+
-
+
diff --git a/AlphaFS.UnitTest/Directory Class/AlphaFS_Directory.Copy/AlphaFS_Directory.Copy_3ExistingDirectories_FromVolumeShadowCopy.cs b/AlphaFS.UnitTest/Directory Class/AlphaFS_Directory.Copy/AlphaFS_Directory.Copy_3ExistingDirectories_FromVolumeShadowCopy.cs
index c6d9e7c02..1b1933c0d 100644
--- a/AlphaFS.UnitTest/Directory Class/AlphaFS_Directory.Copy/AlphaFS_Directory.Copy_3ExistingDirectories_FromVolumeShadowCopy.cs
+++ b/AlphaFS.UnitTest/Directory Class/AlphaFS_Directory.Copy/AlphaFS_Directory.Copy_3ExistingDirectories_FromVolumeShadowCopy.cs
@@ -40,7 +40,7 @@ public void AlphaFS_Directory_Copy_3ExistingDirectories_FromVolumeShadowCopy_Loc
private void AlphaFS_Directory_Copy_3ExistingDirectories_FromVolumeShadowCopy(bool isNetwork)
{
- var testOk = false;
+ var foundShadowCopy = false;
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
@@ -50,7 +50,7 @@ private void AlphaFS_Directory_Copy_3ExistingDirectories_FromVolumeShadowCopy(bo
foreach (var dosDevice in dosDevices)
{
- if (testOk)
+ if (foundShadowCopy)
break;
var shadowSource = Alphaleonis.Win32.Filesystem.Path.GlobalRootDevicePrefix + dosDevice;
@@ -98,7 +98,7 @@ private void AlphaFS_Directory_Copy_3ExistingDirectories_FromVolumeShadowCopy(bo
Assert.AreEqual((int) Alphaleonis.Win32.Win32Errors.NO_ERROR, cmr.ErrorCode);
- testOk = true;
+ foundShadowCopy = true;
copyCount++;
}
@@ -109,8 +109,8 @@ private void AlphaFS_Directory_Copy_3ExistingDirectories_FromVolumeShadowCopy(bo
Console.WriteLine();
- if (!testOk)
- UnitTestAssert.InconclusiveBecauseResourcesAreUnavailable();
+ if (!foundShadowCopy)
+ UnitTestAssert.InconclusiveBecauseFileNotFound("No volume shadow copy found.");
}
}
}
diff --git a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_AnalyzeDirectoryInfoSecurity.cs b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_AnalyzeDirectoryInfoSecurity.cs
similarity index 93%
rename from AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_AnalyzeDirectoryInfoSecurity.cs
rename to AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_AnalyzeDirectoryInfoSecurity.cs
index 8517ed77e..49e4f9938 100644
--- a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_AnalyzeDirectoryInfoSecurity.cs
+++ b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_AnalyzeDirectoryInfoSecurity.cs
@@ -31,14 +31,14 @@ public partial class DirectoryInfoTest
[TestMethod]
- public void AnalyzeDirectoryInfoSecurity_ShouldNotExist_LocalAndNetwork()
+ public void AnalyzeDirectoryInfoSecurity_CreateInstance_ShouldNotExist_LocalAndNetwork()
{
- AnalyzeDirectoryInfoSecurity_ShouldNotExist(false);
- AnalyzeDirectoryInfoSecurity_ShouldNotExist(true);
+ AnalyzeDirectoryInfoSecurity_CreateInstance_ShouldNotExist(false);
+ AnalyzeDirectoryInfoSecurity_CreateInstance_ShouldNotExist(true);
}
- private void AnalyzeDirectoryInfoSecurity_ShouldNotExist(bool isNetwork)
+ private void AnalyzeDirectoryInfoSecurity_CreateInstance_ShouldNotExist(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_ExistingDirectory.cs b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_ExistingDirectory.cs
similarity index 94%
rename from AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_ExistingDirectory.cs
rename to AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_ExistingDirectory.cs
index 66eaf53cd..57c679d14 100644
--- a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_ExistingDirectory.cs
+++ b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_ExistingDirectory.cs
@@ -30,14 +30,14 @@ public partial class DirectoryInfoTest
[TestMethod]
- public void DirectoryInfo_InitializeInstance_ExistingDirectory_LocalAndNetwork_Success()
+ public void DirectoryInfo_CreateInstance_ExistingDirectory_LocalAndNetwork_Success()
{
- DirectoryInfo_InitializeInstance_ExistingDirectory(false);
- DirectoryInfo_InitializeInstance_ExistingDirectory(true);
+ DirectoryInfo_CreateInstance_ExistingDirectory(false);
+ DirectoryInfo_CreateInstance_ExistingDirectory(true);
}
- private void DirectoryInfo_InitializeInstance_ExistingDirectory(bool isNetwork)
+ private void DirectoryInfo_CreateInstance_ExistingDirectory(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse.cs b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse.cs
similarity index 81%
rename from AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse.cs
rename to AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse.cs
index f681e5de3..2711662e6 100644
--- a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse.cs
+++ b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse.cs
@@ -30,14 +30,14 @@ public partial class DirectoryInfoTest
[TestMethod]
- public void DirectoryInfo_InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse_LocalAndNetwork_Success()
+ public void DirectoryInfo_CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse_LocalAndNetwork_Success()
{
- DirectoryInfo_InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse(false);
- DirectoryInfo_InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse(true);
+ DirectoryInfo_CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse(false);
+ DirectoryInfo_CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse(true);
}
- private void DirectoryInfo_InitializeInstance_ExistingFileAsDirectoryeName_PropertyExistsShouldbeFalse(bool isNetwork)
+ private void DirectoryInfo_CreateInstance_ExistingFileAsDirectoryName_PropertyExistsShouldBeFalse(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException.cs b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException.cs
similarity index 84%
rename from AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException.cs
rename to AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException.cs
index 4cecd4fa6..307d393a1 100644
--- a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException.cs
+++ b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException.cs
@@ -30,14 +30,14 @@ public partial class DirectoryInfoTest
[TestMethod]
- public void DirectoryInfo_InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException_LocalAndNetwork_Success()
+ public void DirectoryInfo_CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException_LocalAndNetwork_Success()
{
- DirectoryInfo_InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException(false);
- DirectoryInfo_InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException(true);
+ DirectoryInfo_CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException(false);
+ DirectoryInfo_CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException(true);
}
- private void DirectoryInfo_InitializeInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException(bool isNetwork)
+ private void DirectoryInfo_CreateInstance_FolderNameGreaterThan255Characters_ThrowsPathTooLongException(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_NonExistingDirectory.cs b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_NonExistingDirectory.cs
similarity index 84%
rename from AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_NonExistingDirectory.cs
rename to AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_NonExistingDirectory.cs
index 12a13cd26..efd263313 100644
--- a/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.InitializeInstance/DirectoryInfo.InitializeInstance_NonExistingDirectory.cs
+++ b/AlphaFS.UnitTest/DirectoryInfo Class/DirectoryInfo.CreateInstance/DirectoryInfo.CreateInstance_NonExistingDirectory.cs
@@ -30,14 +30,14 @@ public partial class DirectoryInfoTest
[TestMethod]
- public void DirectoryInfo_InitializeInstance_NonExistingDirectory_LocalAndNetwork_Success()
+ public void DirectoryInfo_CreateInstance_NonExistingDirectory_LocalAndNetwork_Success()
{
- DirectoryInfo_InitializeInstance_NonExistingDirectory(false);
- DirectoryInfo_InitializeInstance_NonExistingDirectory(true);
+ DirectoryInfo_CreateInstance_NonExistingDirectory(false);
+ DirectoryInfo_CreateInstance_NonExistingDirectory(true);
}
- private void DirectoryInfo_InitializeInstance_NonExistingDirectory(bool isNetwork)
+ private void DirectoryInfo_CreateInstance_NonExistingDirectory(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/File Class/File.Copy/AlphaFS_File.Copy_3ExistingFiles_FromVolumeShadowCopy.cs b/AlphaFS.UnitTest/File Class/File.Copy/AlphaFS_File.Copy_3ExistingFiles_FromVolumeShadowCopy.cs
index 658b63d68..0270f2e6a 100644
--- a/AlphaFS.UnitTest/File Class/File.Copy/AlphaFS_File.Copy_3ExistingFiles_FromVolumeShadowCopy.cs
+++ b/AlphaFS.UnitTest/File Class/File.Copy/AlphaFS_File.Copy_3ExistingFiles_FromVolumeShadowCopy.cs
@@ -40,7 +40,7 @@ public void AlphaFS_File_Copy_3ExistingFiles_FromVolumeShadowCopy_LocalAndNetwor
private void AlphaFS_File_Copy_3ExistingFiles_FromVolumeShadowCopy(bool isNetwork)
{
- var testOk = false;
+ var foundShadowCopy = false;
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
@@ -50,7 +50,7 @@ private void AlphaFS_File_Copy_3ExistingFiles_FromVolumeShadowCopy(bool isNetwor
foreach (var dosDevice in dosDevices)
{
- if (testOk)
+ if (foundShadowCopy)
break;
var shadowSource = Alphaleonis.Win32.Filesystem.Path.GlobalRootDevicePrefix + dosDevice;
@@ -95,7 +95,7 @@ private void AlphaFS_File_Copy_3ExistingFiles_FromVolumeShadowCopy(bool isNetwor
Assert.AreEqual((int) Alphaleonis.Win32.Win32Errors.NO_ERROR, cmr.ErrorCode);
- testOk = true;
+ foundShadowCopy = true;
copyCount++;
}
@@ -104,10 +104,10 @@ private void AlphaFS_File_Copy_3ExistingFiles_FromVolumeShadowCopy(bool isNetwor
Console.WriteLine();
+
-
- if (!testOk)
- UnitTestAssert.InconclusiveBecauseResourcesAreUnavailable();
+ if (!foundShadowCopy)
+ UnitTestAssert.InconclusiveBecauseFileNotFound("No volume shadow copy found.");
}
}
}
diff --git a/AlphaFS.UnitTest/File Class/File_Timestamps/AlphaFS_File.GetChangeTime.cs b/AlphaFS.UnitTest/File Class/File_Timestamps/AlphaFS_File.GetChangeTime.cs
index 600898697..5b2fe4b1a 100644
--- a/AlphaFS.UnitTest/File Class/File_Timestamps/AlphaFS_File.GetChangeTime.cs
+++ b/AlphaFS.UnitTest/File Class/File_Timestamps/AlphaFS_File.GetChangeTime.cs
@@ -57,7 +57,7 @@ private void AlphaFS_File_GetChangeTime(bool isNetwork)
Assert.AreEqual(System.IO.File.GetLastWriteTimeUtc(notepadFile), Alphaleonis.Win32.Filesystem.File.GetLastWriteTimeUtc(notepadFile));
- // We can not compare ChangeTime against .NET because it does not exist.
+ // We cannot compare ChangeTime against .NET because it does not exist.
// Creating a file and renaming it triggers ChangeTime, so test for that.
var file = tempRoot.CreateFile();
diff --git a/AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse.cs b/AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse.cs
similarity index 82%
rename from AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse.cs
rename to AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse.cs
index e2c8c3d98..3657ad8c6 100644
--- a/AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse.cs
+++ b/AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse.cs
@@ -30,14 +30,14 @@ public partial class FileInfoTest
[TestMethod]
- public void FileInfo_InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse_LocalAndNetwork_Success()
+ public void FileInfo_CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse_LocalAndNetwork_Success()
{
- FileInfo_InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse(false);
- FileInfo_InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse(true);
+ FileInfo_CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse(false);
+ FileInfo_CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse(true);
}
- private void FileInfo_InitializeInstance_ExistingDirectoryAsFileName_PropertyExistsShouldbeFalse(bool isNetwork)
+ private void FileInfo_CreateInstance_ExistingDirectoryAsFileName_PropertyExistsShouldBeFalse(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_ExistingFile.cs b/AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_ExistingFile.cs
similarity index 95%
rename from AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_ExistingFile.cs
rename to AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_ExistingFile.cs
index 79184c3b2..5922cb948 100644
--- a/AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_ExistingFile.cs
+++ b/AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_ExistingFile.cs
@@ -30,14 +30,14 @@ public partial class FileInfoTest
[TestMethod]
- public void FileInfo_InitializeInstance_ExistingFile_LocalAndNetwork_Success()
+ public void FileInfo_CreateInstance_ExistingFile_LocalAndNetwork_Success()
{
- FileInfo_InitializeInstance_ExistingFile(false);
- FileInfo_InitializeInstance_ExistingFile(true);
+ FileInfo_CreateInstance_ExistingFile(false);
+ FileInfo_CreateInstance_ExistingFile(true);
}
- private void FileInfo_InitializeInstance_ExistingFile(bool isNetwork)
+ private void FileInfo_CreateInstance_ExistingFile(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_NonExistingFile.cs b/AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_NonExistingFile.cs
similarity index 86%
rename from AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_NonExistingFile.cs
rename to AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_NonExistingFile.cs
index df7d095cc..8e11c7fb4 100644
--- a/AlphaFS.UnitTest/FileInfo Class/FileInfo.InitializeInstance/FileInfo.InitializeInstance_NonExistingFile.cs
+++ b/AlphaFS.UnitTest/FileInfo Class/FileInfo.CreateInstance/FileInfo.CreateInstance_NonExistingFile.cs
@@ -30,14 +30,14 @@ public partial class FileInfoTest
[TestMethod]
- public void FileInfo_InitializeInstance_NonExistingFile_LocalAndNetwork_Success()
+ public void FileInfo_CreateInstance_NonExistingFile_LocalAndNetwork_Success()
{
- FileInfo_InitializeInstance_NonExistingFile(false);
- FileInfo_InitializeInstance_NonExistingFile(true);
+ FileInfo_CreateInstance_NonExistingFile(false);
+ FileInfo_CreateInstance_NonExistingFile(true);
}
- private void FileInfo_InitializeInstance_NonExistingFile(bool isNetwork)
+ private void FileInfo_CreateInstance_NonExistingFile(bool isNetwork)
{
using (var tempRoot = new TemporaryDirectory(isNetwork))
{
diff --git a/AlphaFS/AlphaFS.csproj b/AlphaFS/AlphaFS.csproj
index 0b319183a..b6de007e8 100644
--- a/AlphaFS/AlphaFS.csproj
+++ b/AlphaFS/AlphaFS.csproj
@@ -196,32 +196,95 @@
True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -274,33 +337,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -320,41 +362,80 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
@@ -365,38 +446,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -464,23 +513,14 @@
-
-
-
-
-
-
-
-
-
@@ -510,6 +550,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -530,45 +643,64 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
+
@@ -578,7 +710,6 @@
-
@@ -590,43 +721,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
@@ -635,9 +744,7 @@
-
-
@@ -648,7 +755,6 @@
-
@@ -671,63 +777,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
@@ -780,12 +859,12 @@
+
-
@@ -811,7 +890,7 @@
-
+ True
@@ -848,9 +927,6 @@
-
-
- Code
@@ -873,13 +949,11 @@
-
-
-
+
@@ -907,7 +981,7 @@
-->
-
+
\ No newline at end of file
diff --git a/AlphaFS/Device/DeviceInfo.cs b/AlphaFS/Device/Device.DeviceInfo.cs
similarity index 77%
rename from AlphaFS/Device/DeviceInfo.cs
rename to AlphaFS/Device/Device.DeviceInfo.cs
index 989acaa63..3b5b25d76 100644
--- a/AlphaFS/Device/DeviceInfo.cs
+++ b/AlphaFS/Device/Device.DeviceInfo.cs
@@ -19,30 +19,32 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Network;
using System;
-using System.Collections.Generic;
using System.Security;
-using System.Security.Permissions;
+using Alphaleonis.Win32.Network;
namespace Alphaleonis.Win32.Filesystem
{
- /// Provides access to information of a device, on a local or remote host.
- [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
+ /// [AlphaFS] Provides access to information of a device.
[Serializable]
[SecurityCritical]
public sealed class DeviceInfo
{
#region Constructors
-
- /// Initializes a DeviceInfo class.
+
+ /// [AlphaFS] Initializes a DeviceInfo class.
[SecurityCritical]
public DeviceInfo()
{
HostName = Host.GetUncName();
}
- /// Initializes a DeviceInfo class.
+ /// [AlphaFS] Initializes a DeviceInfo class from a local or remote host.
+ ///
+ /// MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ /// http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
+ ///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
[SecurityCritical]
public DeviceInfo(string host)
@@ -53,49 +55,39 @@ public DeviceInfo(string host)
#endregion // Constructors
- #region Methods
-
- /// Enumerates all available devices on the local host.
- /// One of the devices.
- /// instances of type from the local host.
- [SecurityCritical]
- public IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
- {
- return Device.EnumerateDevicesCore(HostName, deviceGuid, true);
- }
-
- #endregion // Methods
-
-
#region Properties
/// Represents the value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode).
public Guid BaseContainerId { get; internal set; }
- /// Represents the name of the device setup class that a device instance belongs to.
- public string DeviceClass { get; internal set; }
+ /// Represents a description of a device instance as identified by the bus.
+ public string BusReportedDeviceDescription { get; internal set; }
/// Represents the of the device setup class that a device instance belongs to.
public Guid ClassGuid { get; internal set; }
-
+
/// Represents the list of compatible identifiers for a device instance.
public string CompatibleIds { get; internal set; }
+ /// Represents the name of the device setup class that a device instance belongs to.
+ public string DeviceClass { get; internal set; }
+
+
/// Represents a description of a device instance.
public string DeviceDescription { get; internal set; }
- /// The device interface path.
+ /// The device interface path string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
public string DevicePath { get; internal set; }
-
+
/// Represents the registry entry name of the driver key for a device instance.
- public string Driver { get; internal set; }
-
+ public string DeviceDriver { get; internal set; }
+
/// Represents the name of the enumerator for a device instance.
public string EnumeratorName { get; internal set; }
@@ -113,7 +105,7 @@ public IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
public string HostName { get; internal set; }
- /// Gets the instance Id of the device.
+ /// Gets the instance ID of the device.
public string InstanceId { get; internal set; }
@@ -129,7 +121,7 @@ public IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
public string Manufacturer { get; internal set; }
- /// Encapsulates the physical device location information provided by a device's firmware to Windows.
+ /// Encapsulates the physical device location (PDO) information provided by a device's firmware to Windows.
public string PhysicalDeviceObjectName { get; internal set; }
diff --git a/AlphaFS/Device/Device.cs b/AlphaFS/Device/Device.cs
deleted file mode 100644
index 48fc880f6..000000000
--- a/AlphaFS/Device/Device.cs
+++ /dev/null
@@ -1,523 +0,0 @@
-/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using Alphaleonis.Win32.Network;
-using Microsoft.Win32.SafeHandles;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.AccessControl;
-using System.Text;
-
-namespace Alphaleonis.Win32.Filesystem
-{
- /// Provides static methods to retrieve device resource information from a local or remote host.
- public static class Device
- {
- #region Enumerate Devices
-
- /// [AlphaFS] Enumerates all available devices on the local host.
- /// instances of type from the local host.
- /// One of the devices.
- [SecurityCritical]
- public static IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
- {
- return EnumerateDevicesCore(null, deviceGuid, true);
- }
-
-
- /// [AlphaFS] Enumerates all available devices of type on the local or remote host.
- /// instances of type for the specified .
- /// The name of the local or remote host on which the device resides. null refers to the local host.
- /// One of the devices.
- [SecurityCritical]
- public static IEnumerable EnumerateDevices(string hostName, DeviceGuid deviceGuid)
- {
- return EnumerateDevicesCore(hostName, deviceGuid, true);
- }
-
-
-
-
- /// [AlphaFS] Enumerates all available devices on the local or remote host.
- [SecurityCritical]
- internal static IEnumerable EnumerateDevicesCore(string hostName, DeviceGuid deviceGuid, bool getAllProperties)
- {
- if (Utils.IsNullOrWhiteSpace(hostName))
- hostName = Environment.MachineName;
-
-
- // CM_Connect_Machine()
- // MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
- // You cannot access remote machines when running on these versions of Windows.
- // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
-
-
- SafeCmConnectMachineHandle safeMachineHandle;
-
- var lastError = NativeMethods.CM_Connect_Machine(Host.GetUncName(hostName), out safeMachineHandle);
-
- NativeMethods.IsValidHandle(safeMachineHandle, lastError);
-
-
- var classGuid = new Guid(Utils.GetEnumDescription(deviceGuid));
-
-
- // Start at the "Root" of the device tree of the specified machine.
-
- using (safeMachineHandle)
- using (var safeHandle = NativeMethods.SetupDiGetClassDevsEx(ref classGuid, IntPtr.Zero, IntPtr.Zero, NativeMethods.SetupDiGetClassDevsExFlags.Present | NativeMethods.SetupDiGetClassDevsExFlags.DeviceInterface, IntPtr.Zero, hostName, IntPtr.Zero))
- {
- NativeMethods.IsValidHandle(safeHandle, Marshal.GetLastWin32Error());
-
- uint memberInterfaceIndex = 0;
- var interfaceStructSize = (uint)Marshal.SizeOf(typeof(NativeMethods.SP_DEVICE_INTERFACE_DATA));
- var dataStructSize = (uint)Marshal.SizeOf(typeof(NativeMethods.SP_DEVINFO_DATA));
-
-
- // Start enumerating device interfaces.
-
- while (true)
- {
- var interfaceData = new NativeMethods.SP_DEVICE_INTERFACE_DATA { cbSize = interfaceStructSize };
-
- var success = NativeMethods.SetupDiEnumDeviceInterfaces(safeHandle, IntPtr.Zero, ref classGuid, memberInterfaceIndex++, ref interfaceData);
-
- lastError = Marshal.GetLastWin32Error();
-
- if (!success)
- {
- if (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NO_MORE_ITEMS)
- NativeError.ThrowException(lastError, hostName);
-
- break;
- }
-
-
- // Create DeviceInfo instance.
-
- var diData = new NativeMethods.SP_DEVINFO_DATA {cbSize = dataStructSize};
-
- var deviceInfo = new DeviceInfo(hostName) {DevicePath = GetDeviceInterfaceDetail(safeHandle, ref interfaceData, ref diData).DevicePath};
-
-
- if (getAllProperties)
- {
- deviceInfo.InstanceId = GetDeviceInstanceId(safeMachineHandle, hostName, diData);
-
- SetDeviceProperties(safeHandle, deviceInfo, diData);
- }
-
- else
- SetMinimalDeviceProperties(safeHandle, deviceInfo, diData);
-
-
- yield return deviceInfo;
- }
- }
- }
-
-
- #region Private Helpers
-
- [SecurityCritical]
- private static string GetDeviceInstanceId(SafeCmConnectMachineHandle safeMachineHandle, string hostName, NativeMethods.SP_DEVINFO_DATA diData)
- {
- uint ptrPrevious;
-
- var lastError = NativeMethods.CM_Get_Parent_Ex(out ptrPrevious, diData.DevInst, 0, safeMachineHandle);
-
- if (lastError != Win32Errors.CR_SUCCESS)
- NativeError.ThrowException(lastError, hostName);
-
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize / 8)) // 512
- {
- lastError = NativeMethods.CM_Get_Device_ID_Ex(diData.DevInst, safeBuffer, (uint) safeBuffer.Capacity, 0, safeMachineHandle);
-
- if (lastError != Win32Errors.CR_SUCCESS)
- NativeError.ThrowException(lastError, hostName);
-
-
- // Device InstanceID, such as: "USB\VID_8087&PID_0A2B\5&2EDA7E1E&0&7", "SCSI\DISK&VEN_SANDISK&PROD_X400\4&288ED25&0&000200", ...
-
- return safeBuffer.PtrToStringUni();
- }
- }
-
-
- /// Builds a Device Interface Detail Data structure.
- /// An initialized NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA instance.
- [SecurityCritical]
- private static NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA GetDeviceInterfaceDetail(SafeHandle safeHandle, ref NativeMethods.SP_DEVICE_INTERFACE_DATA interfaceData, ref NativeMethods.SP_DEVINFO_DATA infoData)
- {
- var didd = new NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA {cbSize = (uint) (IntPtr.Size == 4 ? 6 : 8)};
-
- var success = NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref interfaceData, ref didd, (uint) Marshal.SizeOf(didd), IntPtr.Zero, ref infoData);
-
- var lastError = Marshal.GetLastWin32Error();
-
- if (!success)
- NativeError.ThrowException(lastError);
-
- return didd;
- }
-
-
- [SecurityCritical]
- private static string GetDeviceRegistryProperty(SafeHandle safeHandle, NativeMethods.SP_DEVINFO_DATA infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum property)
- {
- var bufferSize = NativeMethods.DefaultFileBufferSize / 8; // 512
-
- while (true)
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize))
- {
- var success = NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref infoData, property, IntPtr.Zero, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero);
-
- var lastError = Marshal.GetLastWin32Error();
-
- if (success)
- {
- var value = safeBuffer.PtrToStringUni();
-
- return !Utils.IsNullOrWhiteSpace(value) ? value.Trim() : null;
- }
-
-
- // MSDN: SetupDiGetDeviceRegistryProperty returns ERROR_INVALID_DATA error code if
- // the requested property does not exist for a device or if the property data is not valid.
-
- if (lastError == Win32Errors.ERROR_INVALID_DATA)
- return null;
-
-
- bufferSize = GetDoubledBufferSizeOrThrowException(lastError, safeBuffer, bufferSize, property.ToString());
- }
- }
-
-
-
- [SecurityCritical]
- private static void SetDeviceProperties(SafeHandle safeHandle, DeviceInfo deviceInfo, NativeMethods.SP_DEVINFO_DATA infoData)
- {
- SetMinimalDeviceProperties(safeHandle, deviceInfo, infoData);
-
-
- deviceInfo.CompatibleIds = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.CompatibleIds);
-
- deviceInfo.Driver = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Driver);
-
- deviceInfo.EnumeratorName = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.EnumeratorName);
-
- deviceInfo.HardwareId = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.HardwareId);
-
- deviceInfo.LocationInformation = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationInformation);
-
- deviceInfo.LocationPaths = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationPaths);
-
- deviceInfo.Manufacturer = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Manufacturer);
-
- deviceInfo.Service = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Service);
- }
-
-
- [SecurityCritical]
- private static void SetMinimalDeviceProperties(SafeHandle safeHandle, DeviceInfo deviceInfo, NativeMethods.SP_DEVINFO_DATA infoData)
- {
- deviceInfo.BaseContainerId = new Guid(GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.BaseContainerId));
-
- deviceInfo.ClassGuid = new Guid(GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.ClassGuid));
-
- deviceInfo.DeviceClass = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Class);
-
- deviceInfo.DeviceDescription = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.DeviceDescription);
-
- deviceInfo.FriendlyName = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.FriendlyName);
-
- deviceInfo.PhysicalDeviceObjectName = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.PhysicalDeviceObjectName);
- }
-
-
- [SecurityCritical]
- internal static int GetDoubledBufferSizeOrThrowException(int lastError, SafeHandle safeBuffer, int bufferSize, string pathForException)
- {
- if (null != safeBuffer && !safeBuffer.IsClosed)
- safeBuffer.Close();
-
-
- switch ((uint) lastError)
- {
- case Win32Errors.ERROR_MORE_DATA:
- case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
- bufferSize *= 2;
- break;
-
-
- default:
- NativeMethods.IsValidHandle(safeBuffer, lastError, string.Format(CultureInfo.InvariantCulture, "Buffer size: {0}. Path: {1}", bufferSize.ToString(CultureInfo.InvariantCulture), pathForException));
- break;
- }
-
-
- return bufferSize;
- }
-
-
- /// Repeatedly invokes InvokeIoControl with the specified input until enough memory has been allocated.
- [SecurityCritical]
- private static void InvokeIoControlUnknownSize(SafeFileHandle handle, uint controlCode, T input, uint increment = 128)
- {
- var inputSize = (uint) Marshal.SizeOf(input);
- var outputLength = increment;
-
- do
- {
- var output = new byte[outputLength];
- uint bytesReturned;
-
- var success = NativeMethods.DeviceIoControlUnknownSize(handle, controlCode, input, inputSize, output, outputLength, out bytesReturned, IntPtr.Zero);
-
- var lastError = Marshal.GetLastWin32Error();
- if (!success)
- {
- switch ((uint) lastError)
- {
- case Win32Errors.ERROR_MORE_DATA:
- case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
- outputLength += increment;
- break;
-
- default:
- if (lastError != Win32Errors.ERROR_SUCCESS)
- NativeError.ThrowException(lastError);
- break;
- }
- }
-
- else
- break;
-
- } while (true);
- }
-
- #endregion // Private Helpers
-
-
- #endregion // Enumerate Devices
-
-
- #region Compression
-
- /// [AlphaFS] Sets the NTFS compression state of a file or directory on a volume whose file system supports per-file and per-directory compression.
- /// The transaction.
- /// Specifies that is a file or directory.
- /// A path that describes a folder or file to compress or decompress.
- /// true = compress, false = decompress
- /// Indicates the format of the path parameter(s).
- [SecurityCritical]
- internal static void ToggleCompressionCore(KernelTransaction transaction, bool isFolder, string path, bool compress, PathFormat pathFormat)
- {
- using (var handle = File.CreateFileCore(transaction, isFolder, path, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.Modify, FileShare.None, true, false, pathFormat))
-
- InvokeIoControlUnknownSize(handle, NativeMethods.FSCTL_SET_COMPRESSION, compress ? 1 : 0);
- }
-
- #endregion // Compression
-
-
- #region Link
-
- /// [AlphaFS] Creates an NTFS directory junction (similar to CMD command: "MKLINK /J").
- internal static void CreateDirectoryJunction(SafeFileHandle safeHandle, string directoryPath)
- {
- var targetDirBytes = Encoding.Unicode.GetBytes(Path.NonInterpretedPathPrefix + Path.GetRegularPathCore(directoryPath, GetFullPathOptions.AddTrailingDirectorySeparator, false));
-
- var header = new NativeMethods.ReparseDataBufferHeader
- {
- ReparseTag = ReparsePointTag.MountPoint,
- ReparseDataLength = (ushort) (targetDirBytes.Length + 12)
- };
-
- var mountPoint = new NativeMethods.MountPointReparseBuffer
- {
- SubstituteNameOffset = 0,
- SubstituteNameLength = (ushort) targetDirBytes.Length,
- PrintNameOffset = (ushort) (targetDirBytes.Length + UnicodeEncoding.CharSize),
- PrintNameLength = 0
- };
-
- var reparseDataBuffer = new NativeMethods.REPARSE_DATA_BUFFER
- {
- ReparseTag = header.ReparseTag,
- ReparseDataLength = header.ReparseDataLength,
-
- SubstituteNameOffset = mountPoint.SubstituteNameOffset,
- SubstituteNameLength = mountPoint.SubstituteNameLength,
- PrintNameOffset = mountPoint.PrintNameOffset,
- PrintNameLength = mountPoint.PrintNameLength,
-
- PathBuffer = new byte[NativeMethods.MAXIMUM_REPARSE_DATA_BUFFER_SIZE - 16] // 16368
- };
-
- targetDirBytes.CopyTo(reparseDataBuffer.PathBuffer, 0);
-
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(Marshal.SizeOf(reparseDataBuffer)))
- {
- safeBuffer.StructureToPtr(reparseDataBuffer, false);
-
- uint bytesReturned;
- var succes = NativeMethods.DeviceIoControl2(safeHandle, NativeMethods.FSCTL_SET_REPARSE_POINT, safeBuffer, (uint) (targetDirBytes.Length + 20), IntPtr.Zero, 0, out bytesReturned, IntPtr.Zero);
-
- var lastError = Marshal.GetLastWin32Error();
- if (!succes)
- NativeError.ThrowException(lastError, directoryPath);
- }
- }
-
-
- /// [AlphaFS] Deletes an NTFS directory junction.
- internal static void DeleteDirectoryJunction(SafeFileHandle safeHandle)
- {
- var reparseDataBuffer = new NativeMethods.REPARSE_DATA_BUFFER
- {
- ReparseTag = ReparsePointTag.MountPoint,
- ReparseDataLength = 0,
- PathBuffer = new byte[NativeMethods.MAXIMUM_REPARSE_DATA_BUFFER_SIZE - 16] // 16368
- };
-
-
- using (var safeBuffer = new SafeGlobalMemoryBufferHandle(Marshal.SizeOf(reparseDataBuffer)))
- {
- safeBuffer.StructureToPtr(reparseDataBuffer, false);
-
- uint bytesReturned;
- var success = NativeMethods.DeviceIoControl2(safeHandle, NativeMethods.FSCTL_DELETE_REPARSE_POINT, safeBuffer, NativeMethods.REPARSE_DATA_BUFFER_HEADER_SIZE, IntPtr.Zero, 0, out bytesReturned, IntPtr.Zero);
-
- var lastError = Marshal.GetLastWin32Error();
- if (!success)
- NativeError.ThrowException(lastError);
- }
- }
-
-
- /// [AlphaFS] Get information about the target of a mount point or symbolic link on an NTFS file system.
- ///
- ///
- [SecurityCritical]
- internal static LinkTargetInfo GetLinkTargetInfo(SafeFileHandle safeHandle, string reparsePath)
- {
- using (var safeBuffer = GetLinkTargetData(safeHandle, reparsePath))
- {
- var header = safeBuffer.PtrToStructure(0);
-
- var marshalReparseBuffer = (int) Marshal.OffsetOf(typeof(NativeMethods.ReparseDataBufferHeader), "data");
-
- var dataOffset = (int) (marshalReparseBuffer + (header.ReparseTag == ReparsePointTag.MountPoint
- ? Marshal.OffsetOf(typeof(NativeMethods.MountPointReparseBuffer), "data")
- : Marshal.OffsetOf(typeof(NativeMethods.SymbolicLinkReparseBuffer), "data")).ToInt64());
-
- var dataBuffer = new byte[NativeMethods.MAXIMUM_REPARSE_DATA_BUFFER_SIZE - dataOffset];
-
-
- switch (header.ReparseTag)
- {
- // MountPoint can be a junction or mounted drive (mounted drive starts with "\??\Volume").
-
- case ReparsePointTag.MountPoint:
- var mountPoint = safeBuffer.PtrToStructure(marshalReparseBuffer);
-
- safeBuffer.CopyTo(dataOffset, dataBuffer);
-
- return new LinkTargetInfo(
- Encoding.Unicode.GetString(dataBuffer, mountPoint.SubstituteNameOffset, mountPoint.SubstituteNameLength),
- Encoding.Unicode.GetString(dataBuffer, mountPoint.PrintNameOffset, mountPoint.PrintNameLength));
-
-
- case ReparsePointTag.SymLink:
- var symLink = safeBuffer.PtrToStructure(marshalReparseBuffer);
-
- safeBuffer.CopyTo(dataOffset, dataBuffer);
-
- return new SymbolicLinkTargetInfo(
- Encoding.Unicode.GetString(dataBuffer, symLink.SubstituteNameOffset, symLink.SubstituteNameLength),
- Encoding.Unicode.GetString(dataBuffer, symLink.PrintNameOffset, symLink.PrintNameLength), symLink.Flags);
-
-
- default:
- throw new UnrecognizedReparsePointException(reparsePath);
- }
- }
- }
-
-
- /// [AlphaFS] Get information about the target of a mount point or symbolic link on an NTFS file system.
- ///
- ///
- [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposing is controlled.")]
- [SecurityCritical]
- private static SafeGlobalMemoryBufferHandle GetLinkTargetData(SafeFileHandle safeHandle, string reparsePath)
- {
- var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
-
- while (true)
- {
- uint bytesReturned;
- var success = NativeMethods.DeviceIoControl(safeHandle, NativeMethods.FSCTL_GET_REPARSE_POINT, IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, out bytesReturned, IntPtr.Zero);
-
- var lastError = Marshal.GetLastWin32Error();
- if (!success)
- {
- switch ((uint) lastError)
- {
- case Win32Errors.ERROR_MORE_DATA:
- case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
-
- // Should not happen since we already use the maximum size.
-
- if (safeBuffer.Capacity < bytesReturned)
- safeBuffer.Close();
- break;
-
-
- default:
- if (lastError != Win32Errors.ERROR_SUCCESS)
- NativeError.ThrowException(lastError, reparsePath);
- break;
- }
- }
-
- else
- break;
- }
-
-
- return safeBuffer;
- }
-
- #endregion // Link
- }
-}
diff --git a/AlphaFS/Device/DriveInfo Class/DriveInfo.EnumerateLogicalDrives.cs b/AlphaFS/Device/DriveInfo Class/DriveInfo.EnumerateLogicalDrives.cs
new file mode 100644
index 000000000..2f2c3e16d
--- /dev/null
+++ b/AlphaFS/Device/DriveInfo Class/DriveInfo.EnumerateLogicalDrives.cs
@@ -0,0 +1,118 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace Alphaleonis.Win32.Filesystem
+{
+ public sealed partial class DriveInfo
+ {
+ /// Enumerates the drive names of all logical drives on the Computer.
+ /// Returns an collection of logical drives on the Computer.
+ /// Retrieve logical drives as known by the Environment.
+ /// Retrieve only when accessible (IsReady) logical drives.
+ [SecurityCritical]
+ internal static IEnumerable EnumerateLogicalDrivesCore(bool fromEnvironment, bool isReady)
+ {
+ // Get from Environment.
+
+ if (fromEnvironment)
+ {
+ var drivesEnv = isReady
+ ? Environment.GetLogicalDrives().Where(logicalDrive => File.ExistsCore(null, true, logicalDrive, PathFormat.LongFullPath))
+ : Environment.GetLogicalDrives().Select(logicalDrive => logicalDrive);
+
+ foreach (var drive in drivesEnv)
+ {
+ // Optionally check Drive .IsReady.
+ if (isReady)
+ {
+ if (File.ExistsCore(null, true, drive, PathFormat.LongFullPath))
+
+ yield return Path.AddTrailingDirectorySeparator(drive, false);
+ }
+
+ else
+ yield return Path.AddTrailingDirectorySeparator(drive, false);
+ }
+
+ yield break;
+ }
+
+
+ // Get through NativeMethod.
+ var allDrives = Device.NativeMethods.GetLogicalDrives();
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ // MSDN: GetLogicalDrives(): If the function fails, the return value is zero.
+ if (allDrives == Win32Errors.ERROR_SUCCESS)
+ NativeError.ThrowException(lastError);
+
+
+ var drives = allDrives;
+ var count = 0;
+ while (drives != 0)
+ {
+ if ((drives & 1) != 0)
+ ++count;
+
+ drives >>= 1;
+ }
+
+ var result = new string[count];
+ char[] root = {'A', Path.VolumeSeparatorChar};
+
+ drives = allDrives;
+ count = 0;
+
+ while (drives != 0)
+ {
+ if ((drives & 1) != 0)
+ {
+ var drive = new string(root);
+
+ if (isReady)
+ {
+ // Optionally check Drive .IsReady property.
+
+ if (File.ExistsCore(null, true, drive, PathFormat.LongFullPath))
+
+ yield return Path.AddTrailingDirectorySeparator(drive, false);
+ }
+
+ // Ready or not.
+ else
+ yield return Path.AddTrailingDirectorySeparator(drive, false);
+
+ result[count++] = drive;
+ }
+
+ drives >>= 1;
+ root[0]++;
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/DriveInfo Class/DriveInfo.GetDeviceInfo.cs b/AlphaFS/Device/DriveInfo Class/DriveInfo.GetDeviceInfo.cs
new file mode 100644
index 000000000..5ebcea29c
--- /dev/null
+++ b/AlphaFS/Device/DriveInfo Class/DriveInfo.GetDeviceInfo.cs
@@ -0,0 +1,122 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Security;
+
+namespace Alphaleonis.Win32.Filesystem
+{
+ public sealed partial class DriveInfo
+ {
+ /// Retrieves information about the file system and volume associated with the specified root file or directorystream.
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ [SecurityCritical]
+ private object GetDeviceInfo(int type, int mode)
+ {
+ //try
+ //{
+ switch (type)
+ {
+ #region Volume
+
+ // VolumeInfo properties.
+ case 0:
+ if (Utils.IsNullOrWhiteSpace(_volumeInfo.FullPath))
+ _volumeInfo.Refresh();
+
+
+ switch (mode)
+ {
+ case 0:
+ // IsVolume, VolumeInfo
+ return _volumeInfo;
+
+
+ case 1:
+ // DriveFormat
+ return null == _volumeInfo ? DriveType.Unknown.ToString() : _volumeInfo.FileSystemName ?? DriveType.Unknown.ToString();
+
+
+ case 2:
+ // VolumeLabel
+ return null == _volumeInfo ? string.Empty : _volumeInfo.Name ?? string.Empty;
+
+ case 3:
+ // DriveType
+ return null == _volumeInfo ? (object)string.Empty : _volumeInfo.DriveType;
+ }
+
+ break;
+
+
+ // Volume related.
+ case 1:
+ if (mode == 0)
+ {
+ // DosDeviceName
+ return _dosDeviceName ?? (_dosDeviceName = Volume.QueryDosDevice(_name));
+ }
+
+ break;
+
+ #endregion // Volume
+
+
+ #region Drive
+
+ // Drive related.
+ case 2:
+ if (mode == 0)
+ {
+ // RootDirectory
+ return _rootDirectory ?? (_rootDirectory = new DirectoryInfo(null, _name, PathFormat.RelativePath));
+ }
+
+ break;
+
+
+ // DiskSpaceInfo related.
+ case 3:
+ if (mode == 0)
+ {
+ // AvailableFreeSpace, TotalFreeSpace, TotalSize, DiskSpaceInfo
+ if (!_initDsie)
+ {
+ _dsi.Refresh();
+ _initDsie = true;
+ }
+ }
+
+ break;
+
+ #endregion // Drive
+ }
+ //}
+ //catch
+ //{
+ //}
+
+ return type == 0 && mode > 0 ? string.Empty : null;
+ }
+ }
+}
diff --git a/AlphaFS/Device/DriveInfo Class/DriveInfo.GetFreeDriveLetter.cs b/AlphaFS/Device/DriveInfo Class/DriveInfo.GetFreeDriveLetter.cs
new file mode 100644
index 000000000..a473b596d
--- /dev/null
+++ b/AlphaFS/Device/DriveInfo Class/DriveInfo.GetFreeDriveLetter.cs
@@ -0,0 +1,59 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+
+namespace Alphaleonis.Win32.Filesystem
+{
+ public sealed partial class DriveInfo
+ {
+ /// [AlphaFS] Gets the first available drive letter on the local system.
+ /// Returns a drive letter as . When no drive letters are available, an exception is thrown.
+ /// The letters "A" and "B" are reserved for floppy drives and will never be returned by this function.
+ public static char GetFreeDriveLetter()
+ {
+ return GetFreeDriveLetter(false);
+ }
+
+
+ /// [AlphaFS] Gets an available drive letter on the local system.
+ /// When true get the last available drive letter. When false gets the first available drive letter.
+ /// Returns a drive letter as . When no drive letters are available, an exception is thrown.
+ /// The letters "A" and "B" are reserved for floppy drives and will never be returned by this function.
+ /// No drive letters available.
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ public static char GetFreeDriveLetter(bool getLastAvailable)
+ {
+ var freeDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ".Except(EnumerateLogicalDrivesCore(false, false).OrderBy(driveName => driveName).Select(driveName => driveName[0]));
+
+ try
+ {
+ return getLastAvailable ? freeDriveLetters.Last() : freeDriveLetters.First();
+ }
+ catch
+ {
+ throw new ArgumentOutOfRangeException(Resources.No_Drive_Letters_Available);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/DriveInfo.cs b/AlphaFS/Device/DriveInfo Class/DriveInfo.cs
similarity index 58%
rename from AlphaFS/Device/DriveInfo.cs
rename to AlphaFS/Device/DriveInfo Class/DriveInfo.cs
index bc19ba061..50f80edea 100644
--- a/AlphaFS/Device/DriveInfo.cs
+++ b/AlphaFS/Device/DriveInfo Class/DriveInfo.cs
@@ -20,7 +20,6 @@
*/
using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
@@ -36,19 +35,24 @@ namespace Alphaleonis.Win32.Filesystem
///
[Serializable]
[SecurityCritical]
- public sealed class DriveInfo
+ public sealed partial class DriveInfo
{
+ #region Fields
+
[NonSerialized] private readonly VolumeInfo _volumeInfo;
[NonSerialized] private readonly DiskSpaceInfo _dsi;
[NonSerialized] private bool _initDsie;
- [NonSerialized] private DriveType? _driveType;
+ [NonSerialized] private readonly string _name;
[NonSerialized] private string _dosDeviceName;
[NonSerialized] private DirectoryInfo _rootDirectory;
- [NonSerialized] private readonly string _name;
+
+ #endregion // Private Fields
#region Constructors
+ #region .NET
+
/// Provides access to information on the specified drive.
///
///
@@ -61,9 +65,12 @@ public sealed class DriveInfo
[SecurityCritical]
public DriveInfo(string driveName)
{
- if (Utils.IsNullOrWhiteSpace(driveName))
+ if (null == driveName)
throw new ArgumentNullException("driveName");
+ if (driveName.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "driveName");
+
driveName = driveName.Length == 1 ? driveName + Path.VolumeSeparatorChar : Path.GetPathRoot(driveName, false);
@@ -73,18 +80,24 @@ public DriveInfo(string driveName)
_name = Path.AddTrailingDirectorySeparator(driveName, false);
- // Initiate VolumeInfo() lazyload instance.
+
+ // Initiate VolumeInfo lazyload instance.
_volumeInfo = new VolumeInfo(_name, false, true);
- // Initiate DiskSpaceInfo() lazyload instance.
+
+ // Initiate DiskSpaceInfo lazyload instance.
_dsi = new DiskSpaceInfo(_name, null, false, true);
}
+ #endregion // .NET
+
#endregion // Constructors
#region Properties
+ #region .NET
+
/// Indicates the amount of available free space on a drive.
/// The amount of free space available on the drive, in bytes.
/// This property indicates the amount of free space available on the drive. Note that this number may be different from the number because this property takes into account disk quotas.
@@ -93,11 +106,13 @@ public long AvailableFreeSpace
get
{
GetDeviceInfo(3, 0);
+
return null == _dsi ? 0 : _dsi.FreeBytesAvailable;
}
}
- /// Gets the name of the file system, such as NTFS or FAT32.
+
+ /// Gets the name of the file system, such as: "NTFS" or "FAT32".
/// Use DriveFormat to determine what formatting a drive uses.
public string DriveFormat
{
@@ -113,7 +128,7 @@ public string DriveFormat
///
public DriveType DriveType
{
- get { return (DriveType) GetDeviceInfo(2, 0); }
+ get { return (DriveType) GetDeviceInfo(0, 3); }
}
@@ -130,13 +145,13 @@ public DriveType DriveType
///
public bool IsReady
{
- get { return File.ExistsCore(null, true, Name, PathFormat.LongFullPath); }
+ get { return File.ExistsCore(null, true, _name, PathFormat.LongFullPath); }
}
/// Gets the name of the drive.
/// The name of the drive.
- /// This property is the name assigned to the drive, such as C:\ or E:\
+ /// This property is the name assigned to the drive, such as: C:\ or D:\
public string Name
{
get { return _name; }
@@ -144,12 +159,13 @@ public string Name
/// Gets the root directory of a drive.
- /// A DirectoryInfo object that contains the root directory of the drive.
+ /// Returns a DirectoryInfo object that contains the root directory of the drive.
public DirectoryInfo RootDirectory
{
- get { return (DirectoryInfo) GetDeviceInfo(2, 1); }
+ get { return (DirectoryInfo) GetDeviceInfo(2, 0); }
}
+
/// Gets the total amount of free space available on a drive.
/// The total free space available on a drive, in bytes.
/// This property indicates the total amount of free space available on the drive, not just what is available to the current user.
@@ -158,6 +174,7 @@ public long TotalFreeSpace
get
{
GetDeviceInfo(3, 0);
+
return null == _dsi ? 0 : _dsi.TotalNumberOfFreeBytes;
}
}
@@ -171,6 +188,7 @@ public long TotalSize
get
{
GetDeviceInfo(3, 0);
+
return null == _dsi ? 0 : _dsi.TotalNumberOfBytes;
}
}
@@ -185,21 +203,26 @@ public long TotalSize
public string VolumeLabel
{
get { return (string) GetDeviceInfo(0, 2); }
- set { Volume.SetVolumeLabel(Name, value); }
+
+ set { Volume.SetVolumeLabel(_name, value); }
}
+ #endregion // .NET
+
+
/// [AlphaFS] Returns the instance.
public DiskSpaceInfo DiskSpaceInfo
{
get
{
GetDeviceInfo(3, 0);
+
return _dsi;
}
}
- /// [AlphaFS] The MS-DOS device name.
+ /// [AlphaFS] The Win32 Device name.
public string DosDeviceName
{
get { return (string) GetDeviceInfo(1, 0); }
@@ -209,7 +232,10 @@ public string DosDeviceName
/// [AlphaFS] Indicates if this drive is a SUBST.EXE / DefineDosDevice drive mapping.
public bool IsDosDeviceSubstitute
{
- get { return !Utils.IsNullOrWhiteSpace(DosDeviceName) && DosDeviceName.StartsWith(Path.NonInterpretedPathPrefix, StringComparison.OrdinalIgnoreCase); }
+ get
+ {
+ return !Utils.IsNullOrWhiteSpace(DosDeviceName) && DosDeviceName.StartsWith(Path.NonInterpretedPathPrefix, StringComparison.OrdinalIgnoreCase);
+ }
}
@@ -219,9 +245,9 @@ public bool IsUnc
get
{
return !IsDosDeviceSubstitute && DriveType == DriveType.Network ||
-
+
// Handle Host devices with file systems: FAT/FAT32, UDF (CDRom), ...
- Name.StartsWith(Path.UncPrefix, StringComparison.Ordinal) && DriveType == DriveType.NoRootDirectory && DriveFormat.Equals(DriveType.Unknown.ToString(), StringComparison.OrdinalIgnoreCase);
+ _name.StartsWith(Path.UncPrefix, StringComparison.Ordinal) && DriveType == DriveType.NoRootDirectory && DriveFormat.Equals(DriveType.Unknown.ToString(), StringComparison.OrdinalIgnoreCase);
}
}
@@ -232,15 +258,14 @@ public bool IsVolume
get { return null != GetDeviceInfo(0, 0); }
}
-
- /// [AlphaFS] Contains information about a file-system volume.
- /// A VolumeInfo object that contains file-system volume information of the drive.
+
+ /// [AlphaFS] Contains information about a file system volume.
+ /// Returns a object that contains file system volume information of the drive.
public VolumeInfo VolumeInfo
{
get { return (VolumeInfo) GetDeviceInfo(0, 0); }
}
-
#endregion // Properties
@@ -248,12 +273,12 @@ public VolumeInfo VolumeInfo
#region .NET
- /// Retrieves the of all logical drives on the Computer.
- /// An array of type that represents the logical drives on the Computer.
+ /// Retrieves the drive names of all logical drives on a Computer.
+ /// Returns an of instances on the Computer.
[SecurityCritical]
public static DriveInfo[] GetDrives()
{
- return Directory.EnumerateLogicalDrivesCore(false, false).ToArray();
+ return EnumerateLogicalDrivesCore(false, false).OrderBy(driveName => driveName).Select(driveName => new DriveInfo(driveName)).ToArray();
}
@@ -268,147 +293,25 @@ public override string ToString()
#endregion // .NET
- /// [AlphaFS] Enumerates the drive names of all logical drives on the Computer.
+ /// [AlphaFS] Retrieves the drive names of all logical drives on a Computer.
+ /// Returns an of instances on the Computer.
/// Retrieve logical drives as known by the Environment.
/// Retrieve only when accessible (IsReady) logical drives.
- ///
- /// An IEnumerable of type that represents
- /// the logical drives on the Computer.
- ///
[SecurityCritical]
- public static IEnumerable EnumerateDrives(bool fromEnvironment, bool isReady)
+ public static DriveInfo[] GetDrives(bool fromEnvironment, bool isReady)
{
- return Directory.EnumerateLogicalDrivesCore(fromEnvironment, isReady);
+ return EnumerateLogicalDrivesCore(fromEnvironment, isReady).OrderBy(driveName => driveName).Select(driveName => new DriveInfo(driveName)).ToArray();
}
- /// [AlphaFS] Gets the first available drive letter on the local system.
- /// A drive letter as . When no drive letters are available, an exception is thrown.
- /// The letters "A" and "B" are reserved for floppy drives and will never be returned by this function.
- public static char GetFreeDriveLetter()
+ /// [AlphaFS] Refreshes the state of the object.
+ public void Refresh()
{
- return GetFreeDriveLetter(false);
- }
-
+ _volumeInfo.Refresh();
- /// Gets an available drive letter on the local system.
- /// When true get the last available drive letter. When false gets the first available drive letter.
- /// A drive letter as . When no drive letters are available, an exception is thrown.
- /// The letters "A" and "B" are reserved for floppy drives and will never be returned by this function.
- /// No drive letters available.
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- public static char GetFreeDriveLetter(bool getLastAvailable)
- {
- var freeDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ".Except(Directory.EnumerateLogicalDrivesCore(false, false).Select(d => d.Name[0]));
-
- try
- {
- return getLastAvailable ? freeDriveLetters.Last() : freeDriveLetters.First();
- }
- catch
- {
- throw new ArgumentOutOfRangeException(Resources.No_Drive_Letters_Available);
- }
+ _dsi.Refresh();
}
#endregion // Methods
-
-
- #region Private Methods
-
- /// Retrieves information about the file system and volume associated with the specified root file or directorystream.
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- [SecurityCritical]
- private object GetDeviceInfo(int type, int mode)
- {
- try
- {
- switch (type)
- {
- #region Volume
-
- // VolumeInfo properties.
- case 0:
- if (Utils.IsNullOrWhiteSpace(_volumeInfo.FullPath))
- _volumeInfo.Refresh();
-
- switch (mode)
- {
- case 0:
- // IsVolume, VolumeInfo
- return _volumeInfo;
-
- case 1:
- // DriveFormat
- return null == _volumeInfo ? DriveType.Unknown.ToString() : _volumeInfo.FileSystemName ?? DriveType.Unknown.ToString();
-
- case 2:
- // VolumeLabel
- return null == _volumeInfo ? string.Empty : _volumeInfo.Name ?? string.Empty;
- }
-
- break;
-
-
- // Volume related.
- case 1:
- switch (mode)
- {
- case 0:
- // DosDeviceName
- return _dosDeviceName ?? (_dosDeviceName = Volume.GetVolumeDeviceName(Name));
- }
-
- break;
-
- #endregion // Volume
-
-
- #region Drive
-
- // Drive related.
- case 2:
- switch (mode)
- {
- case 0:
- // DriveType
- return _driveType ?? (_driveType = Volume.GetDriveType(Name));
-
- case 1:
- // RootDirectory
- return _rootDirectory ?? (_rootDirectory = new DirectoryInfo(null, Name, PathFormat.RelativePath));
- }
-
- break;
-
- // DiskSpaceInfo related.
- case 3:
- switch (mode)
- {
- case 0:
- // AvailableFreeSpace, TotalFreeSpace, TotalSize, DiskSpaceInfo
- if (!_initDsie)
- {
- _dsi.Refresh();
- _initDsie = true;
- }
-
- break;
- }
-
- break;
-
- #endregion // Drive
- }
- }
- catch
- {
- }
-
- return type == 0 && mode > 0 ? string.Empty : null;
- }
-
- #endregion // Private
}
}
diff --git a/AlphaFS/Device/FilesystemHelper Class/Device.FilesystemHelper.cs b/AlphaFS/Device/FilesystemHelper Class/Device.FilesystemHelper.cs
new file mode 100644
index 000000000..019020be2
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/Device.FilesystemHelper.cs
@@ -0,0 +1,34 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides static methods to retrieve device resource information from a local or remote host.
+ internal static partial class FilesystemHelper
+ {
+ /// MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384
+ private const int MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384;
+
+
+ /// REPARSE_DATA_BUFFER_HEADER_SIZE = 8
+ private const int REPARSE_DATA_BUFFER_HEADER_SIZE = 8;
+ }
+}
diff --git a/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.Compression.cs b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.Compression.cs
new file mode 100644
index 000000000..db67af2a1
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.Compression.cs
@@ -0,0 +1,46 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.IO;
+using System.Security;
+using System.Security.AccessControl;
+using Alphaleonis.Win32.Filesystem;
+using File = Alphaleonis.Win32.Filesystem.File;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class FilesystemHelper
+ {
+ /// [AlphaFS] Sets the NTFS compression state of a file or directory on a volume whose file system supports per-file and per-directory compression.
+ /// The transaction.
+ /// When true indicates the sources is a directory, false indicates a file.
+ /// A path that describes a folder or file to compress or decompress.
+ /// true = compress, false = decompress
+ /// Indicates the format of the path parameter(s).
+ [SecurityCritical]
+ internal static void ToggleCompressionCore(KernelTransaction transaction, bool isFolder, string path, bool compress, PathFormat pathFormat)
+ {
+ using (var safeHandle = File.CreateFileCore(transaction, isFolder, path, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.Modify, FileShare.None, true, false, pathFormat))
+
+ using (Local.InvokeDeviceIoData(safeHandle, NativeMethods.IoControlCode.FSCTL_SET_COMPRESSION, compress ? 1 : 0, path)) { }
+ }
+ }
+}
diff --git a/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.CreateDirectoryJunction.cs b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.CreateDirectoryJunction.cs
new file mode 100644
index 000000000..3f683ed97
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.CreateDirectoryJunction.cs
@@ -0,0 +1,87 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Text;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
+ internal static partial class FilesystemHelper
+ {
+ /// [AlphaFS] Creates an NTFS directory junction (similar to CMD command: "MKLINK /J").
+ internal static void CreateDirectoryJunction(SafeFileHandle safeFileHandle, string directoryPath)
+ {
+ var targetDirBytes = Encoding.Unicode.GetBytes(Path.NonInterpretedPathPrefix + Path.GetRegularPathCore(directoryPath, GetFullPathOptions.AddTrailingDirectorySeparator, false));
+
+ var header = new Filesystem.NativeMethods.ReparseDataBufferHeader
+ {
+ ReparseTag = ReparsePointTag.MountPoint,
+ ReparseDataLength = (ushort) (targetDirBytes.Length + 12)
+ };
+
+
+ var mountPoint = new Filesystem.NativeMethods.MountPointReparseBuffer
+ {
+ SubstituteNameOffset = 0,
+ SubstituteNameLength = (ushort) targetDirBytes.Length,
+
+ PrintNameOffset = (ushort) (targetDirBytes.Length + UnicodeEncoding.CharSize),
+ PrintNameLength = 0
+ };
+
+
+ var reparseDataBuffer = new Filesystem.NativeMethods.REPARSE_DATA_BUFFER
+ {
+ ReparseTag = header.ReparseTag,
+ ReparseDataLength = header.ReparseDataLength,
+
+ SubstituteNameOffset = mountPoint.SubstituteNameOffset,
+ SubstituteNameLength = mountPoint.SubstituteNameLength,
+
+ PrintNameOffset = mountPoint.PrintNameOffset,
+ PrintNameLength = mountPoint.PrintNameLength,
+
+ PathBuffer = new byte[MAXIMUM_REPARSE_DATA_BUFFER_SIZE - 16] // 16368
+ };
+
+
+ targetDirBytes.CopyTo(reparseDataBuffer.PathBuffer, 0);
+
+
+ using (var safeBuffer = new SafeGlobalMemoryBufferHandle(Marshal.SizeOf(reparseDataBuffer)))
+ {
+ safeBuffer.StructureToPtr(reparseDataBuffer, false);
+
+ var success = NativeMethods.DeviceIoJunctions(safeFileHandle, NativeMethods.IoControlCode.FSCTL_SET_REPARSE_POINT, safeBuffer, (uint) (targetDirBytes.Length + 20), IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (!success)
+ NativeError.ThrowException(lastError, directoryPath);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.DeleteDirectoryJunction.cs b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.DeleteDirectoryJunction.cs
new file mode 100644
index 000000000..86bff6e5b
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.DeleteDirectoryJunction.cs
@@ -0,0 +1,55 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class FilesystemHelper
+ {
+ /// [AlphaFS] Deletes an NTFS directory junction.
+ internal static void DeleteDirectoryJunction(SafeFileHandle safeFileHandle)
+ {
+ var reparseDataBuffer = new Filesystem.NativeMethods.REPARSE_DATA_BUFFER
+ {
+ ReparseTag = ReparsePointTag.MountPoint,
+ ReparseDataLength = 0,
+ PathBuffer = new byte[MAXIMUM_REPARSE_DATA_BUFFER_SIZE - 16] // 16368
+ };
+
+
+ using (var safeBuffer = new SafeGlobalMemoryBufferHandle(Marshal.SizeOf(reparseDataBuffer)))
+ {
+ safeBuffer.StructureToPtr(reparseDataBuffer, false);
+
+ var success = NativeMethods.DeviceIoJunctions(safeFileHandle, NativeMethods.IoControlCode.FSCTL_DELETE_REPARSE_POINT, safeBuffer, REPARSE_DATA_BUFFER_HEADER_SIZE, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (!success)
+ NativeError.ThrowException(lastError);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetLinkTarget.cs b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetLinkTarget.cs
new file mode 100644
index 000000000..74d9beb3e
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetLinkTarget.cs
@@ -0,0 +1,112 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Text;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class FilesystemHelper
+ {
+ /// [AlphaFS] Get information about the target of a mount point or symbolic link on an NTFS file system.
+ ///
+ ///
+ [SecurityCritical]
+ internal static LinkTargetInfo GetLinkTargetInfo(SafeFileHandle safeFileHandle, string reparsePath)
+ {
+ using (var safeBuffer = GetLinkTargetData(safeFileHandle, reparsePath))
+ {
+ var header = safeBuffer.PtrToStructure();
+
+ var marshalReparseBuffer = (int)Marshal.OffsetOf(typeof(Filesystem.NativeMethods.ReparseDataBufferHeader), "data");
+
+ var dataOffset = (int)(marshalReparseBuffer + (header.ReparseTag == ReparsePointTag.MountPoint
+ ? Marshal.OffsetOf(typeof(Filesystem.NativeMethods.MountPointReparseBuffer), "data")
+ : Marshal.OffsetOf(typeof(Filesystem.NativeMethods.SymbolicLinkReparseBuffer), "data")).ToInt64());
+
+ var dataBuffer = new byte[MAXIMUM_REPARSE_DATA_BUFFER_SIZE - dataOffset];
+
+
+ switch (header.ReparseTag)
+ {
+ // MountPoint can be a junction or mounted drive (mounted drive starts with "\??\Volume").
+
+ case ReparsePointTag.MountPoint:
+ var mountPoint = safeBuffer.PtrToStructure(marshalReparseBuffer);
+
+ safeBuffer.CopyTo(dataOffset, dataBuffer);
+
+ return new LinkTargetInfo(
+ Encoding.Unicode.GetString(dataBuffer, mountPoint.SubstituteNameOffset, mountPoint.SubstituteNameLength),
+ Encoding.Unicode.GetString(dataBuffer, mountPoint.PrintNameOffset, mountPoint.PrintNameLength));
+
+
+ case ReparsePointTag.SymLink:
+ var symLink = safeBuffer.PtrToStructure(marshalReparseBuffer);
+
+ safeBuffer.CopyTo(dataOffset, dataBuffer);
+
+ return new SymbolicLinkTargetInfo(
+ Encoding.Unicode.GetString(dataBuffer, symLink.SubstituteNameOffset, symLink.SubstituteNameLength),
+ Encoding.Unicode.GetString(dataBuffer, symLink.PrintNameOffset, symLink.PrintNameLength), symLink.Flags);
+
+
+ default:
+ throw new UnrecognizedReparsePointException(reparsePath);
+ }
+ }
+ }
+
+
+ /// [AlphaFS] Get information about the target of a mount point or symbolic link on an NTFS file system.
+ ///
+ ///
+ [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
+ [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposing is controlled.")]
+ [SecurityCritical]
+ private static SafeGlobalMemoryBufferHandle GetLinkTargetData(SafeFileHandle safeFileHandle, string reparsePath)
+ {
+ Utils.IsValidHandle(safeFileHandle);
+
+ var bufferSize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
+
+ while (true)
+ {
+ var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize);
+
+ var success = NativeMethods.DeviceIoControl(safeFileHandle, NativeMethods.IoControlCode.FSCTL_GET_REPARSE_POINT, IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+
+ if (success)
+ return safeBuffer;
+
+ bufferSize = Utils.GetDoubledBufferSizeOrThrowException(safeBuffer, lastError, bufferSize, reparsePath);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetLocalDevicePath.cs b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetLocalDevicePath.cs
new file mode 100644
index 000000000..952427e16
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetLocalDevicePath.cs
@@ -0,0 +1,82 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Globalization;
+using Alphaleonis.Win32.Filesystem;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class FilesystemHelper
+ {
+ /// Determines and retrieves the such as: \\.\C: or \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ /// Returns the path string such as: \\.\C: or \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ /// A disk path such as: \\.\PhysicalDrive0
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// A string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ internal static string GetLocalDevicePath(string devicePath)
+ {
+ string unusedLogicalDrive;
+
+ return GetLocalDevicePath(devicePath, out unusedLogicalDrive);
+ }
+
+
+ /// Determines and retrieves the such as: \\.\C: or \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ /// Returns the path string such as: \\.\C: or \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ /// A disk path such as: \\.\PhysicalDrive0
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// A string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ /// If is a logical drive, it is returned in
+ internal static string GetLocalDevicePath(string devicePath, out string logicalDrive)
+ {
+ bool isDrive;
+ bool isVolume;
+ bool isDeviceInfo;
+
+ var validatedDevicePath = GetValidatedDevicePath(devicePath, out isDrive, out isVolume, out isDeviceInfo);
+
+ if (!validatedDevicePath.StartsWith(Path.LogicalDrivePrefix, StringComparison.OrdinalIgnoreCase))
+
+ validatedDevicePath = string.Format(CultureInfo.InvariantCulture, "{0}{1}", isDrive ? Path.LogicalDrivePrefix : string.Empty, Path.RemoveTrailingDirectorySeparator(validatedDevicePath));
+
+
+ if (isDrive)
+ {
+ logicalDrive = Path.GetRegularPathCore(validatedDevicePath, GetFullPathOptions.RemoveTrailingDirectorySeparator, false);
+
+ logicalDrive = validatedDevicePath.Substring(Path.LogicalDrivePrefix.Length);
+ }
+
+ else
+ logicalDrive = null;
+
+
+ return validatedDevicePath;
+ }
+ }
+}
diff --git a/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetValidatedDevicePath.cs b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetValidatedDevicePath.cs
new file mode 100644
index 000000000..8056ba295
--- /dev/null
+++ b/AlphaFS/Device/FilesystemHelper Class/FilesystemHelper.GetValidatedDevicePath.cs
@@ -0,0 +1,72 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using Alphaleonis.Win32.Filesystem;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class FilesystemHelper
+ {
+ /// Determines and retrieves the type of device path.
+ /// The final device path with a .
+ internal static string GetValidatedDevicePath(string devicePath, out bool isDrive, out bool isVolume, out bool isDevice)
+ {
+ if (null == devicePath)
+ throw new ArgumentNullException("devicePath");
+
+ if (devicePath.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "devicePath");
+
+
+ if (devicePath.StartsWith(Path.PhysicalDrivePrefix, StringComparison.OrdinalIgnoreCase))
+ {
+ isDrive = false;
+ isVolume = false;
+ isDevice = true;
+
+ return devicePath;
+ }
+
+
+ // Resolve single drive letter or get root directory information.
+
+ devicePath = devicePath.Length == 1 ? devicePath + Path.VolumeSeparatorChar : Path.GetPathRoot(devicePath, false);
+
+ var hasPath = !Utils.IsNullOrWhiteSpace(devicePath);
+
+
+ isVolume = hasPath && devicePath.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase);
+
+ isDevice = hasPath && !isVolume && devicePath.StartsWith(Path.LongPathPrefix, StringComparison.Ordinal);
+
+ isDrive = hasPath && !isDevice && !isVolume && Path.IsLogicalDriveCore(devicePath, false, PathFormat.LongFullPath);
+
+
+
+ if (!hasPath || !isVolume && !isDevice && !isDrive)
+ throw new ArgumentException(Resources.Argument_must_be_DriveLetter_or_VolumeGuid_or_DevicePath, "devicePath");
+
+
+ return Path.AddTrailingDirectorySeparator(devicePath, false);
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Device.Local.cs b/AlphaFS/Device/Local Class/Device.Local.cs
new file mode 100644
index 000000000..0f7a84500
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Device.Local.cs
@@ -0,0 +1,28 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides static methods to retrieve device resource information from the local host.
+ public static partial class Local
+ {
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.EnumerateDevices.cs b/AlphaFS/Device/Local Class/Local.EnumerateDevices.cs
new file mode 100644
index 000000000..53dca6ee0
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.EnumerateDevices.cs
@@ -0,0 +1,344 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Text;
+using Alphaleonis.Win32.Filesystem;
+using Alphaleonis.Win32.Network;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// [AlphaFS] Enumerates all available devices on the local host.
+ /// Returns an collection from the local host.
+ /// One of the device guids.
+ [SecurityCritical]
+ public static IEnumerable EnumerateDevices(DeviceGuid deviceGuid)
+ {
+ return EnumerateDevicesCore(null, new[] {deviceGuid}, true);
+ }
+
+
+ /// [AlphaFS] Enumerates all available devices of type on the local host.
+ /// Returns an collection from the local host.
+ /// One or more device guids.
+ [SecurityCritical]
+ public static IEnumerable EnumerateDevices(DeviceGuid[] deviceGuid)
+ {
+ return EnumerateDevicesCore(null, deviceGuid, true);
+ }
+
+
+ /// [AlphaFS] Enumerates all available devices of type on the local or remote host.
+ /// Returns an collection for the specified .
+ ///
+ /// MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ /// http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
+ ///
+ /// The name of the local or remote host on which the device resides. null refers to the local host.
+ /// One of the device guids.
+ [SecurityCritical]
+ public static IEnumerable EnumerateDevices(string hostName, DeviceGuid deviceGuid)
+ {
+ return EnumerateDevicesCore(hostName, new[] {deviceGuid}, true);
+ }
+
+
+ /// [AlphaFS] Enumerates all available devices of type on the local or remote host.
+ /// Returns an collection for the specified .
+ ///
+ /// MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ /// http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
+ ///
+ /// The name of the local or remote host on which the device resides. null refers to the local host.
+ /// One or more device guids.
+ [SecurityCritical]
+ public static IEnumerable EnumerateDevices(string hostName, DeviceGuid[] deviceGuid)
+ {
+ return EnumerateDevicesCore(hostName, deviceGuid, true);
+ }
+
+
+ /// [AlphaFS] Enumerates all available devices of type on the local or remote host.
+ /// Returns an collection for the specified .
+ ///
+ /// MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ /// http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
+ ///
+ /// The name of the local or remote host on which the device resides. null refers to the local host.
+ /// One or more device guids.
+ /// true to retrieve all device properties.
+ [SecurityCritical]
+ internal static IEnumerable EnumerateDevicesCore(string hostName, DeviceGuid[] deviceGuid, bool getAllProperties)
+ {
+ SafeCmConnectMachineHandle safeMachineHandle = null;
+
+ var isRemote = !Utils.IsNullOrWhiteSpace(hostName);
+ if (isRemote)
+ {
+ var lastError = NativeMethods.CM_Connect_Machine(Host.GetUncName(hostName), out safeMachineHandle);
+
+ Utils.IsValidHandle(safeMachineHandle, lastError);
+ }
+
+
+ using (safeMachineHandle)
+ foreach (var guid in deviceGuid)
+ foreach (var device in EnumerateDevicesNative(safeMachineHandle, hostName, guid, getAllProperties))
+ yield return device;
+ }
+
+
+ /// [AlphaFS] Enumerates all available devices of type on the local or remote host.
+ /// Returns an collection for the specified .
+ ///
+ /// MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ /// http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx
+ ///
+ /// An initialized instance.
+ /// The name of the local or remote host on which the device resides. null refers to the local host.
+ /// One of the devices.
+ /// true to retrieve all device properties.
+ [SecurityCritical]
+ internal static IEnumerable EnumerateDevicesNative(SafeCmConnectMachineHandle safeMachineHandle, string hostName, DeviceGuid deviceGuid, bool getAllProperties)
+ {
+ var nonNullHostName = !Utils.IsNullOrWhiteSpace(hostName) ? hostName : Environment.MachineName;
+
+ var classGuid = new Guid(Utils.GetEnumDescription(deviceGuid));
+
+
+ // Start at the "Root" of the device tree.
+
+ using (var safeHandle = NativeMethods.SetupDiGetClassDevsEx(ref classGuid, IntPtr.Zero, IntPtr.Zero, NativeMethods.DEVICE_INFORMATION_FLAGS.DIGCF_PRESENT | NativeMethods.DEVICE_INFORMATION_FLAGS.DIGCF_DEVICEINTERFACE, IntPtr.Zero, hostName, IntPtr.Zero))
+ {
+ var lastError = Marshal.GetLastWin32Error();
+
+ Utils.IsValidHandle(safeHandle, lastError);
+
+ uint memberInterfaceIndex = 0;
+ var interfaceStructSize = (uint) Marshal.SizeOf(typeof(NativeMethods.SP_DEVICE_INTERFACE_DATA));
+ var dataStructSize = (uint) Marshal.SizeOf(typeof(NativeMethods.SP_DEVINFO_DATA));
+
+
+ // Start enumerating device interfaces.
+
+ while (true)
+ {
+ var interfaceData = new NativeMethods.SP_DEVICE_INTERFACE_DATA {cbSize = interfaceStructSize};
+
+ var success = NativeMethods.SetupDiEnumDeviceInterfaces(safeHandle, IntPtr.Zero, ref classGuid, memberInterfaceIndex++, ref interfaceData);
+
+ lastError = Marshal.GetLastWin32Error();
+
+ if (!success)
+ {
+ if (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NO_MORE_ITEMS)
+ NativeError.ThrowException(lastError, nonNullHostName);
+
+ break;
+ }
+
+
+ // Create DeviceInfo instance.
+
+ var diData = new NativeMethods.SP_DEVINFO_DATA {cbSize = dataStructSize};
+
+ var deviceInfo = new DeviceInfo(nonNullHostName) {DevicePath = GetDeviceInterfaceDetail(safeHandle, ref interfaceData, ref diData).DevicePath};
+
+
+ if (getAllProperties)
+ {
+ deviceInfo.InstanceId = GetDeviceInstanceId(safeMachineHandle, nonNullHostName, diData);
+
+ SetDeviceProperties(safeHandle, deviceInfo, diData);
+ }
+
+ else
+ SetMinimalDeviceProperties(safeHandle, deviceInfo, diData);
+
+
+ yield return deviceInfo;
+ }
+ }
+ }
+
+
+
+
+ [SecurityCritical]
+ private static string GetDeviceInstanceId(SafeCmConnectMachineHandle safeMachineHandle, string hostNameForException, NativeMethods.SP_DEVINFO_DATA diData)
+ {
+ uint ptrPrevious;
+
+ var lastError = NativeMethods.CM_Get_Parent_Ex(out ptrPrevious, diData.DevInst, 0, safeMachineHandle);
+
+ if (lastError != Win32Errors.CR_SUCCESS)
+ NativeError.ThrowException(lastError, hostNameForException);
+
+
+ using (var safeBuffer = new SafeGlobalMemoryBufferHandle(Filesystem.NativeMethods.DefaultFileBufferSize / 8)) // 512
+ {
+ lastError = NativeMethods.CM_Get_Device_ID_Ex(diData.DevInst, safeBuffer, (uint) safeBuffer.Capacity, 0, safeMachineHandle);
+
+ if (lastError != Win32Errors.CR_SUCCESS)
+ NativeError.ThrowException(lastError, hostNameForException);
+
+
+ // Device InstanceID, such as: "USB\VID_8087&PID_0A2B\5&2EDA7E1E&0&7", "SCSI\DISK&VEN_SANDISK&PROD_X400\4&288ED25&0&000200", ...
+
+ return safeBuffer.PtrToStringUni();
+ }
+ }
+
+
+ /// Builds a Device Interface Detail Data structure.
+ /// Returns an initialized NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA instance.
+ [SecurityCritical]
+ private static NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA GetDeviceInterfaceDetail(SafeHandle safeHandle, ref NativeMethods.SP_DEVICE_INTERFACE_DATA interfaceData, ref NativeMethods.SP_DEVINFO_DATA infoData)
+ {
+ var didd = new NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA {cbSize = (uint) (IntPtr.Size == 4 ? 6 : 8)};
+
+ var success = NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref interfaceData, ref didd, (uint) Marshal.SizeOf(didd), IntPtr.Zero, ref infoData);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (!success)
+ NativeError.ThrowException(lastError);
+
+ return didd;
+ }
+
+
+ [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "lastError")]
+ private static string GetDeviceBusReportedDeviceDescription(SafeHandle safeHandle, NativeMethods.SP_DEVINFO_DATA infoData)
+ {
+ if (!OperatingSystem.IsAtLeast(OperatingSystem.EnumOsName.Windows7))
+ return string.Empty;
+
+
+ const int bufferSize = Filesystem.NativeMethods.DefaultFileBufferSize / 32; // 128
+
+ var descriptionBuffer = new byte[bufferSize];
+ ulong propertyType = 0;
+ var requiredSize = 0;
+
+
+ var success = NativeMethods.SetupDiGetDeviceProperty(safeHandle, ref infoData, ref NativeMethods.DEVPROPKEYS.DeviceBusReportedDeviceDesc, ref propertyType, descriptionBuffer, descriptionBuffer.Length, ref requiredSize, 0);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (success)
+ {
+ var value = Encoding.Unicode.GetString(descriptionBuffer);
+
+ var result = value.Remove(value.IndexOf((char) 0));
+
+ return !Utils.IsNullOrWhiteSpace(result) ? result.Trim() : string.Empty;
+ }
+
+ return string.Empty;
+ }
+
+
+ [SecurityCritical]
+ private static string GetDeviceRegistryProperty(SafeHandle safeHandle, NativeMethods.SP_DEVINFO_DATA infoData, NativeMethods.SPDRP property)
+ {
+ var bufferSize = Filesystem.NativeMethods.DefaultFileBufferSize / 8; // 512
+
+ while (true)
+ using (var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize))
+ {
+ var success = NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref infoData, property, IntPtr.Zero, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (success)
+ {
+ var value = safeBuffer.PtrToStringUni();
+
+ return !Utils.IsNullOrWhiteSpace(value) ? value.Trim() : string.Empty;
+ }
+
+
+ // MSDN: SetupDiGetDeviceRegistryProperty returns ERROR_INVALID_DATA error code if
+ // the requested property does not exist for a device or if the property data is not valid.
+
+ if (lastError == Win32Errors.ERROR_INVALID_DATA)
+ return string.Empty;
+
+
+ bufferSize = Utils.GetDoubledBufferSizeOrThrowException(safeBuffer, lastError, bufferSize, property.ToString());
+ }
+ }
+
+
+ [SecurityCritical]
+ private static void SetDeviceProperties(SafeHandle safeHandle, DeviceInfo deviceInfo, NativeMethods.SP_DEVINFO_DATA infoData)
+ {
+ SetMinimalDeviceProperties(safeHandle, deviceInfo, infoData);
+
+
+ deviceInfo.BaseContainerId = new Guid(GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.BaseContainerId));
+
+ deviceInfo.ClassGuid = new Guid(GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.ClassGuid));
+
+ deviceInfo.CompatibleIds = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.CompatibleIds);
+
+ deviceInfo.DeviceClass = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.Class);
+
+ deviceInfo.DeviceDriver = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.Driver);
+
+ deviceInfo.EnumeratorName = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.EnumeratorName);
+
+ deviceInfo.HardwareId = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.HardwareId);
+
+ deviceInfo.LocationInformation = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.LocationInformation);
+
+ deviceInfo.LocationPaths = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.LocationPaths);
+
+ deviceInfo.Manufacturer = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.Manufacturer);
+
+ deviceInfo.Service = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.Service);
+ }
+
+
+ [SecurityCritical]
+ private static void SetMinimalDeviceProperties(SafeHandle safeHandle, DeviceInfo deviceInfo, NativeMethods.SP_DEVINFO_DATA infoData)
+ {
+ deviceInfo.BusReportedDeviceDescription = GetDeviceBusReportedDeviceDescription(safeHandle, infoData);
+
+ deviceInfo.DeviceDescription = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.DeviceDescription);
+
+ deviceInfo.FriendlyName = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.FriendlyName);
+
+ deviceInfo.PhysicalDeviceObjectName = GetDeviceRegistryProperty(safeHandle, infoData, NativeMethods.SPDRP.PhysicalDeviceObjectName);
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.EnumeratePhysicalDisks.cs b/AlphaFS/Device/Local Class/Local.EnumeratePhysicalDisks.cs
new file mode 100644
index 000000000..c0f802609
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.EnumeratePhysicalDisks.cs
@@ -0,0 +1,67 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Collections.Generic;
+using System.Security;
+using Alphaleonis.Win32.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// [AlphaFS] Enumerates the physical disks (including CD/DVD-ROM devices) on the Computer, populated with volume/logical drive information.
+ /// Returns an collection that represents the physical disks on the Computer.
+ [SecurityCritical]
+ public static IEnumerable EnumeratePhysicalDisks()
+ {
+ return EnumeratePhysicalDisksCore(ProcessContext.IsElevatedProcess, -1);
+ }
+
+
+ /// [AlphaFS] Enumerates the physical disks (including CD/DVD-ROM devices) on the Computer, populated with volume/logical drive information.
+ /// Returns an collection that represents the physical disks on the Computer.
+ /// Retrieve instances by device number.
+ [SecurityCritical]
+ public static IEnumerable EnumeratePhysicalDisks(int deviceNumber)
+ {
+ return EnumeratePhysicalDisksCore(ProcessContext.IsElevatedProcess, deviceNumber);
+ }
+
+
+ /// [AlphaFS] Enumerates the physical disks (including CD/DVD-ROM devices) on the Computer, populated with volume/logical drive information.
+ /// Returns an collection that represents the physical disks on the Computer.
+ /// true indicates the current process is in an elevated state, allowing to retrieve more data.
+ /// Retrieve a instance by device number.
+ [SecurityCritical]
+ internal static IEnumerable EnumeratePhysicalDisksCore(bool isElevated, int deviceNumber)
+ {
+ foreach (var deviceInfo in EnumerateDevicesCore(null, new []{DeviceGuid.Disk, DeviceGuid.CDRom, DeviceGuid.Wpd, DeviceGuid.WpdPrivate}, false))
+ {
+ string unusedPhysicalDriveNumberPath;
+
+ var storageDeviceInfo = GetStorageDeviceInfo(isElevated, true, deviceNumber, deviceInfo.DevicePath, out unusedPhysicalDriveNumberPath);
+
+ if (null != storageDeviceInfo)
+ yield return new PhysicalDiskInfo(deviceNumber, storageDeviceInfo, deviceInfo);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetDeviceIoData.cs b/AlphaFS/Device/Local Class/Local.GetDeviceIoData.cs
new file mode 100644
index 000000000..9d40cc82e
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetDeviceIoData.cs
@@ -0,0 +1,70 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Object needs to be disposed by caller.")]
+ [SecurityCritical]
+ private static SafeGlobalMemoryBufferHandle GetDeviceIoData(SafeFileHandle safeFileHandle, NativeMethods.IoControlCode controlCode, string pathForException, out int lastError, int size = -1)
+ {
+ Utils.IsValidHandle(safeFileHandle);
+
+ var bufferSize = size > -1 ? size : Marshal.SizeOf(typeof(T));
+
+ while (true)
+ {
+ var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize);
+
+ var success = NativeMethods.DeviceIoControl(safeFileHandle, controlCode, IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero, IntPtr.Zero);
+
+ lastError = Marshal.GetLastWin32Error();
+
+
+ if (success)
+ return safeBuffer;
+
+
+ using (safeBuffer)
+ {
+ if (lastError == Win32Errors.ERROR_NOT_READY ||
+
+ // A logical drive path like "\\.\D:" fails on a dynamic disk.
+ lastError == Win32Errors.ERROR_INVALID_FUNCTION ||
+
+ // Request device number from a DeviceGuid.Image device.
+ lastError == Win32Errors.ERROR_NOT_SUPPORTED)
+
+ return null;
+ }
+
+ bufferSize = Utils.GetDoubledBufferSizeOrThrowException(safeBuffer, lastError, bufferSize, pathForException);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetDevicePowerState.cs b/AlphaFS/Device/Local Class/Local.GetDevicePowerState.cs
new file mode 100644
index 000000000..d50f8264c
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetDevicePowerState.cs
@@ -0,0 +1,48 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// [AlphaFS] Retrieves the current power state for the specified storage device.
+ /// Returns true if the storage device is in the working state; otherwise, false.
+ ///
+ /// A disk path such as: \\.\PhysicalDrive0
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// A string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ [SecurityCritical]
+ public static bool GetDevicePowerState(string devicePath)
+ {
+ using (var safeFileHandle = OpenDevice(FilesystemHelper.GetLocalDevicePath(devicePath), NativeMethods.FILE_ANY_ACCESS))
+ {
+ bool isOn;
+
+ return NativeMethods.GetDevicePowerState(safeFileHandle, out isOn) && isOn;
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetDiskGeometryEx.cs b/AlphaFS/Device/Local Class/Local.GetDiskGeometryEx.cs
new file mode 100644
index 000000000..a5a31eea9
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetDiskGeometryEx.cs
@@ -0,0 +1,88 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// Returns information about the physical disk's geometry (media type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector).
+ [SecurityCritical]
+ private static NativeMethods.DISK_GEOMETRY_EX GetDiskGeometryEx(SafeFileHandle safeFileHandle, string pathForException)
+ {
+ var bufferSize = 128;
+
+ while (true)
+ using (var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize))
+ {
+ var success = NativeMethods.DeviceIoControl(safeFileHandle, NativeMethods.IoControlCode.IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (success)
+ {
+ var typeOf = typeof(NativeMethods.DISK_GEOMETRY);
+ var sizeOf = Marshal.SizeOf(typeOf); // 24
+
+ var diskGeometryEx = new NativeMethods.DISK_GEOMETRY_EX
+ {
+ Geometry = safeBuffer.PtrToStructure(),
+
+ DiskSize = safeBuffer.ReadInt64(sizeOf)
+ };
+
+
+ var offset = (uint) sizeOf + sizeof(long); // 32
+
+ diskGeometryEx.PartitionInformation = safeBuffer.PtrToStructure((int) offset);
+
+
+ //// Intermittently throws: System.AccessViolationException: Attempted to read or write protected memory.
+ //// Observed when mounting an .iso file.
+
+ //offset += diskGeometryEx.PartitionInformation.SizeOfPartitionInfo;
+
+ //diskGeometryEx.DiskDetectionInfo = safeBuffer.PtrToStructure((int) offset);
+
+ return diskGeometryEx;
+ }
+
+
+ if (lastError == Win32Errors.ERROR_NOT_READY ||
+
+ // A logical drive path like "\\.\D:" fails on a dynamic disk.
+ lastError == Win32Errors.ERROR_INVALID_FUNCTION ||
+
+ // Request device number from a DeviceGuid.Image device.
+ lastError == Win32Errors.ERROR_NOT_SUPPORTED)
+
+ return new NativeMethods.DISK_GEOMETRY_EX();
+
+
+ bufferSize = Utils.GetDoubledBufferSizeOrThrowException(safeBuffer, lastError, bufferSize, pathForException);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetStorageAdapterInfo.cs b/AlphaFS/Device/Local Class/Local.GetStorageAdapterInfo.cs
new file mode 100644
index 000000000..168f45b64
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetStorageAdapterInfo.cs
@@ -0,0 +1,62 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Security;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// [AlphaFS] Retrieves the storage adapter of the device that is related to the logical drive name, volume or .
+ /// Returns a instance that represent the storage device that is related to .
+ ///
+ [SecurityCritical]
+ internal static StorageAdapterInfo GetStorageAdapterInfo(SafeFileHandle safeFileHandle, int deviceNumber, string localDevicePath, string busReportedDeviceDescription)
+ {
+ var storagePropertyQuery = new NativeMethods.STORAGE_PROPERTY_QUERY
+ {
+ PropertyId = NativeMethods.STORAGE_PROPERTY_ID.StorageAdapterProperty,
+ QueryType = NativeMethods.STORAGE_QUERY_TYPE.PropertyStandardQuery
+ };
+
+
+ using (var safeBuffer = InvokeDeviceIoData(safeFileHandle, NativeMethods.IoControlCode.IOCTL_STORAGE_QUERY_PROPERTY, storagePropertyQuery, localDevicePath, Filesystem.NativeMethods.DefaultFileBufferSize / 8))
+
+ if (null != safeBuffer)
+ {
+ var storageAdapterInfo = new StorageAdapterInfo(deviceNumber, safeBuffer.PtrToStructure());
+
+
+ if (!Utils.IsNullOrWhiteSpace(busReportedDeviceDescription))
+
+ storageAdapterInfo.BusReportedDeviceDescription = busReportedDeviceDescription;
+
+
+ return storageAdapterInfo;
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetStorageDeviceInfo.cs b/AlphaFS/Device/Local Class/Local.GetStorageDeviceInfo.cs
new file mode 100644
index 000000000..037f265bd
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetStorageDeviceInfo.cs
@@ -0,0 +1,106 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Security;
+using System.Security.AccessControl;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// Returns a instance that represent the storage device that is related to .
+ ///
+ [SecurityCritical]
+ internal static StorageDeviceInfo GetStorageDeviceInfo(bool isElevated, bool isDevice, int deviceNumber, string devicePath, out string localDevicePath)
+ {
+ localDevicePath = FilesystemHelper.GetLocalDevicePath(devicePath);
+ var getByDeviceNumber = deviceNumber > -1;
+ var retry = false;
+
+ Retry:
+
+ int lastError;
+
+ // On retry, the drive is accessed using "\\.\PhysicalDriveX" path format which is the device, not the volume/logical drive.
+
+ using (var safeFileHandle = OpenDevice(localDevicePath, isElevated ? FileSystemRights.Read : NativeMethods.FILE_ANY_ACCESS))
+
+ using (var safeBuffer = GetDeviceIoData(safeFileHandle, NativeMethods.IoControlCode.IOCTL_STORAGE_GET_DEVICE_NUMBER, localDevicePath, out lastError))
+ {
+ if (null != safeBuffer)
+ {
+ var storageDeviceInfo = new StorageDeviceInfo(safeBuffer.PtrToStructure());
+
+ if (getByDeviceNumber && deviceNumber != storageDeviceInfo.DeviceNumber)
+ return null;
+
+ SetStorageDeviceInfoData(isElevated, safeFileHandle, localDevicePath, storageDeviceInfo);
+
+
+ if (!localDevicePath.StartsWith(Path.PhysicalDrivePrefix, StringComparison.OrdinalIgnoreCase))
+ localDevicePath = null;
+
+ return storageDeviceInfo;
+ }
+
+
+ // A logical drive path on a dynamic disk like "\\.\D:" fails.
+
+ if (!retry && !isDevice && lastError == Win32Errors.ERROR_INVALID_FUNCTION)
+ foreach (var physicalDeviceNumber in GetDeviceNumbersForVolume(safeFileHandle, localDevicePath))
+ {
+ if (getByDeviceNumber && deviceNumber != physicalDeviceNumber)
+ continue;
+
+ // StorageDeviceInfo.PartitionNumber = 0 when opening the device as "\\.\PhysicalDriveX".
+
+ localDevicePath = Path.PhysicalDrivePrefix + physicalDeviceNumber.ToString(CultureInfo.InvariantCulture);
+
+ isDevice = true;
+ retry = true;
+
+ goto Retry;
+ }
+ }
+
+ return null;
+ }
+
+
+ /// Returns an of physical drive device numbers used by the specified volume.
+ [SecurityCritical]
+ private static IEnumerable GetDeviceNumbersForVolume(SafeFileHandle safeFileHandle, string pathForException)
+ {
+ var volDiskExtents = GetVolumeDiskExtents(safeFileHandle, pathForException);
+
+ if (volDiskExtents.HasValue)
+
+ foreach (var extent in volDiskExtents.Value.Extents)
+
+ yield return (int) extent.DiskNumber;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetStoragePartitionInfo.cs b/AlphaFS/Device/Local Class/Local.GetStoragePartitionInfo.cs
new file mode 100644
index 000000000..9153ec71c
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetStoragePartitionInfo.cs
@@ -0,0 +1,67 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// [AlphaFS] Retrieves information about the partitions on a disk and the features of each partition.
+ /// Returns a instance that represent the partition info that is related to .
+ ///
+ [SecurityCritical]
+ internal static StoragePartitionInfo GetStoragePartitionInfo(SafeFileHandle safeFileHandle, int deviceNumber, string localDevicePath)
+ {
+ using (var safeBuffer = InvokeDeviceIoData(safeFileHandle, NativeMethods.IoControlCode.IOCTL_DISK_GET_DRIVE_LAYOUT_EX, 0, localDevicePath, Filesystem.NativeMethods.DefaultFileBufferSize / 4))
+
+ if (null != safeBuffer)
+ {
+ var layout = safeBuffer.PtrToStructure();
+
+ // Sanity check.
+ if (layout.PartitionCount <= 256)
+ {
+ var driveStructureSize = Marshal.SizeOf(typeof(NativeMethods.DRIVE_LAYOUT_INFORMATION_EX)); // 48
+
+ var partitionStructureSize = Marshal.SizeOf(typeof(NativeMethods.PARTITION_INFORMATION_EX)); // 144
+
+ var partitions = new NativeMethods.PARTITION_INFORMATION_EX[layout.PartitionCount];
+
+
+ for (var i = 0; i <= layout.PartitionCount - 1; i++)
+
+ partitions[i] = safeBuffer.PtrToStructure(driveStructureSize + i * partitionStructureSize);
+
+
+ var disk = GetDiskGeometryEx(safeFileHandle, localDevicePath);
+
+ return new StoragePartitionInfo(deviceNumber, disk, layout, partitions);
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.GetVolumeDiskExtents.cs b/AlphaFS/Device/Local Class/Local.GetVolumeDiskExtents.cs
new file mode 100644
index 000000000..f95f5dcaf
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.GetVolumeDiskExtents.cs
@@ -0,0 +1,78 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// Retrieves the physical location and disk number of a specified volume on one or more disks.
+ [SecurityCritical]
+ private static NativeMethods.VOLUME_DISK_EXTENTS? GetVolumeDiskExtents(SafeFileHandle safeFileHandle, string pathForException)
+ {
+ var structSize = Marshal.SizeOf(typeof(NativeMethods.DISK_EXTENT_SINGLE));
+
+ var bufferSize = structSize;
+
+
+ // 2018-06-20 Note: Although the code should handle multiple disk extents, it has only been tested with one disk extent.
+
+ while (true)
+ using (var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize))
+ {
+ var success = NativeMethods.DeviceIoControl(safeFileHandle, NativeMethods.IoControlCode.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+ if (success)
+ {
+ var numberOfExtents = safeBuffer.ReadInt64();
+
+ var diskExtent = new NativeMethods.DISK_EXTENT[numberOfExtents];
+
+ for (int i = 0, itemOffset = 0; i < numberOfExtents; i++, itemOffset = structSize * i)
+ {
+ var single = safeBuffer.PtrToStructure(itemOffset);
+
+ diskExtent[i].DiskNumber = single.Extent.DiskNumber;
+ diskExtent[i].ExtentLength = single.Extent.ExtentLength;
+ diskExtent[i].StartingOffset = single.Extent.StartingOffset;
+ }
+
+ return new NativeMethods.VOLUME_DISK_EXTENTS
+ {
+ NumberOfDiskExtents = (uint) numberOfExtents,
+ Extents = diskExtent
+ };
+ }
+
+
+ // When ERROR_MORE_DATA, the drive is part of a mirror or volume, or the volume is on multiple disks.
+
+ bufferSize = Utils.GetDoubledBufferSizeOrThrowException(safeBuffer, lastError, bufferSize, pathForException);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.InvokeDeviceIoData.cs b/AlphaFS/Device/Local Class/Local.InvokeDeviceIoData.cs
new file mode 100644
index 000000000..581dd8e05
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.InvokeDeviceIoData.cs
@@ -0,0 +1,71 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Security;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// Invokes InvokeIoControl with the specified input and specified size.
+ [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Object needs to be disposed by caller.")]
+ [SecurityCritical]
+ internal static SafeGlobalMemoryBufferHandle InvokeDeviceIoData(SafeFileHandle safeFileHandle, NativeMethods.IoControlCode controlCode, T anyObject, string pathForException, int size = -1)
+ {
+ Utils.IsValidHandle(safeFileHandle);
+
+ var bufferSize = size > -1 ? size : Marshal.SizeOf(anyObject);
+
+ while (true)
+ {
+ var safeBuffer = new SafeGlobalMemoryBufferHandle(bufferSize);
+
+ var success = NativeMethods.DeviceIoControlAnyObjectGetSet(safeFileHandle, controlCode, anyObject, (uint) bufferSize, safeBuffer, (uint) safeBuffer.Capacity, IntPtr.Zero, IntPtr.Zero);
+
+ var lastError = Marshal.GetLastWin32Error();
+
+
+ if (success)
+ return safeBuffer;
+
+
+ using (safeBuffer)
+ {
+ if (lastError == Win32Errors.ERROR_NOT_READY ||
+
+ // A logical drive path like "\\.\D:" fails on a dynamic disk.
+ lastError == Win32Errors.ERROR_INVALID_FUNCTION ||
+
+ // Request device number from a DeviceGuid.Image device.
+ lastError == Win32Errors.ERROR_NOT_SUPPORTED)
+
+ return null;
+ }
+
+ bufferSize = Utils.GetDoubledBufferSizeOrThrowException(safeBuffer, lastError, bufferSize, pathForException);
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.OpenDevice.cs b/AlphaFS/Device/Local Class/Local.OpenDevice.cs
new file mode 100644
index 000000000..f44aab77d
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.OpenDevice.cs
@@ -0,0 +1,64 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.IO;
+using System.Security;
+using System.Security.AccessControl;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
+using File = Alphaleonis.Win32.Filesystem.File;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ /// Opens a physical disk or volume/logical drive for read access.
+ /// Returns a instance.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// A disk path such as: \\.\PhysicalDrive0
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// A string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ /// If no elevated access is needed to access the physical disk or volume/logical drive, specify 0 for this parameter.
+ [SecurityCritical]
+ public static SafeFileHandle OpenDevice(string devicePath, FileSystemRights fileSystemRights)
+ {
+ // fileSystemRights: If this parameter is 0 (FILE_ANY_ACCESS), the application can query certain metadata such as file, directory, or device attributes
+ // without accessing that file or device, even if GENERIC_READ access would have been denied.
+ //
+ // You cannot request an access mode that conflicts with the sharing mode that is specified by the dwShareMode parameter in an open request that already has an open handle.
+ //
+ // When opening a volume or removable media drive (for example, a floppy disk drive or flash memory thumb drive), the lpFileName string should be the following form: "\\.\X:".
+ // Do not use a trailing backslash (\), which indicates the root directory of a drive.
+ //
+ // When opening a volume or floppy disk, the dwShareMode parameter must have the FILE_SHARE_WRITE flag.
+
+
+ return File.CreateFileCore(null, null, devicePath, ExtendedFileAttributes.Normal | ExtendedFileAttributes.NoBuffering, null, FileMode.Open, fileSystemRights, FileShare.ReadWrite, false, false, PathFormat.LongFullPath);
+ }
+ }
+}
diff --git a/AlphaFS/Device/Local Class/Local.SetStorageDeviceInfoData.cs b/AlphaFS/Device/Local Class/Local.SetStorageDeviceInfoData.cs
new file mode 100644
index 000000000..19587134f
--- /dev/null
+++ b/AlphaFS/Device/Local Class/Local.SetStorageDeviceInfoData.cs
@@ -0,0 +1,82 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Security;
+using Microsoft.Win32.SafeHandles;
+
+namespace Alphaleonis.Win32.Device
+{
+ public static partial class Local
+ {
+ [SecurityCritical]
+ private static void SetStorageDeviceInfoData(bool isElevated, SafeFileHandle safeFileHandle, string pathForException, StorageDeviceInfo storageDeviceInfo)
+ {
+ var storagePropertyQuery = new NativeMethods.STORAGE_PROPERTY_QUERY
+ {
+ PropertyId = NativeMethods.STORAGE_PROPERTY_ID.StorageDeviceProperty,
+ QueryType = NativeMethods.STORAGE_QUERY_TYPE.PropertyStandardQuery
+ };
+
+
+ using (var safeBuffer = InvokeDeviceIoData(safeFileHandle, NativeMethods.IoControlCode.IOCTL_STORAGE_QUERY_PROPERTY, storagePropertyQuery, pathForException, Filesystem.NativeMethods.DefaultFileBufferSize / 2))
+ {
+ var deviceDescriptor = safeBuffer.PtrToStructure();
+
+
+ storageDeviceInfo.BusType = (StorageBusType) deviceDescriptor.BusType;
+
+ storageDeviceInfo.CommandQueueing = deviceDescriptor.CommandQueueing;
+
+ storageDeviceInfo.ProductId = safeBuffer.PtrToStringAnsi((int) deviceDescriptor.ProductIdOffset).Trim();
+
+ storageDeviceInfo.ProductRevision = safeBuffer.PtrToStringAnsi((int) deviceDescriptor.ProductRevisionOffset).Trim();
+
+ storageDeviceInfo.RemovableMedia = deviceDescriptor.RemovableMedia;
+
+ storageDeviceInfo.SerialNumber = safeBuffer.PtrToStringAnsi((int) deviceDescriptor.SerialNumberOffset).Trim();
+
+ storageDeviceInfo.VendorId = safeBuffer.PtrToStringAnsi((int) deviceDescriptor.VendorIdOffset).Trim();
+
+
+ if (Utils.IsNullOrWhiteSpace(storageDeviceInfo.ProductRevision) || storageDeviceInfo.ProductRevision.Length == 1)
+ storageDeviceInfo.ProductRevision = string.Empty;
+
+ if (Utils.IsNullOrWhiteSpace(storageDeviceInfo.SerialNumber) || storageDeviceInfo.SerialNumber.Length == 1)
+ storageDeviceInfo.SerialNumber = string.Empty;
+
+ if (Utils.IsNullOrWhiteSpace(storageDeviceInfo.VendorId) || storageDeviceInfo.VendorId.Length == 1)
+ storageDeviceInfo.VendorId = string.Empty;
+ }
+
+
+ // Get disk total size.
+
+ if (isElevated)
+ {
+ int lastError;
+
+ using (var safeBuffer = GetDeviceIoData(safeFileHandle,NativeMethods.IoControlCode.IOCTL_DISK_GET_LENGTH_INFO, pathForException, out lastError))
+
+ storageDeviceInfo.TotalSize = null != safeBuffer ? safeBuffer.ReadInt64() : 0;
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.DeviceManagement.cs b/AlphaFS/Device/Native Methods/NativeMethods.DeviceManagement.cs
similarity index 60%
rename from AlphaFS/Filesystem/Native Methods/NativeMethods.DeviceManagement.cs
rename to AlphaFS/Device/Native Methods/NativeMethods.DeviceManagement.cs
index 7184e9994..4b2348cb8 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.DeviceManagement.cs
+++ b/AlphaFS/Device/Native Methods/NativeMethods.DeviceManagement.cs
@@ -19,94 +19,82 @@
* THE SOFTWARE.
*/
-using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
+using Microsoft.Win32.SafeHandles;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
#region CM_Xxx
/// The CM_Connect_Machine function creates a connection to a remote machine.
- ///
- /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
- /// You cannot access remote machines when running on these versions of Windows.
- /// Available in Microsoft Windows 2000 and later versions of Windows.
- ///
- /// Name of the unc server.
- /// [out] The ph machine.
///
/// If the operation succeeds, the function returns CR_SUCCESS.
/// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CM_Connect_MachineW"), SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.I4)]
- public static extern int CM_Connect_Machine([MarshalAs(UnmanagedType.LPWStr)] string uncServerName, out SafeCmConnectMachineHandle phMachine);
-
- ///
- /// The CM_Get_Device_ID_Ex function retrieves the device instance ID for a specified device instance on a local or a remote machine.
- ///
///
+ /// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
/// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
/// You cannot access remote machines when running on these versions of Windows.
- ///
- /// Available in Microsoft Windows 2000 and later versions of Windows.
///
- /// The dn development instance.
- /// The buffer.
- /// Length of the buffer.
- /// The ul flags.
- /// The machine.
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CM_Connect_MachineW"), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.I4)]
+ internal static extern int CM_Connect_Machine([MarshalAs(UnmanagedType.LPWStr)] string uncServerName, out SafeCmConnectMachineHandle phMachine);
+
+
+ /// The CM_Get_Device_ID_Ex function retrieves the device instance ID for a specified device instance on a local or a remote machine.
///
/// If the operation succeeds, the function returns CR_SUCCESS.
/// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
+ ///
+ /// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
+ /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ ///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CM_Get_Device_ID_ExW"), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.I4)]
- public static extern int CM_Get_Device_ID_Ex([MarshalAs(UnmanagedType.U4)] uint dnDevInst, SafeGlobalMemoryBufferHandle buffer, [MarshalAs(UnmanagedType.U4)] uint bufferLen, [MarshalAs(UnmanagedType.U4)] uint ulFlags, SafeCmConnectMachineHandle hMachine);
+ internal static extern int CM_Get_Device_ID_Ex([MarshalAs(UnmanagedType.U4)] uint dnDevInst, SafeGlobalMemoryBufferHandle buffer, [MarshalAs(UnmanagedType.U4)] uint bufferLen, [MarshalAs(UnmanagedType.U4)] uint ulFlags, SafeCmConnectMachineHandle hMachine);
- ///
- /// The CM_Disconnect_Machine function removes a connection to a remote machine.
- ///
+
+ /// The CM_Disconnect_Machine function removes a connection to a remote machine.
+ ///
+ /// If the operation succeeds, the function returns CR_SUCCESS.
+ /// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
+ ///
///
+ /// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
/// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
/// You cannot access remote machines when running on these versions of Windows.
+ ///
/// SetLastError is set to false.
- /// Available in Microsoft Windows 2000 and later versions of Windows.
///
- /// The machine.
- ///
- /// If the operation succeeds, the function returns CR_SUCCESS.
- /// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
- ///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.I4)]
internal static extern int CM_Disconnect_Machine(IntPtr hMachine);
- ///
- /// The CM_Get_Parent_Ex function obtains a device instance handle to the parent node of a specified device node (devnode) in a local
- /// or a remote machine's device tree.
- ///
- ///
- /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
- /// You cannot access remote machines when running on these versions of Windows.
- /// Available in Microsoft Windows 2000 and later versions of Windows.
- ///
- /// [out] The pdn development instance.
- /// The dn development instance.
- /// The ul flags.
- /// The machine.
+
+ /// The CM_Get_Parent_Ex function obtains a device instance handle to the parent node of a specified device node (devnode) in a local or a remote machine's device tree.
///
/// If the operation succeeds, the function returns CR_SUCCESS.
/// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
///
+ ///
+ /// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
+ /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed.
+ /// You cannot access remote machines when running on these versions of Windows.
+ ///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.I4)]
@@ -114,95 +102,74 @@ internal static partial class NativeMethods
#endregion // CM_Xxx
+
#region DeviceIoControl
- /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
- ///
- /// If the operation completes successfully, the return value is nonzero.
- /// If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.
- ///
+ /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
///
- /// To retrieve a handle to the device, you must call the function with either the name of a device or
- /// the name of the driver associated with a device.
+ /// To retrieve a handle to the device, you must call the function with either the name of a device or the name of the driver associated with a device.
/// To specify a device name, use the following format: \\.\DeviceName
/// Minimum supported client: Windows XP
/// Minimum supported server: Windows Server 2003
///
- /// The device.
- /// The i/o control code.
- /// Buffer for in data.
- /// Size of the in buffer.
- /// Buffer for out data.
- /// Size of the out buffer.
- /// [out] The bytes returned.
- /// The overlapped.
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool DeviceIoControl(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] uint dwIoControlCode, IntPtr lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, SafeGlobalMemoryBufferHandle lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, [MarshalAs(UnmanagedType.U4)] out uint lpBytesReturned, IntPtr lpOverlapped);
-
- /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
+ ///
///
/// If the operation completes successfully, the return value is nonzero.
/// If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.
///
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool DeviceIoControl(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] IoControlCode dwIoControlCode, IntPtr lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, SafeGlobalMemoryBufferHandle lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, IntPtr lpBytesReturned, IntPtr lpOverlapped);
+
+
+ /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
///
- /// To retrieve a handle to the device, you must call the function with either the name of a device or
- /// the name of the driver associated with a device.
+ /// To retrieve a handle to the device, you must call the function with either the name of a device or the name of the driver associated with a device.
/// To specify a device name, use the following format: \\.\DeviceName
/// Minimum supported client: Windows XP
/// Minimum supported server: Windows Server 2003
///
- /// The device.
- /// The i/o control code.
- /// Buffer for in data.
- /// Size of the in buffer.
- /// Buffer for out data.
- /// Size of the out buffer.
- /// [out] The bytes returned.
- /// The overlapped.
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DeviceIoControl"), SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool DeviceIoControl2(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] uint dwIoControlCode, SafeGlobalMemoryBufferHandle lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, IntPtr lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, [MarshalAs(UnmanagedType.U4)] out uint lpBytesReturned, IntPtr lpOverlapped);
-
- /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
+ ///
///
/// If the operation completes successfully, the return value is nonzero.
/// If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.
///
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DeviceIoControl"), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool DeviceIoControlAnyObjectGetSet(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] IoControlCode dwIoControlCode, [MarshalAs(UnmanagedType.AsAny)] object lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, SafeGlobalMemoryBufferHandle lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, IntPtr lpBytesReturned, IntPtr lpOverlapped);
+
+
+ /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
///
- /// To retrieve a handle to the device, you must call the function with either the name of a device or
- /// the name of the driver associated with a device.
+ /// To retrieve a handle to the device, you must call the function with either the name of a device or the name of the driver associated with a device.
/// To specify a device name, use the following format: \\.\DeviceName
/// Minimum supported client: Windows XP
/// Minimum supported server: Windows Server 2003
///
- /// The device.
- /// The i/o control code.
- /// Buffer for in data.
- /// Size of the in buffer.
- /// Buffer for out data.
- /// Size of the out buffer.
- /// [out] The bytes returned.
- /// The overlapped.
+ ///
+ ///
+ /// If the operation completes successfully, the return value is nonzero.
+ /// If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.
+ ///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DeviceIoControl"), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool DeviceIoControlUnknownSize(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] uint dwIoControlCode, [MarshalAs(UnmanagedType.AsAny)] object lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, [MarshalAs(UnmanagedType.AsAny)] [Out] object lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, [MarshalAs(UnmanagedType.U4)] out uint lpBytesReturned, IntPtr lpOverlapped);
+ internal static extern bool DeviceIoJunctions(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] IoControlCode dwIoControlCode, SafeGlobalMemoryBufferHandle lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, IntPtr lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, IntPtr lpBytesReturned, IntPtr lpOverlapped);
#endregion // DeviceIoControl
+
#region SetupDiXxx
- ///
- /// The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory.
- ///
+ /// The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory.
///
- /// SetLastError is set to false.
/// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
+ /// SetLastError is set to false.
///
- /// Information describing the development.
+ ///
///
/// The function returns TRUE if it is successful.
/// Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError.
@@ -212,105 +179,135 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetupDiDestroyDeviceInfoList(IntPtr hDevInfo);
- ///
- /// The SetupDiEnumDeviceInterfaces function enumerates the device interfaces that are contained in a device information set.
- ///
+
+ /// The SetupDiEnumDeviceInterfaces function enumerates the device interfaces that are contained in a device information set.
///
- /// Repeated calls to this function return an structure for a different device
- /// interface.
- /// This function can be called repeatedly to get information about interfaces in a device information set that are
- /// associated
- /// with a particular device information element or that are associated with all device information elements.
/// Available in Microsoft Windows 2000 and later versions of Windows.
///
- /// Information describing the development.
- /// Information describing the development.
- /// [in,out] Unique identifier for the interface class.
- /// Zero-based index of the member.
- /// [in,out] Information describing the device interface.
+ ///
///
/// SetupDiEnumDeviceInterfaces returns TRUE if the function completed without error.
- /// If the function completed with an error, FALSE is returned and the error code for the failure can be retrieved by calling
- /// GetLastError.
+ /// If the function completed with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetupDiEnumDeviceInterfaces(SafeHandle hDevInfo, IntPtr devInfo, ref Guid interfaceClassGuid, [MarshalAs(UnmanagedType.U4)] uint memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData);
- ///
- /// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements
- /// for a local or a remote computer.
- ///
+
+ /// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer.
///
- /// The caller of SetupDiGetClassDevsEx must delete the returned device information set when it is no longer needed by calling
- /// .
/// Available in Microsoft Windows 2000 and later versions of Windows.
///
- /// [in,out] Unique identifier for the class.
- /// The enumerator.
- /// The parent.
- /// The devs ex flags.
- /// Set the device information belongs to.
- /// Name of the machine.
- /// The reserved.
+ ///
///
- /// If the operation succeeds, SetupDiGetClassDevsEx returns a handle to a device information set that contains all installed
- /// devices that matched the supplied parameters.
- /// If the operation fails, the function returns INVALID_HANDLE_VALUE. To get extended error information, call
- /// GetLastError.
+ /// If the operation succeeds, SetupDiGetClassDevsEx returns a handle to a device information set that contains all installed devices that matched the supplied parameters.
+ /// If the operation fails, the function returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- internal static extern SafeSetupDiClassDevsExHandle SetupDiGetClassDevsEx(ref Guid classGuid, IntPtr enumerator, IntPtr hwndParent, [MarshalAs(UnmanagedType.U4)] SetupDiGetClassDevsExFlags devsExFlags, IntPtr deviceInfoSet, [MarshalAs(UnmanagedType.LPWStr)] string machineName, IntPtr reserved);
+ internal static extern SafeSetupDiClassDevsExHandle SetupDiGetClassDevsEx(ref Guid classGuid, IntPtr enumerator, IntPtr hwndParent, [MarshalAs(UnmanagedType.U4)] DEVICE_INFORMATION_FLAGS devsExFlags, IntPtr deviceInfoSet, [MarshalAs(UnmanagedType.LPWStr)] string machineName, IntPtr reserved);
- ///
- /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
- ///
+
+ /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
///
- /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as
- /// CreateFile.
- /// Do not attempt to parse the device path symbolic name. The device path can be reused across system starts.
/// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
+ /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as CreateFile.
+ /// Do not attempt to parse the device path symbolic name. The device path can be reused across system starts.
///
- /// Information describing the development.
- /// [in,out] Information describing the device interface.
- /// [in,out] Information describing the device interface detail.
- /// Size of the device interface detail data.
- /// Size of the required.
- /// [in,out] Information describing the device information.
+ ///
///
/// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error.
- /// If the function completed with an error, FALSE is returned and the error code for the failure can be retrieved by calling
- /// GetLastError.
+ /// If the function completed with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetupDiGetDeviceInterfaceDetail(SafeHandle hDevInfo, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData, [MarshalAs(UnmanagedType.U4)] uint deviceInterfaceDetailDataSize, IntPtr requiredSize, ref SP_DEVINFO_DATA deviceInfoData);
- ///
- /// The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.
+
+
+ /// The SetupDiGetDeviceProperty function retrieves a device instance property.
+ ///
+ /// Available in Windows Vista and later versions of Windows.
+ ///
+ ///
+ ///
+ /// SetupDiGetDeviceProperty returns TRUE if it is successful.
+ /// Otherwise, it returns FALSE, and the logged error can be retrieved by calling GetLastError.
+ ///
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetupDiGetDevicePropertyW"), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool SetupDiGetDeviceProperty(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref DEVPROPKEY propkey, [MarshalAs(UnmanagedType.U8)] ref ulong propertyDataType, byte[] propertyBuffer, int propertyBufferSize, ref int requiredSize, uint flags);
+
+
+
+ //[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ //[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetupDiGetDevicePropertyW"), SuppressUnmanagedCodeSecurity]
+ //[return: MarshalAs(UnmanagedType.Bool)]
+ //internal static extern bool SetupDiGetDeviceProperty3(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref DEVPROPKEY propkey, [MarshalAs(UnmanagedType.U8)] ref ulong propertyDataType, Guid propertyBuffer, int propertyBufferSize, ref int requiredSize, uint flags);
+
+
+ ///// The SetupDiGetDeviceProperty function retrieves a device instance property.
+ /////
+ ///// Available in Windows Vista and later versions of Windows.
+ /////
+ /////
+ /////
+ ///// SetupDiGetDeviceProperty returns TRUE if it is successful.
+ ///// Otherwise, it returns FALSE, and the logged error can be retrieved by calling GetLastError.
+ /////
+ //[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ //[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetupDiGetDevicePropertyW"), SuppressUnmanagedCodeSecurity]
+ //[return: MarshalAs(UnmanagedType.Bool)]
+ //internal static extern bool SetupDiGetDeviceProperty2(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref DEVPROPKEY propkey, [MarshalAs(UnmanagedType.U8)] ref ulong propertyDataType, SafeGlobalMemoryBufferHandle propertyBuffer, int propertyBufferSize, ref int requiredSize, [MarshalAs(UnmanagedType.U4)] uint flags);
+
+
+ ///// The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.
+ /////
+ ///// Available in Microsoft Windows 2000 and later versions of Windows.
+ /////
+ /////
+ /////
+ ///// SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful.
+ ///// Otherwise, it returns FALSE and the logged error can be retrieved by making a call to GetLastError.
+ ///// SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.
+ /////
+ //[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ //[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ //[return: MarshalAs(UnmanagedType.Bool)]
+ //internal static extern bool SetupDiGetDeviceRegistryProperty(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, SPDRP property, ref int propertyRegDataType, byte[] propertyBuffer, [MarshalAs(UnmanagedType.U4)] uint propertyBufferSize, ref int requiredSize);
+
+
+ /// The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.
+ ///
+ /// Available in Microsoft Windows 2000 and later versions of Windows.
+ ///
///
- /// Available in Microsoft Windows 2000 and later versions of Windows.
- /// Set the device information belongs to.
- /// [in,out] Information describing the device information.
- /// The property.
- /// [out] Type of the property register data.
- /// Buffer for property data.
- /// Size of the property buffer.
- /// Size of the required.
///
/// SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful.
/// Otherwise, it returns FALSE and the logged error can be retrieved by making a call to GetLastError.
- /// SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a
- /// device or if the property data is not valid.
+ /// SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.
///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool SetupDiGetDeviceRegistryProperty(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, SetupDiGetDeviceRegistryPropertyEnum property, IntPtr propertyRegDataType, SafeGlobalMemoryBufferHandle propertyBuffer, [MarshalAs(UnmanagedType.U4)] uint propertyBufferSize, IntPtr requiredSize);
+ internal static extern bool SetupDiGetDeviceRegistryProperty(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, SPDRP property, IntPtr propertyRegDataType, SafeGlobalMemoryBufferHandle propertyBuffer, [MarshalAs(UnmanagedType.U4)] uint propertyBufferSize, IntPtr requiredSize);
#endregion // SetupDiXxx
+
+
+ /// Retrieves the current power state of the specified device. This function cannot be used to query the power state of a display device.
+ /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool GetDevicePowerState(SafeHandle hDevice, [MarshalAs(UnmanagedType.Bool)] out bool pfOn);
}
}
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.DiskManagement.cs b/AlphaFS/Device/Native Methods/NativeMethods.DiskManagement.cs
similarity index 98%
rename from AlphaFS/Filesystem/Native Methods/NativeMethods.DiskManagement.cs
rename to AlphaFS/Device/Native Methods/NativeMethods.DiskManagement.cs
index fb7b92aa6..c39c4baf9 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.DiskManagement.cs
+++ b/AlphaFS/Device/Native Methods/NativeMethods.DiskManagement.cs
@@ -23,7 +23,7 @@
using System.Runtime.InteropServices;
using System.Security;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
@@ -33,7 +33,7 @@ internal static partial class NativeMethods
///
/// Symbolic link behavior: If the path points to a symbolic link, the operation is performed on the target.
/// If this parameter is a UNC name, it must include a trailing backslash (for example, "\\MyServer\MyShare\").
- /// Furthermore, a drive specification must have a trailing backslash (for example, "C:\").
+ /// Furthermore, a drive specification must have a trailing backslash (for example, C:\).
/// The calling application must have FILE_LIST_DIRECTORY access rights for this directory.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.VolumeManagement.cs b/AlphaFS/Device/Native Methods/NativeMethods.VolumeManagement.cs
similarity index 88%
rename from AlphaFS/Filesystem/Native Methods/NativeMethods.VolumeManagement.cs
rename to AlphaFS/Device/Native Methods/NativeMethods.VolumeManagement.cs
index b1c860017..861c549e4 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.VolumeManagement.cs
+++ b/AlphaFS/Device/Native Methods/NativeMethods.VolumeManagement.cs
@@ -19,23 +19,25 @@
* THE SOFTWARE.
*/
-using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
+using Alphaleonis.Win32.Filesystem;
+using Microsoft.Win32.SafeHandles;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
- {
+ {
/// Defines, redefines, or deletes MS-DOS device names.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
+ /// SMB does not support volume management functions. For CsvFs, a new name will not be replicated to the other nodes on the cluster.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
@@ -43,11 +45,13 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DefineDosDevice(DosDeviceAttributes dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string lpDeviceName, [MarshalAs(UnmanagedType.LPWStr)] string lpTargetPath);
+
/// Deletes a drive letter or mounted folder.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
+ /// SMB does not support volume management functions. For CsvFs, a new mount point will not be replicated to the other nodes on the cluster.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
@@ -55,33 +59,39 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DeleteVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeMountPoint);
+
/// Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the volumes of a computer.
///
/// If the function succeeds, the return value is a search handle used in a subsequent call to the FindNextVolume and FindVolumeClose functions.
/// If the function fails to find any volumes, the return value is the INVALID_HANDLE_VALUE error code. To get extended error information, call GetLastError.
///
+ /// SMB does not support volume management functions.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstVolumeW"), SuppressUnmanagedCodeSecurity]
internal static extern SafeFindVolumeHandle FindFirstVolume(StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
+
/// Retrieves the name of a mounted folder on the specified volume. FindFirstVolumeMountPoint is used to begin scanning the mounted folders on a volume.
///
/// If the function succeeds, the return value is a search handle used in a subsequent call to the FindNextVolumeMountPoint and FindVolumeMountPointClose functions.
/// If the function fails to find a mounted folder on the volume, the return value is the INVALID_HANDLE_VALUE error code.
///
+ /// SMB does not support volume management functions. CsvFS does not support adding mount point on a CSV volume. ReFS does not index mount points.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstVolumeMountPointW"), SuppressUnmanagedCodeSecurity]
internal static extern SafeFindVolumeMountPointHandle FindFirstVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszRootPathName, StringBuilder lpszVolumeMountPoint, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
+
/// Continues a volume search started by a call to the FindFirstVolume function. FindNextVolume finds one volume per call.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
+ /// SMB does not support volume management functions.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
@@ -89,68 +99,71 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FindNextVolume(SafeFindVolumeHandle hFindVolume, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
+
/// Continues a mounted folder search started by a call to the FindFirstVolumeMountPoint function. FindNextVolumeMountPoint finds one mounted folder per call.
///
/// If the function succeeds, the return value is nonzero.
- /// If the function fails, the return value is zero. To get extended error information, call GetLastError. If no more mounted folders can be found, the GetLastError function returns the ERROR_NO_MORE_FILES error code.
+ /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
+ /// If no more mounted folders can be found, the GetLastError function returns the ERROR_NO_MORE_FILES error code.
/// In that case, close the search with the FindVolumeMountPointClose function.
///
- /// Minimum supported client: Windows XP
- /// Minimum supported server: Windows Server 2003
+ /// SMB does not support volume management functions. CsvFS does not support adding mount point on a CSV volume. ReFS does not index mount points.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindNextVolumeMountPointW"), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FindNextVolumeMountPoint(SafeFindVolumeMountPointHandle hFindVolume, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
- /// Closes the specified volume search handle.
- ///
- /// SetLastError is set to false.
- /// Minimum supported client: Windows XP [desktop apps only]. Minimum supported server: Windows Server 2003 [desktop apps only].
- ///
+
+ /// Closes the specified volume search handle. The FindFirstVolume and FindNextVolume functions use this search handle to locate volumes.
///
- /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error
- /// information, call GetLastError.
+ /// If the function succeeds, the return value is nonzero.
+ /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
+ /// SMB does not support volume management functions.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FindVolumeClose(IntPtr hFindVolume);
+
/// Closes the specified mounted folder search handle.
- ///
- /// SetLastError is set to false.
- /// Minimum supported client: Windows XP
- /// Minimum supported server: Windows Server 2003
- ///
///
/// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error
/// information, call GetLastError.
///
+ /// SMB does not support volume management functions. CsvFS does not support adding mount point on a CSV volume.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FindVolumeMountPointClose(IntPtr hFindVolume);
+
///
/// Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
- /// To determine whether a drive is a USB-type drive, call and specify the
- /// SPDRP_REMOVAL_POLICY property.
+ /// To determine whether a drive is a USB-type drive, SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY property.
///
+ ///
+ /// The return value specifies the type of drive, see .
+ /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
+ ///
///
/// SMB does not support volume management functions.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
///
/// Full pathname of the root file.
- ///
- /// The return value specifies the type of drive, see .
- /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
- ///
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetDriveTypeW"), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.U4)]
internal static extern DriveType GetDriveType([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName);
+
///
/// Retrieves a bitmask representing the currently available disk drives.
///
@@ -169,6 +182,7 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.U4)]
internal static extern uint GetLogicalDrives();
+
/// Retrieves information about the file system and volume associated with the specified root directory.
///
/// If all the requested information is retrieved, the return value is nonzero.
@@ -182,6 +196,7 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetVolumeInformation([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName, StringBuilder lpVolumeNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nVolumeNameSize, [MarshalAs(UnmanagedType.U4)] out uint lpVolumeSerialNumber, [MarshalAs(UnmanagedType.U4)] out int lpMaximumComponentLength, [MarshalAs(UnmanagedType.U4)] out VOLUME_INFO_FLAGS lpFileSystemAttributes, StringBuilder lpFileSystemNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nFileSystemNameSize);
+
/// Retrieves information about the file system and volume associated with the specified file.
///
/// If all the requested information is retrieved, the return value is nonzero.
@@ -196,14 +211,15 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetVolumeInformationByHandle(SafeFileHandle hFile, StringBuilder lpVolumeNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nVolumeNameSize, [MarshalAs(UnmanagedType.U4)] out uint lpVolumeSerialNumber, [MarshalAs(UnmanagedType.U4)] out int lpMaximumComponentLength, out VOLUME_INFO_FLAGS lpFileSystemAttributes, StringBuilder lpFileSystemNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nFileSystemNameSize);
- /// Retrieves a volume GUID path for the volume that is associated with the specified volume mount point (drive letter, volume GUID path, or mounted folder).
+
+ /// Retrieves a volume path for the volume that is associated with the specified volume mount point (drive letter, volume path, or mounted folder).
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
- /// Use GetVolumeNameForVolumeMountPoint to obtain a volume GUID path for use with functions such as SetVolumeMountPoint and FindFirstVolumeMountPoint that require a volume GUID path as an input parameter.
+ /// Use GetVolumeNameForVolumeMountPoint to obtain a volume path for use with functions such as SetVolumeMountPoint and FindFirstVolumeMountPoint that require a volume path as an input parameter.
/// SMB does not support volume management functions.
- /// Mount points aren't supported by ReFS volumes.
+ /// Mount points are not supported by ReFS volumes.
/// Minimum supported client: Windows XP [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
@@ -211,6 +227,7 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetVolumeNameForVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeMountPoint, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
+
/// Retrieves the volume mount point where the specified path is mounted.
///
/// If a specified path is passed, GetVolumePathName returns the path to the volume mount point, which means that it returns the
@@ -232,18 +249,19 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetVolumePathName([MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, StringBuilder lpszVolumePathName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength);
+
/// Retrieves a list of drive letters and mounted folder paths for the specified volume.
- /// Minimum supported client: Windows XP.
- /// Minimum supported server: Windows Server 2003.
- ///
- /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error
- /// information, call GetLastError.
- ///
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only].
+ /// Minimum supported server: Windows Server 2003 [desktop apps only].
+ ///
+ /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumePathNamesForVolumeNameW"), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetVolumePathNamesForVolumeName([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeName, char[] lpszVolumePathNames, [MarshalAs(UnmanagedType.U4)] uint cchBuferLength, [MarshalAs(UnmanagedType.U4)] out uint lpcchReturnLength);
+
/// Sets the label of a file system volume.
/// Minimum supported client: Windows XP [desktop apps only].
/// Minimum supported server: Windows Server 2003 [desktop apps only].
@@ -257,6 +275,7 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetVolumeLabel([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName, [MarshalAs(UnmanagedType.LPWStr)] string lpVolumeName);
+
/// Associates a volume with a drive letter or a directory on another volume.
/// Minimum supported client: Windows XP [desktop apps only].
/// Minimum supported server: Windows Server 2003 [desktop apps only].
@@ -269,6 +288,7 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeMountPoint, [MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeName);
+
/// Retrieves information about MS-DOS device names.
/// Minimum supported client: Windows XP [desktop apps only].
/// Minimum supported server: Windows Server 2003 [desktop apps only].
@@ -282,4 +302,4 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.U4)]
internal static extern uint QueryDosDevice([MarshalAs(UnmanagedType.LPWStr)] string lpDeviceName, char[] lpTargetPath, [MarshalAs(UnmanagedType.U4)] uint ucchMax);
}
-}
\ No newline at end of file
+}
diff --git a/AlphaFS/Device/Native Methods/NativeMethods.cs b/AlphaFS/Device/Native Methods/NativeMethods.cs
new file mode 100644
index 000000000..35ad29fd9
--- /dev/null
+++ b/AlphaFS/Device/Native Methods/NativeMethods.cs
@@ -0,0 +1,29 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// FILE_ANY_ACCESS = 0
+ internal const int FILE_ANY_ACCESS = 0;
+ }
+}
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/DiGetClassFlags.cs b/AlphaFS/Device/Native Other/DEVICE_INFORMATION_FLAGS.cs
similarity index 52%
rename from AlphaFS/Filesystem/Structures, Enumerations/DiGetClassFlags.cs
rename to AlphaFS/Device/Native Other/DEVICE_INFORMATION_FLAGS.cs
index d60b07e76..bdda24caf 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/DiGetClassFlags.cs
+++ b/AlphaFS/Device/Native Other/DEVICE_INFORMATION_FLAGS.cs
@@ -21,41 +21,28 @@
using System;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
/// Specifies control options that filter the device information elements that are added to the device information set.
[Flags]
- internal enum SetupDiGetClassDevsExFlags
+ internal enum DEVICE_INFORMATION_FLAGS
{
- /// DIGCF_DEFAULT
- /// Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes.
- ///
- Default = 1, // only valid with DIGCF_DEVICEINTERFACE
+ /// Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes.
+ DIGCF_DEFAULT = 1, // Only valid with DIGCF_DEVICEINTERFACE
- /// DIGCF_PRESENT
- /// Return only devices that are currently present.
- ///
- Present = 2,
+ /// Return only devices that are currently present.
+ DIGCF_PRESENT = 2,
- /// DIGCF_ALLCLASSES
- /// Return a list of installed devices for the specified device setup classes or device interface classes.
- ///
- AllClasses = 4,
+ /// Return a list of installed devices for the specified device setup classes or device interface classes.
+ DIGCF_ALLCLASSES = 4,
- /// DIGCF_PROFILE
- /// Return only devices that are a part of the current hardware profile.
- ///
- Profile = 8,
+ /// Return only devices that are a part of the current hardware profile.
+ DIGCF_PROFILE = 8,
- /// DIGCF_DEVICEINTERFACE
- ///
- /// Return devices that support device interfaces for the specified device interface classes.
- /// This flag must be set in the Flags parameter if the Enumerator parameter specifies a Device Instance ID.
- ///
- ///
- DeviceInterface = 16
+ /// Return devices that support device interfaces for the specified device interface classes. This flag must be set in the Flags parameter if the Enumerator parameter specifies a Device Instance ID.
+ DIGCF_DEVICEINTERFACE = 16
}
}
-}
\ No newline at end of file
+}
diff --git a/AlphaFS/Device/Native Other/DEVPROPKEY.cs b/AlphaFS/Device/Native Other/DEVPROPKEY.cs
new file mode 100644
index 000000000..dc2b569da
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DEVPROPKEY.cs
@@ -0,0 +1,250 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// In Windows Vista and later versions of Windows, the DEVPROPKEY structure represents a device property key for a device property in the unified device property model.
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ public struct DEVPROPKEY
+ {
+ /// A globally unique ID (GUID) for the device property.
+ public Guid fmtid;
+
+ /// A value that identifies the device property.
+ public ulong pid;
+ }
+
+
+
+ private static class ClassCategories
+ {
+ //public static readonly Guid Name = CreateGuid(0xb725f130, 0x47ef, 0x101a, 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac);
+ public static readonly Guid Device1 = CreateGuid(0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0);
+ //public static readonly Guid Device2 = CreateGuid(0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7);
+ //public static readonly Guid Device3 = CreateGuid(0x80497100, 0x8c73, 0x48b9, 0xaa, 0xd9, 0xce, 0x38, 0x7e, 0x19, 0xc5, 0x6e);
+ //public static readonly Guid Device4 = CreateGuid(0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57);
+ //public static readonly Guid Device5 = CreateGuid(0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c);
+ //public static readonly Guid Device6 = CreateGuid(0x80d81ea6, 0x7473, 0x4b0c, 0x82, 0x16, 0xef, 0xc1, 0x1a, 0x2c, 0x4c, 0x8b);
+ public static readonly Guid Numa = CreateGuid(0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2);
+ //public static readonly Guid Device7 = CreateGuid(0x83da6326, 0x97a6, 0x4088, 0x94, 0x53, 0xa1, 0x92, 0x3f, 0x57, 0x3b, 0x29);
+ //public static readonly Guid Device8 = CreateGuid(0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6);
+ //public static readonly Guid DeviceSafeRemovel = CreateGuid(0xafd97640, 0x86a3, 0x4210, 0xb6, 0x7c, 0x28, 0x9c, 0x41, 0xaa, 0xbe, 0x55);
+ //public static readonly Guid DriverPackage = CreateGuid(0xcf73bb51, 0x3abf, 0x44a2, 0x85, 0xe0, 0x9a, 0x3d, 0xc7, 0xa1, 0x21, 0x32);
+ //public static readonly Guid DeviceClass1 = CreateGuid(0x4321918b, 0xf69e, 0x470d, 0xa5, 0xde, 0x4d, 0x88, 0xc7, 0x5a, 0xd2, 0x4b);
+ //public static readonly Guid DeviceClass2 = CreateGuid(0x259abffc, 0x50a7, 0x47ce, 0xaf, 0x8, 0x68, 0xc9, 0xa7, 0xd7, 0x33, 0x66);
+ //public static readonly Guid DeviceClass3 = CreateGuid(0x713d1703, 0xa2e2, 0x49f5, 0x92, 0x14, 0x56, 0x47, 0x2e, 0xf3, 0xda, 0x5c);
+ //public static readonly Guid DeviceInterface = CreateGuid(0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22);
+ //public static readonly Guid DeviceInterfaceClass = CreateGuid(0x14c83a99, 0x0b3f, 0x44b7, 0xbe, 0x4c, 0xa1, 0x78, 0xd3, 0x99, 0x05, 0x64);
+ //public static readonly Guid AudioEndpoint = CreateGuid(0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e);
+ //public static readonly Guid AudioEngine1 = CreateGuid(0xf19f064d, 0x82c, 0x4e27, 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c);
+ //public static readonly Guid AudioEngine2 = CreateGuid(0xe4870e26, 0x3cc5, 0x4cd2, 0xba, 0x46, 0xca, 0xa, 0x9a, 0x70, 0xed, 0x4);
+
+
+ // Needed for .NET Standard 1.0 compliance .
+ private static Guid CreateGuid(uint a, ushort b, ushort c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k)
+ {
+ return new Guid(unchecked((int)a), unchecked((short)b), unchecked((short)c), d, e, f, g, h, i, j, k);
+ }
+ }
+
+
+ public class DEVPROPKEYS
+ {
+ //public static DEVPROPKEY Name = new DEVPROPKEY {fmtid = ClassCategories.Name, pid = 10 }; // DEVPROP_TYPE_STRING
+
+ // Device properties. These correspond to the old setupapi SPDRP_XXX properties.
+
+ //public static DEVPROPKEY DeviceDeviceDesc = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 2}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceHardwareIds = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 3}; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceCompatibleIds = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 4 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceService = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 6 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClass = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 9 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassGuid = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 10 }; // DEVPROP_TYPE_GUID
+ //public static DEVPROPKEY DeviceDriver = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 11 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceConfigFlags = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 12 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceManufacturer = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 13 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceFriendlyName = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 14 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceLocationInfo = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 15 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DevicePdoName = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 16 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceCapabilities = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 17 }; // DEVPROP_TYPE_UNINT32
+ //public static DEVPROPKEY DeviceUiNumber = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 18 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceUpperFilters = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 19 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceLowerFilters = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 20 }; // DEVPROP_TYPE_STRING_LIST
+ public static DEVPROPKEY DeviceBusTypeGuid = new DEVPROPKEY { fmtid = ClassCategories.Device1, pid = 21 }; // DEVPROP_TYPE_GUID
+ //public static DEVPROPKEY DeviceLegacyBusType = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 22 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceBusNumber = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 23 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceEnumeratorName = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 24 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceSecurity = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 25 }; // DEVPROP_TYPE_SECURITY_DESCRIPTOR
+ //public static DEVPROPKEY DeviceSecuritySds = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 26 }; // DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING
+ //public static DEVPROPKEY DeviceDevType = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 27 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceExclusive = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 28 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceCharacteristics = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 29 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceAddress = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 30 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceUiNumberDescFormat = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 31 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DevicePowerData = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 32 }; // DEVPROP_TYPE_BINARY
+ //public static DEVPROPKEY DeviceRemovalPolicy = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 33 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceRemovalPolicyDefault = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 34 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceRemovalPolicyOverride = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 35 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceInstallState = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 36 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceLocationPaths = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 37 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceBaseContainerId = new DEVPROPKEY {fmtid = ClassCategories.Device1, pid = 38 }; // DEVPROP_TYPE_GUID
+
+
+ // Device properties. These correspond to a device's status and problem code.
+
+ //public static DEVPROPKEY DeviceDevNodeStatus = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 2 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceProblemCode = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 3 }; // DEVPROP_TYPE_UINT32
+
+
+ // Device properties. These correspond to device relations.
+
+ //public static DEVPROPKEY DeviceEjectionRelations = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 4 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceRemovalRelations = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 5 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DevicePowerRelations = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 6 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceBusRelationsn = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 7 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceParent = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 8 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceChildren = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 9 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceSiblings = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 10 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceTransportRelations = new DEVPROPKEY {fmtid = ClassCategories.Device2, pid = 11 }; // DEVPROP_TYPE_STRING_LIST
+
+
+ // Other Device properties.
+
+ //public static DEVPROPKEY DeviceReported = new DEVPROPKEY {fmtid = ClassCategories.Device3, pid = 2}; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceLegacy = new DEVPROPKEY {fmtid = ClassCategories.Device3, pid = 3}; // DEVPROP_TYPE_BOOLEAN
+
+ //public static DEVPROPKEY DeviceInstanceId = new DEVPROPKEY {fmtid = ClassCategories.Device4, pid = 256 }; // DEVPROP_TYPE_STRING
+
+ //public static DEVPROPKEY DeviceContainerId = new DEVPROPKEY {fmtid = ClassCategories.Device5, pid = 2 }; // DEVPROP_TYPE_GUID
+
+ //public static DEVPROPKEY DeviceModelId = new DEVPROPKEY {fmtid = ClassCategories.Device6, pid = 2 }; // DEVPROP_TYPE_GUID
+ //public static DEVPROPKEY DeviceFriendlyNameAttributes = new DEVPROPKEY {fmtid = ClassCategories.Device6, pid = 3 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceManufacturerAttributes = new DEVPROPKEY {fmtid = ClassCategories.Device6, pid = 4 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DevicePresenceNotForDeviceb = new DEVPROPKEY {fmtid = ClassCategories.Device6, pid = 5 }; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceSignalStrength = new DEVPROPKEY {fmtid = ClassCategories.Device6, pid = 6 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceIsAssociateableByUserAction = new DEVPROPKEY {fmtid = ClassCategories.Device6, pid = 7 }; // DEVPROP_TYPE_BOOLEAN
+
+ //public static DEVPROPKEY DeviceInstallInProgress = new DEVPROPKEY { fmtid = ClassCategories.Device7, pid = 9 }; // DEVPROP_TYPE_BOOLEAN
+
+ //public static DEVPROPKEY NumaProximityDomain = new DEVPROPKEY {fmtid = ClassCategories.Numa, pid = 1 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceDhpRebalancePolicy = new DEVPROPKEY {fmtid = ClassCategories.Numa, pid = 2 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceNumaNode = new DEVPROPKEY {fmtid = ClassCategories.Numa, pid = 3}; // DEVPROP_TYPE_UINT32
+ public static DEVPROPKEY DeviceBusReportedDeviceDesc = new DEVPROPKEY { fmtid = ClassCategories.Numa, pid = 4 }; // DEVPROP_TYPE_STRING
+
+
+ // Device driver properties.
+
+ //public static DEVPROPKEY DeviceDriverDate = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 2 }; // DEVPROP_TYPE_FILETIME
+ //public static DEVPROPKEY DeviceDriverVersion = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 3 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverDesc = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 4}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverInfPath = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 5}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverInfSection = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 6}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverInfSectionExt = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 7}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceMatchingDeviceId = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 8}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverProvider = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 9}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverPropPageProvider = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 10 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverCoInstallers = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 11 }; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceResourcePickerTags = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 12 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceResourcePickerExceptions = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 13 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceDriverRank = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 14 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceDriverLogoLevel = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 15 }; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceNoConnectSound = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 17 }; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceGenericDriverInstalled = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 18 }; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceAdditionalSoftwareRequested = new DEVPROPKEY {fmtid = ClassCategories.Device8, pid = 19 }; // DEVPROP_TYPE_BOOLEAN
+
+
+ // Device safe-removal properties.
+
+ //public static DEVPROPKEY DeviceSafeRemovalRequired = new DEVPROPKEY {fmtid = ClassCategories.DeviceSafeRemovel, pid = 2 }; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceSafeRemovalRequiredOverride = new DEVPROPKEY {fmtid = ClassCategories.DeviceSafeRemovel, pid = 3 }; // DEVPROP_TYPE_BOOLEAN
+
+
+ // Device properties that were set by the driver package that was installed on the device.
+
+ //public static DEVPROPKEY DrvPkgModel = new DEVPROPKEY {fmtid = ClassCategories.DriverPackage, pid = 2}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DrvPkgVendorWebSite = new DEVPROPKEY {fmtid = ClassCategories.DriverPackage, pid = 3}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DrvPkgDetailedDescription = new DEVPROPKEY {fmtid = ClassCategories.DriverPackage, pid = 4}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DrvPkgDocumentationLink = new DEVPROPKEY {fmtid = ClassCategories.DriverPackage, pid = 5}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DrvPkgIcon = new DEVPROPKEY {fmtid = ClassCategories.DriverPackage, pid = 6}; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DrvPkgBrandingIcon = new DEVPROPKEY {fmtid = ClassCategories.DriverPackage, pid = 7}; // DEVPROP_TYPE_STRING_LIST
+
+
+ // Device setup class properties. These correspond to the old setupapi SPCRP_XXX properties.
+
+ //public static DEVPROPKEY DeviceClassUpperFilters = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 19}; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceClassLowerFilters = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 20}; // DEVPROP_TYPE_STRING_LIST
+ //public static DEVPROPKEY DeviceClassSecurity = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 25}; // DEVPROP_TYPE_SECURITY_DESCRIPTOR
+ //public static DEVPROPKEY DeviceClassSecuritySds = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 26}; // DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING
+ //public static DEVPROPKEY DeviceClassDevType = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 27}; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceClassExclusive = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 28}; // DEVPROP_TYPE_UINT32
+ //public static DEVPROPKEY DeviceClassCharacteristics = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass1, pid = 29}; // DEVPROP_TYPE_UINT32
+
+
+ // Device setup class properties. These correspond to registry values under the device class GUID key.
+
+ //public static DEVPROPKEY DeviceClassName = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 2 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassClassName = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 3}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassIcon = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 4}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassClassInstaller = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 5}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassPropPageProvider = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 6}; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassNoInstallClass = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 7}; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceClassNoDisplayClass = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 8}; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceClassSilentInstall = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 9}; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceClassNoUseClass = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 10 }; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceClassDefaultService = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 11 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceClassIconPath = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass2, pid = 12 }; // DEVPROP_TYPE_STRING_LIST
+
+
+ // Other Device setup class properties.
+
+ //public static DEVPROPKEY DeviceClassClassCoInstallers = new DEVPROPKEY {fmtid = ClassCategories.DeviceClass3, pid = 2 }; // DEVPROP_TYPE_STRING_LIST
+
+
+ // Device interface properties.
+
+ //public static DEVPROPKEY DeviceInterfaceFriendlyName = new DEVPROPKEY {fmtid = ClassCategories.DeviceInterface, pid = 2 }; // DEVPROP_TYPE_STRING
+ //public static DEVPROPKEY DeviceInterfaceEnabled = new DEVPROPKEY {fmtid = ClassCategories.DeviceInterface, pid = 3 }; // DEVPROP_TYPE_BOOLEAN
+ //public static DEVPROPKEY DeviceInterfaceClassGuid = new DEVPROPKEY {fmtid = ClassCategories.DeviceInterface, pid = 4 }; // DEVPROP_TYPE_GUID
+
+
+ // Device interface class properties.
+
+ //public static DEVPROPKEY DeviceInterfaceClassDefaultInterface = new DEVPROPKEY {fmtid = ClassCategories.DeviceInterfaceClass, pid = 2}; // DEVPROP_TYPE_STRING
+
+ //public static DEVPROPKEY AudioEndpointFormFactor = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 0};
+ //public static DEVPROPKEY AudioEndpointControlPanelPageProvider = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 1};
+ //public static DEVPROPKEY AudioEndpointAssociation = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 2};
+ //public static DEVPROPKEY AudioEndpointPhysicalSpeakers = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 3};
+ //public static DEVPROPKEY AudioEndpointGuid = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 4};
+ //public static DEVPROPKEY AudioEndpointDisableSysFx = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 5};
+ //public static DEVPROPKEY AudioEndpointFullRangeSpeakers = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 6};
+ //public static DEVPROPKEY AudioEndpointSupportsEventDrivenMode = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 7};
+ //public static DEVPROPKEY AudioEndpointJackSubType = new DEVPROPKEY {fmtid = ClassCategories.AudioEndpoint, pid = 8};
+ //public static DEVPROPKEY AudioEngineDeviceFormat = new DEVPROPKEY {fmtid = ClassCategories.AudioEngine1, pid = 0};
+ //public static DEVPROPKEY AudioEngineOemFormat = new DEVPROPKEY {fmtid = ClassCategories.AudioEngine2, pid = 3};
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_DETECTION_INFO.cs b/AlphaFS/Device/Native Other/DISK_DETECTION_INFO.cs
new file mode 100644
index 000000000..d7f58fe92
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_DETECTION_INFO.cs
@@ -0,0 +1,49 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains detected drive parameters.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DISK_DETECTION_INFO
+ {
+ /// The size of the structure, in bytes.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint SizeOfDetectInfo;
+
+ /// The detected partition type. This member can be one of the following values from the enumeration.
+ public readonly DetectionType DetectionType;
+
+ ///
+ /// Union of and structs.
+ /// If DetectionType is DetectInt13, the union is a DISK_INT13_INFO structure.
+ /// If DetectionType is DetectExInt13, the union is a DISK_EX_INT13_INFO structure.
+ ///
+ public DiskInt13Union DiskInt13Union;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_EXTENT.cs b/AlphaFS/Device/Native Other/DISK_EXTENT.cs
new file mode 100644
index 000000000..f4886104f
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_EXTENT.cs
@@ -0,0 +1,69 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ // MSDN: Regardless of the disk type, a disk can contain one or more disk extents.
+ // A disk extent is a contiguous range of logical blocks exposed by the disk. For example, a disk extent can represent an entire volume,
+ // one portion of a spanned volume, one member of a striped volume, or one plex of a mirrored volume.
+
+
+
+
+ /// Represents a disk extent.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DISK_EXTENT
+ {
+ /// The number of the disk that contains this extent. This is the same number that is used to construct the name of the disk,
+ /// for example, the X in "\\.\PhysicalDriveX" or "\\?\HarddiskX".
+ [MarshalAs(UnmanagedType.U4)] public uint DiskNumber;
+
+ /// The offset from the beginning of the disk to the extent, in bytes.
+ [MarshalAs(UnmanagedType.I8)] public long StartingOffset;
+
+ /// The number of bytes in this extent.
+ [MarshalAs(UnmanagedType.I8)] public long ExtentLength;
+ }
+
+
+ /// Represents a disk extent.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DISK_EXTENT_SINGLE
+ {
+ /// The number of disks in the volume (a volume can span multiple disks).
+ [MarshalAs(UnmanagedType.U4)] public readonly uint NumberOfDiskExtents;
+
+ public readonly DISK_EXTENT Extent;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_EX_INT13_INFO.cs b/AlphaFS/Device/Native Other/DISK_EX_INT13_INFO.cs
new file mode 100644
index 000000000..91c8fe043
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_EX_INT13_INFO.cs
@@ -0,0 +1,60 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains extended Int13 drive parameters.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DISK_EX_INT13_INFO
+ {
+ /// The size of the extended drive parameter buffer for this partition or disk. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort ExBufferSize;
+
+ /// The information flags for this partition or disk. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort ExFlags;
+
+ /// The number of cylinders per head. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint ExCylinders;
+
+ /// The maximum number of heads for this hard disk. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint ExHeads;
+
+ /// The number of sectors per track. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint ExSectorsPerTrack;
+
+ /// The total number of sectors for this disk. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U8)] public readonly ulong ExSectorsPerDrive;
+
+ /// The sector size for this disk. For valid values, see the BIOS documentation.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort ExSectorSize;
+
+ /// Reserved for future use.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort ExReserved;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_GEOMETRY.cs b/AlphaFS/Device/Native Other/DISK_GEOMETRY.cs
new file mode 100644
index 000000000..d365a3c62
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_GEOMETRY.cs
@@ -0,0 +1,51 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Describes the geometry of disk devices and media.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DISK_GEOMETRY
+ {
+ /// The number of cylinders.
+ [MarshalAs(UnmanagedType.I8)] public readonly long Cylinders;
+
+ /// The type of media.
+ [MarshalAs(UnmanagedType.U4)] public readonly MEDIA_TYPE MediaType;
+
+ /// The number of tracks per cylinder.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint TracksPerCylinder;
+
+ /// The number of sectors per track.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint SectorsPerTrack;
+
+ /// The number of bytes per sector.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint BytesPerSector;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_GEOMETRY_EX.cs b/AlphaFS/Device/Native Other/DISK_GEOMETRY_EX.cs
new file mode 100644
index 000000000..bfa978ea6
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_GEOMETRY_EX.cs
@@ -0,0 +1,51 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Describes the extended geometry of disk devices and media.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DISK_GEOMETRY_EX
+ {
+ /// Describes the geometry of disk devices and media.
+ public DISK_GEOMETRY Geometry;
+
+ /// The disk size, in bytes.
+ [MarshalAs(UnmanagedType.I8)] public long DiskSize;
+
+ ///// Any additional data.
+ //[MarshalAs(UnmanagedType.I1)] public readonly byte Data;
+
+ /// Contains the disk partition information.
+ public DISK_PARTITION_INFO PartitionInformation;
+
+ /// Contains detected drive parameters.
+ public DISK_DETECTION_INFO DiskDetectionInfo;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_INT13_INFO.cs b/AlphaFS/Device/Native Other/DISK_INT13_INFO.cs
new file mode 100644
index 000000000..75cbd628b
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_INT13_INFO.cs
@@ -0,0 +1,64 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ ///
+ /// The DISK_INT13_INFO structure is used by the BIOS to report disk detection data for a partition with an INT13 format.
+ ///
+ /// MSDN: http://msdn.microsoft.com/en-us/library/windows/hardware/ff552624(v=vs.85).aspx
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct DISK_INT13_INFO
+ {
+ ///
+ /// Corresponds to the Device/Head register defined in the AT Attachment (ATA) specification. When zero, the fourth bit of this register
+ /// indicates that drive zero is selected. When 1, it indicates that drive one is selected. The values of bits 0, 1, 2, 3, and 6 depend
+ /// on the command in the command register. Bits 5 and 7 are no longer used. For more information about the values that the Device/Head
+ /// register can hold, see the ATA specification.
+ ///
+ public ushort DriveSelect;
+
+ ///
+ /// Indicates the maximum number of cylinders on the disk.
+ ///
+ public ulong MaxCylinders;
+
+ ///
+ /// Indicates the number of sectors per track.
+ ///
+ public ushort SectorsPerTrack;
+
+ ///
+ /// Indicates the maximum number of disk heads.
+ ///
+ public ushort MaxHeads;
+
+ ///
+ /// Indicates the number of drives.
+ ///
+ public ushort NumberDrives;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DISK_PARTITION_INFO.cs b/AlphaFS/Device/Native Other/DISK_PARTITION_INFO.cs
new file mode 100644
index 000000000..15efc0fcc
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DISK_PARTITION_INFO.cs
@@ -0,0 +1,56 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains the disk partition information.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
+ internal struct DISK_PARTITION_INFO
+ {
+ /// The size of this structure, in bytes.
+ [FieldOffset(0)] [MarshalAs(UnmanagedType.U4)]
+ public readonly uint SizeOfPartitionInfo;
+
+ /// The format of a partition.
+ [FieldOffset(4)] [MarshalAs(UnmanagedType.U4)]
+ public readonly PARTITION_STYLE PartitionStyle;
+
+ /// Signature: MBR signature of the partition.
+ /// If PartitionStyle is PARTITION_STYLE_MBR (0), the union is a structure that contains information for an master boot record partition, which includes a disk signature and a checksum.
+ ///
+ [FieldOffset(8)] [MarshalAs(UnmanagedType.U4)]
+ public readonly uint MbrSignature;
+
+ /// DiskId: GUID of the GPT partition.
+ /// If PartitionStyle is PARTITION_STYLE_GPT (1), the union is a structure that contains information for a GUID partition table partition, which includes a disk identifier (GUID).
+ ///
+ [FieldOffset(8)] public Guid DiskId;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_EX.cs b/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_EX.cs
new file mode 100644
index 000000000..809e25e91
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_EX.cs
@@ -0,0 +1,50 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains extended information about a drive's partitions.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
+ internal struct DRIVE_LAYOUT_INFORMATION_EX
+ {
+ /// The style of the partitions on the drive enumerated by the enumeration.
+ [FieldOffset(0)] [MarshalAs(UnmanagedType.U4)]
+ public readonly PartitionStyle PartitionStyle;
+
+ /// The number of partitions on the drive. On hard disks with the MBR layout, this value will always be a multiple of 4.
+ [FieldOffset(4)] [MarshalAs(UnmanagedType.U4)]
+ public readonly uint PartitionCount;
+
+ /// A structure containing information about the master boot record type partitioning on the drive.
+ [FieldOffset(8)] public DRIVE_LAYOUT_INFORMATION_MBR Mbr;
+
+ /// A structure containing information about the GUID disk partition type partitioning on the drive.
+ [FieldOffset(8)] public DRIVE_LAYOUT_INFORMATION_GPT Gpt;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_GPT.cs b/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_GPT.cs
new file mode 100644
index 000000000..1019f9e1e
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_GPT.cs
@@ -0,0 +1,49 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains information about a drive's GUID partition table (GPT) partitions.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DRIVE_LAYOUT_INFORMATION_GPT
+ {
+ /// The GUID of the disk.
+ public Guid DiskId;
+
+ /// The starting byte offset of the first usable block.
+ [MarshalAs(UnmanagedType.U8)] public readonly ulong StartingUsableOffset;
+
+ /// The size of the usable blocks on the disk, in bytes.
+ [MarshalAs(UnmanagedType.U8)] public readonly ulong UsableLength;
+
+ /// The maximum number of partitions that can be defined in the usable block.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint MaxPartitionCount;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_MBR.cs b/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_MBR.cs
new file mode 100644
index 000000000..036c02ca8
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DRIVE_LAYOUT_INFORMATION_MBR.cs
@@ -0,0 +1,39 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Provides information about a drive's master boot record (MBR) partitions.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DRIVE_LAYOUT_INFORMATION_MBR
+ {
+ /// The signature of the drive.
+ [MarshalAs(UnmanagedType.U8)] public readonly ulong Signature;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/DiskInt13Union.cs b/AlphaFS/Device/Native Other/DiskInt13Union.cs
new file mode 100644
index 000000000..ef2e49cdc
--- /dev/null
+++ b/AlphaFS/Device/Native Other/DiskInt13Union.cs
@@ -0,0 +1,47 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ ///
+ /// Un-named struct for structure
+ ///
+ [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
+ internal struct DiskInt13Union
+ {
+ ///
+ /// for member description
+ ///
+ [FieldOffset(0)]
+ public DISK_INT13_INFO Int13;
+
+ ///
+ /// for member description
+ ///
+ [FieldOffset(0)]
+ public DISK_EX_INT13_INFO ExInt13;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/FILE_DEVICE.cs b/AlphaFS/Device/Native Other/FILE_DEVICE.cs
new file mode 100644
index 000000000..56f5cba5f
--- /dev/null
+++ b/AlphaFS/Device/Native Other/FILE_DEVICE.cs
@@ -0,0 +1,255 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// The storage device type.
+ internal enum FILE_DEVICE
+ {
+ /// BEEP parameter.
+ BEEP = 1,
+
+ /// CD_ROM parameter.
+ CD_ROM = 2,
+
+ /// CD_ROM_FILE_SYSTEM parameter.
+ CD_ROM_FILE_SYSTEM = 3,
+
+ /// CONTROLLER parameter.
+ CONTROLLER = 4,
+
+ /// DATALINK parameter.
+ DATALINK = 5,
+
+ /// DFS parameter.
+ DFS = 6,
+
+ /// DISK parameter.
+ DISK = 7,
+
+ /// DISK_FILE_SYSTEM parameter.
+ DISK_FILE_SYSTEM = 8,
+
+ /// FILE_SYSTEM parameter.
+ FILE_SYSTEM = 9,
+
+ /// INPORT_PORT parameter.
+ INPORT_PORT = 10,
+
+ /// KEYBOARD parameter.
+ KEYBOARD = 11,
+
+ /// MAILSLOT parameter.
+ MAILSLOT = 12,
+
+ /// MIDI_IN parameter.
+ MIDI_IN = 13,
+
+ /// MIDI_OUT parameter.
+ MIDI_OUT = 14,
+
+ /// MOUSE parameter.
+ MOUSE = 15,
+
+ /// MULTI_UNC_PROVIDER parameter.
+ MULTI_UNC_PROVIDER = 16,
+
+ /// NAMED_PIPE parameter.
+ NAMED_PIPE = 17,
+
+ /// NETWORK parameter.
+ NETWORK = 18,
+
+ /// NETWORK_BROWSER parameter.
+ NETWORK_BROWSER = 19,
+
+ /// NETWORK_FILE_SYSTEM parameter.
+ NETWORK_FILE_SYSTEM = 20,
+
+ /// NULL parameter.
+ NULL = 21,
+
+ /// PARALLEL_PORT parameter.
+ PARALLEL_PORT = 22,
+
+ /// PHYSICAL_NETCARD parameter.
+ PHYSICAL_NETCARD = 23,
+
+ /// PRINTER parameter.
+ PRINTER = 24,
+
+ /// SCANNER parameter.
+ SCANNER = 25,
+
+ /// SERIAL_MOUSE_PORT parameter.
+ SERIAL_MOUSE_PORT = 26,
+
+ /// SERIAL_PORT parameter.
+ SERIAL_PORT = 27,
+
+ /// SCREEN parameter.
+ SCREEN = 28,
+
+ /// SOUND parameter.
+ SOUND = 29,
+
+ /// STREAMS parameter.
+ STREAMS = 30,
+
+ /// TAPE parameter.
+ TAPE = 31,
+
+ /// TAPE_FILE_SYSTEM parameter.
+ TAPE_FILE_SYSTEM = 32,
+
+ /// TRANSPORT parameter.
+ TRANSPORT = 33,
+
+ /// UNKNOWN parameter.
+ UNKNOWN = 34,
+
+ /// VIDEO parameter.
+ VIDEO = 35,
+
+ /// VIRTUAL_DISK parameter.
+ VIRTUAL_DISK = 36,
+
+ /// WAVE_IN parameter.
+ WAVE_IN = 37,
+
+ /// WAVE_OUT parameter.
+ WAVE_OUT = 38,
+
+ /// 8042_PORT parameter.
+ PORT_8042 = 39,
+
+ /// NETWORK_REDIRECTOR parameter.
+ NETWORK_REDIRECTOR = 40,
+
+ /// BATTERY parameter.
+ BATTERY = 41,
+
+ /// BUS_EXTENDER parameter.
+ BUS_EXTENDER = 42,
+
+ /// MODEM parameter.
+ MODEM = 43,
+
+ /// VDM parameter.
+ VDM = 44,
+
+ /// MASS_STORAGE parameter.
+ MASS_STORAGE = 45,
+
+ /// SMB parameter.
+ SMB = 46,
+
+ /// KS parameter.
+ KS = 47,
+
+ /// CHANGER parameter.
+ CHANGER = 48,
+
+ /// SMARTCARD parameter.
+ SMARTCARD = 49,
+
+ /// ACPI parameter.
+ ACPI = 50,
+
+ /// DVD parameter.
+ DVD = 51,
+
+ /// FULLSCREEN_VIDEO parameter.
+ FULLSCREEN_VIDEO = 52,
+
+ /// DFS_FILE_SYSTEM parameter.
+ DFS_FILE_SYSTEM = 53,
+
+ /// DFS_VOLUME parameter.
+ DFS_VOLUME = 54,
+
+ /// SERENUM parameter.
+ SERENUM = 55,
+
+ /// TERMSRV parameter.
+ TERMSRV = 56,
+
+ /// KSEC parameter.
+ KSEC = 57,
+
+ /// FIPS parameter.
+ FIPS = 58,
+
+ /// INFINIBAND parameter.
+ INFINIBAND = 59,
+
+ /// VMBUS parameter.
+ VMBUS = 62,
+
+ /// CRYPT_PROVIDER parameter.
+ CRYPT_PROVIDER = 63,
+
+ /// WPD parameter.
+ WPD = 64,
+
+ /// BLUETOOTH parameter.
+ BLUETOOTH = 65,
+
+ /// MT_COMPOSITE parameter.
+ MT_COMPOSITE = 66,
+
+ /// MT_TRANSPORT parameter.
+ MT_TRANSPORT = 67,
+
+ /// BIOMETRIC parameter.
+ BIOMETRIC = 68,
+
+ /// PMI parameter.
+ PMI = 69,
+
+ /// EHSTOR parameter.
+ EHSTOR = 70,
+
+ /// DEVAPI parameter.
+ DEVAPI = 71,
+
+ /// GPIO parameter.
+ GPIO = 72,
+
+ /// USBEX parameter.
+ USBEX = 73,
+
+ /// CONSOLE parameter.
+ CONSOLE = 80,
+
+ /// NFP parameter.
+ NFP = 81,
+
+ /// SYSENV parameter.
+ SYSENV = 82,
+
+ /// MASS_STORAGE parameter.
+ VOLUME = 86
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/IoControlCode.cs b/AlphaFS/Device/Native Other/IoControlCode.cs
new file mode 100644
index 000000000..30ce68cbb
--- /dev/null
+++ b/AlphaFS/Device/Native Other/IoControlCode.cs
@@ -0,0 +1,681 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.IO;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Enumerable values that enter into DeviceIoControl function as dwIoControlCode parameter
+ /// Some of the code was taken from: http://blogs.msdn.com/b/codedebate/archive/2007/12/18/6797175.aspx
+ internal enum IoControlCode : uint
+ {
+ /// Retrieves the physical location of a specified volume on one or more disks.
+ IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = (FILE_DEVICE.VOLUME << 16) | (0 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /// Return properties of a storage device or adapter. The request indicates the kind of information to retrieve, such as inquiry data for a device or capabilities and limitations of an adapter.
+ IOCTL_STORAGE_QUERY_PROPERTY = (FILE_DEVICE.MASS_STORAGE << 16) | (0x500 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ #region MASS_STORAGE
+
+ ///// Determines whether the media has changed on a removable-media device that the caller has opened for read or write access. If read or write access to the device is not necessary, the caller can improve performance by opening the device with FILE_READ_ATTRIBUTES and issuing anIOCTL_STORAGE_CHECK_VERIFY2 request instead.
+ //IOCTL_STORAGE_CHECK_VERIFY = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0200 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Determines whether the media has changed on a removable-media device - the caller has opened with FILE_READ_ATTRIBUTES. Because no file system is mounted when a device is opened in this way, this request can be processed much more quickly than an IOCTL_STORAGE_CHECK_VERIFY request.
+ //IOCTL_STORAGE_CHECK_VERIFY2 = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0200 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14), // FileAccess.Any
+
+
+ ///// Locks the device to prevent removal of the media. If the driver can prevent the media from being removed while the drive is in use, it disables or enables the mechanism that ejects media on a device - the caller has opened for read or write access.
+ //IOCTL_STORAGE_MEDIA_REMOVAL = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0201 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Causes the device to eject the media if the device supports ejection capabilities.
+ //IOCTL_STORAGE_EJECT_MEDIA = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0202 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Causes media to be loaded in a device that the caller has opened for read or write access. If read or write access to the device is not necessary, the caller can improve performance by opening the device with FILE_READ_ATTRIBUTES and issuing an IOCTL_STORAGE_LOAD_MEDIA2 request instead.
+ //IOCTL_STORAGE_LOAD_MEDIA = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0203 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Causes media to be loaded in a device that the caller has opened with FILE_READ_ATTRIBUTES. Because no file system is mounted when a device is opened in this way, this request can be processed much more quickly than an IOCTL_STORAGE_LOAD_MEDIA request.
+ //IOCTL_STORAGE_LOAD_MEDIA2 = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0203 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Claims a device for the exclusive use of the caller on a bus that supports multiple initiators and the concept of reserving a device, such as a SCSI bus.
+ //IOCTL_STORAGE_RESERVE = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0204 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Releases a device previously reserved for the exclusive use of the caller on a bus that supports multiple initiators and the concept of reserving a device, such as a SCSI bus.
+ //IOCTL_STORAGE_RELEASE = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0205 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ /////
+ ///// Determines whether another device that the driver supports has been connected to the I/O bus, either since the system was booted or since
+ ///// the driver last processed this request.
+ ///// This IOCTL is obsolete in the Plug and Play environment. Plug and Play class drivers handle this request by calling IoInvalidateDeviceRelations
+ ///// with the device relations type BusRelations. If a new device is found, the class driver's AddDevice routine will be called.
+ ///// Legacy class drivers can continue to handle this IOCTL without modifications. If a new device is found, the driver sets up any necessary
+ ///// system objects and resources to handle I/O requests for its new device. It also initializes the device on receipt of this request
+ ///// dynamically, that is, without requiring the machine to be rebooted. Such a driver is assumed to support devices connected on a dynamically
+ ///// configurable I/O bus.
+ /////
+ //IOCTL_STORAGE_FIND_NEW_DEVICES = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0206 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ /////
+ ///// Locks the device to prevent removal of the media. If the driver can prevent the media from being removed while the drive is in use,
+ ///// the driver disables or enables the mechanism that ejects media, thereby locking the drive. A caller must open the device with
+ ///// FILE_READ_ATTRIBUTES to send this request.
+ ///// Unlike IOCTL_STORAGE_MEDIA_REMOVAL, the driver tracks IOCTL_STORAGE_EJECTION_CONTROL requests by caller and ignores unlock requests for
+ ///// which it has not received a lock request from the same caller, thereby preventing other callers from unlocking the drive.
+ /////
+ //IOCTL_STORAGE_EJECTION_CONTROL = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0250 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// Temporarily enables or disables delivery of the custom PnP events GUID_IO_MEDIA_ARRIVAL and GUID_IO_MEDIA_REMOVAL on a removable-media device.
+ ///// This, in turn, enables or disables media change detection (AutoPlay) for the device if the caller has opened the device with
+ ///// FILE_READ_ATTRIBUTES access and if the device has AutoPlay enabled in the registry. The caller must not open the device for read or write
+ ///// access or the IOCTL operation will fail. This IOCTL has no effect on the AutoPlay setting in the registry.
+ /////
+ //IOCTL_STORAGE_MCN_CONTROL = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0251 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Returns information about the geometry of floppy drives.
+ //IOCTL_STORAGE_GET_MEDIA_TYPES = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0300 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Returns information about the types of media supported by a device. A storage class driver must handle this IOCTL to control devices to be accessed by the removable storage manager (RSM) either as stand-alone devices or as data transfer elements (drives) in a media library or changer device.
+ //IOCTL_STORAGE_GET_MEDIA_TYPES_EX = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0301 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Resets an I/O bus and, indirectly, each device on the bus. Resetting the bus clears all device reservations and transfer speed settings, which must then be renegotiated, making it a time-consuming operation that should be used very rarely. The caller requires only read access to issue a bus reset.
+ //[Obsolete]
+ //IOCTL_STORAGE_RESET_BUS = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0400 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// If possible, resets a non-SCSI storage device without affecting other devices on the bus. Device reset for SCSI devices is not supported. The caller requires only read access to issue a device reset and, to comply, the device must be capable of responding to I/O requests. If the device reset succeeds, pending I/O requests are canceled.
+ //[Obsolete]
+ //IOCTL_STORAGE_RESET_DEVICE = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0401 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ /// Returns a STORAGE_DEVICE_NUMBER structure that contains the XXX type, device number, and, for a partitionable device,
+ /// the partition number assigned to a device by the driver when the device is started. This request is usually issued by a fault-tolerant disk driver.
+ ///
+ IOCTL_STORAGE_GET_DEVICE_NUMBER = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0420 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// Polls for a prediction of device failure. This request works with the IDE disk drives that support self-monitoring analysis and reporting technology (SMART). If the drive is a SCSI drive, the class driver attempts to verify if the SCSI disk supports the equivalent IDE SMART technology by check the inquiry information on the Information Exception Control Page, X3T10/94-190 Rev 4.
+ ///// If the device supports prediction failure, the disk class driver queries the device for failure prediction status and reports the results. If the disk class driver assigns a nonzero value to the PredictFailure member of STORAGE_PREDICT_FAILURE in the output buffer at Irp->AssociatedIrp.SystemBuffer, the disk has bad sectors and is predicting a failure. The storage stack returns 512 bytes of vendor-specific information about the failure prediction in the VendorSpecific member of STORAGE_PREDICT_FAILURE.
+ ///// If the PredictFailure member contains a value of zero, the disk is not predicting a failure.
+ /////
+ //IOCTL_STORAGE_PREDICT_FAILURE = (FILE_DEVICE.MASS_STORAGE << 16) | (0x0440 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+ #endregion // MASS_STORAGE
+
+
+ #region DISK
+
+ /// Returns information about the physical disk's geometry (media type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector).
+ /// IOCTL_DISK_GET_DRIVE_GEOMETRY_EX can retrieve information from both Master Boot Record (MBR) and GUID Partition Table (GPT)-type partitioned media.
+ ///
+ IOCTL_DISK_GET_DRIVE_GEOMETRY_EX = (FILE_DEVICE.DISK << 16) | (0x0028 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///////// Returns information about the type, size, and nature of a disk partition. (Floppy drivers need not handle this request.)
+ //IOCTL_DISK_GET_PARTITION_INFO_EX = (FILE_DEVICE.DISK << 16) | (0x0012 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Changes the partition type of the specified disk partition. (Floppy drivers need not handle this request.)
+ //IOCTL_DISK_SET_PARTITION_INFO = (FILE_DEVICE.DISK << 16) | (0x0002 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ /// Contains extended information about a drive's partitions.
+ IOCTL_DISK_GET_DRIVE_LAYOUT_EX = (FILE_DEVICE.DISK << 16) | (0x0014 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Repartitions a disk as specified. (Floppy drivers need not handle this request.)
+ //IOCTL_DISK_SET_DRIVE_LAYOUT = (FILE_DEVICE.DISK << 16) | (0x0004 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Performs a logical format of a specified extent on a disk.
+ //IOCTL_DISK_VERIFY = (FILE_DEVICE.DISK << 16) | (0x0005 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Formats the specified set of contiguous tracks on the disk.
+ //IOCTL_DISK_FORMAT_TRACKS = (FILE_DEVICE.DISK << 16) | (0x0006 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Maps defective blocks to new location on disk. This request instructs the device to reassign the bad block address to a good block from its spare-block pool.
+ //IOCTL_DISK_REASSIGN_BLOCKS = (FILE_DEVICE.DISK << 16) | (0x0007 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Increments a reference counter that enables the collection of disk performance statistics, such as the numbers of bytes read and written since the driver last processed this request, for a corresponding disk monitoring application. In Microsoft Windows 2000 this IOCTL is handled by the filter driver diskperf. In Windows XP and later operating systems, the partition manager handles this request for disks and ftdisk.sys and dmio.sys handle this request for volumes.
+ //IOCTL_DISK_PERFORMANCE = (FILE_DEVICE.DISK << 16) | (0x0008 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Determines whether a disk is writable.
+ //IOCTL_DISK_IS_WRITABLE = (FILE_DEVICE.DISK << 16) | (0x0009 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //IOCTL_DISK_LOGGING = (FILE_DEVICE.DISK << 16) | (0x000a << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Is similar to IOCTL_DISK_FORMAT_TRACKS, except that it allows the caller to specify several more parameters. The additional extended parameters are the format gap length, the number of sectors per track, and an array whose element size is equal to the number of sectors per track. This array represents the track layout.
+ //IOCTL_DISK_FORMAT_TRACKS_EX = (FILE_DEVICE.DISK << 16) | (0x000b << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Do not use
+ //[Obsolete]
+ //IOCTL_DISK_HISTOGRAM_STRUCTURE = (FILE_DEVICE.DISK <<16) | (0x000c << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Do not use
+ //[Obsolete]
+ //IOCTL_DISK_HISTOGRAM_DATA = (FILE_DEVICE.DISK <<16) | (0x000d << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Do not use
+ //[Obsolete]
+ //IOCTL_DISK_HISTOGRAM_RESET = (FILE_DEVICE.DISK <<16) | (0x000e << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Do not use
+ //[Obsolete]
+ //IOCTL_DISK_REQUEST_STRUCTURE = (FILE_DEVICE.DISK <<16) | (0x000f << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+ ///// Do not use
+ //[Obsolete]
+ //IOCTL_DISK_REQUEST_DATA = (FILE_DEVICE.DISK <<16) | (0x0010 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Do not use
+ //[Obsolete]
+ //IOCTL_DISK_CONTROLLER_NUMBER = (FILE_DEVICE.DISK <<16) | (0x0011 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /// Retrieves the length of the specified disk, volume, or partition.
+ /// This operation should be used instead of IOCTL_DISK_GET_PARTITION_INFO_EX for volumes that do not have partition info, such as partition type or number of hidden sectors.
+ IOCTL_DISK_GET_LENGTH_INFO = (FILE_DEVICE.DISK << 16) | (0x0017 << 2) | IoControlMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Returns version information, a capabilities mask, and a bitmask for the device. This IOCTL must be handled by drivers that support Self-Monitoring Analysis and Reporting Technology (SMART).
+ //SMART_GET_VERSION = (FILE_DEVICE.DISK << 16) | (0x0020 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ /////
+ ///// Sends one of the following Self-Monitoring Analysis and Reporting Technology (SMART) commands to the device:
+ ///// * Enable or disable reporting on the device
+ ///// * Enable or disable autosaving of attributes
+ ///// * Save current attributes now
+ ///// * Execute offline diagnostics
+ ///// * Get current SMART status
+ ///// * Write to SMART log
+ ///// This IOCTL must be handled by drivers that support SMART.
+ /////
+ //SMART_SEND_DRIVE_COMMAND = (FILE_DEVICE.DISK << 16) | (0x0021 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Returns the ATA-2 identify data, the Self-Monitoring Analysis and Reporting Technology (SMART) thresholds, or the SMART attributes for the device. This IOCTL must be handled by drivers that support SMART.
+ //SMART_RCV_DRIVE_DATA = (FILE_DEVICE.DISK << 16) | (0x0022 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Updates device extension with drive size information for current media.
+ //IOCTL_DISK_UPDATE_DRIVE_SIZE = (FILE_DEVICE.DISK << 16) | (0x0032 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Increases the size of an existing partition. It is used in conjunction with IOCTL_DISK_UPDATE_DRIVE_SIZE to extend a disk, so that it will contain a new free space area, and then to extend an existing partition on the disk into the newly attached free space. It takes a DISK_GROW_PARTITION structure as the only parameter. For this operation to work, the space after the specified partition must be free. A partition cannot be extended over another existing partition.
+ //IOCTL_DISK_GROW_PARTITION = (FILE_DEVICE.DISK << 16) | (0x0034 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Returns disk cache configuration data.
+ //IOCTL_DISK_GET_CACHE_INFORMATION = (FILE_DEVICE.DISK << 16) | (0x0035 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Sets disk cache configuration data.
+ //IOCTL_DISK_SET_CACHE_INFORMATION = (FILE_DEVICE.DISK << 16) | (0x0036 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Removes partition information from the disk. If the partition style of the disk is Master Boot Record (MBR), sector 0 of the disk is wiped clean except for the bootstrap code. All signatures, such as the AA55 boot signature and the NTFT disk signature, will be removed. If the partition style of the disk is GUID Partition Table (GPT), the primary partition table header in sector 1 and the backup partition table in the last sector of the disk are wiped clean. This operation can be used to generate so-called "superfloppies" that contain a file system starting at the first sector of the disk rather than in a partition on the disk.
+ //IOCTL_DISK_DELETE_DRIVE_LAYOUT = (FILE_DEVICE.DISK << 16) | (0x0040 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ /////
+ //DiskSenseDevice = (FILE_DEVICE.DISK << 16) | (0x00f8 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// In Microsoft Windows 2000 and later operating systems, this IOCTL is replaced by IOCTL_STORAGE_CHECK_VERIFY. The only difference between the two IOCTLs is the base value.
+ //IOCTL_DISK_CHECK_VERIFY = (FILE_DEVICE.DISK << 16) | (0x0200 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// In Microsoft Windows 2000 and later operating systems, this IOCTL is replaced by IOCTL_STORAGE_FIND_NEW_DEVICES. The only difference between the two IOCTLs is the base value.
+ //IOCTL_DISK_FIND_NEW_DEVICES = (FILE_DEVICE.DISK << 16) | (0x0206 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// In Microsoft Windows 2000 and later operating systems, this IOCTL is replaced by IOCTL_STORAGE_GET_MEDIA_TYPES. The only difference between the two IOCTLs is the base value.
+ //IOCTL_DISK_GET_MEDIA_TYPES = (FILE_DEVICE.DISK << 16) | (0x0300 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+ #endregion // DISK
+
+
+ #region CHANGER
+
+ ///// Retrieves the parameters of the specified device.
+ //IOCTL_CHANGER_GET_PARAMETERS = (FILE_DEVICE.CHANGER << 16) | (0x0000 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Retrieves the current status of the specified device.
+ //IOCTL_CHANGER_GET_STATUS = (FILE_DEVICE.CHANGER << 16) | (0x0001 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Retrieves the product data for the specified device.
+ //IOCTL_CHANGER_GET_PRODUCT_DATA = (FILE_DEVICE.CHANGER << 16) | (0x0002 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Sets the state of the device's insert/eject port, door, or keypad.
+ //IOCTL_CHANGER_SET_ACCESS = (FILE_DEVICE.CHANGER << 16) | (0x0004 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Retrieves the status of all elements or a specified number of elements of a particular type.
+ //IOCTL_CHANGER_GET_ELEMENT_STATUS = (FILE_DEVICE.CHANGER << 16) | (0x0005 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Initializes the status of all elements or the specified elements of a particular type.
+ //IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS = (FILE_DEVICE.CHANGER << 16) | (0x0006 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Sets the changer's robotic transport mechanism to the specified element address. This optimizes moving or exchanging media by positioning the transport beforehand.
+ //IOCTL_CHANGER_SET_POSITION = (FILE_DEVICE.CHANGER << 16) | (0x0007 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Moves a piece of media from a source element to one destination, and the piece of media originally in the first destination to a second destination.
+ //IOCTL_CHANGER_EXCHANGE_MEDIUM = (FILE_DEVICE.CHANGER << 16) | (0x0008 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Moves a piece of media to a destination.
+ //IOCTL_CHANGER_MOVE_MEDIUM = (FILE_DEVICE.CHANGER << 16) | (0x0009 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Physically recalibrates a transport element. Recalibration may involve returning the transport to its home position.
+ //IOCTL_CHANGER_REINITIALIZE_TRANSPORT = (FILE_DEVICE.CHANGER << 16) | (0x000A << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ ///// Retrieves the volume tag information for the specified elements.
+ //IOCTL_CHANGER_QUERY_VOLUME_TAGS = (FILE_DEVICE.CHANGER << 16) | (0x000B << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+ #endregion // CHANGER
+
+
+ #region FILE_SYSTEM
+
+ ///// Requests a level 1 opportunistic lock on a file.
+ //FSCTL_REQUEST_OPLOCK_LEVEL_1 = (FILE_DEVICE.FILE_SYSTEM << 16) | (0 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Requests a level 2 opportunistic lock on a file.
+ //FSCTL_REQUEST_OPLOCK_LEVEL_2 = (FILE_DEVICE.FILE_SYSTEM << 16) | (1 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+ ///// Requests a batch opportunistic lock on a file.
+ //FSCTL_REQUEST_BATCH_OPLOCK = (FILE_DEVICE.FILE_SYSTEM << 16) | (2 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Responds to notification that an exclusive opportunistic lock on a file is about to be broken. Use this operation to indicate that the file should receive a level 2 opportunistic lock.
+ //FSCTL_OPLOCK_BREAK_ACKNOWLEDGE = (FILE_DEVICE.FILE_SYSTEM << 16) | (3 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Notifies a server that a client application is ready to close a file. Use this operation after notification that an opportunistic lock on a file is ready to be broken.
+ //FSCTL_OPBATCH_ACK_CLOSE_PENDING = (FILE_DEVICE.FILE_SYSTEM << 16) | (4 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// Enables the calling application to wait for completion of an opportunistic lock break.
+ ///// This operation is not useful to application developers and is documented here only for completeness. CreateFile handles the problem that this operation was designed to handle.
+ /////
+ //FSCTL_OPLOCK_BREAK_NOTIFY = (FILE_DEVICE.FILE_SYSTEM << 16) | (5 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Locks a volume if it is not in use. A locked volume can be accessed only through handles to the file object (*hDevice) that locks the volume. For more information, see the Remarks section.
+ //FSCTL_LOCK_VOLUME = (FILE_DEVICE.FILE_SYSTEM << 16) | (6 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Unlocks a volume.
+ //FSCTL_UNLOCK_VOLUME = (FILE_DEVICE.FILE_SYSTEM << 16) | (7 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Dismounts a volume regardless of whether or not the volume is currently in use. For more information, see the Remarks section.
+ //FSCTL_DISMOUNT_VOLUME = (FILE_DEVICE.FILE_SYSTEM << 16) | (8 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Determines whether the specified volume is mounted, or if the specified file or directory is on a mounted volume.
+ //FSCTL_IS_VOLUME_MOUNTED = (FILE_DEVICE.FILE_SYSTEM << 16) | (10 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_IS_PATHNAME_VALID control code performs static analysis of the supplied pathname and returns a status value that indicates
+ ///// whether the pathname is well formed (for example, no illegal characters, acceptable path length, and so on). Because this analysis does
+ ///// not consider the content of the volume, it sometimes gives "false positives." In other words, the analysis might indicate that the
+ ///// pathname is well formed, even when it is not. Negative results are more reliable, but are not guaranteed to be correct.
+ ///// This control code is not supported with fast FAT file systems, and it is not a meaningful operation in NTFS or UDFS. NTFS and UDFS support
+ ///// such a wide variety of codesets that any string is potentially a valid pathname.
+ /////
+ //FSCTL_IS_PATHNAME_VALID = (FILE_DEVICE.FILE_SYSTEM << 16) | (11 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// The FSCTL_MARK_VOLUME_DIRTY control code marks a specified volume as dirty, which triggers Autochk.exe to run on the volume during the next system restart.
+ //FSCTL_MARK_VOLUME_DIRTY = (FILE_DEVICE.FILE_SYSTEM << 16) | (12 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_QUERY_RETRIEVAL_POINTERS control code retrieves a mapping between virtual cluster numbers (VCN, offsets within the file/stream
+ ///// space) and logical cluster numbers (LCN, offsets within the volume space), starting at the beginning of the file up to the map size
+ ///// specified in InputBuffer.
+ ///// FSCTL_QUERY_RETRIEVAL_POINTERS is similar to FSCTL_GET_RETRIEVAL_POINTERS. However, FSCTL_QUERY_RETRIEVAL_POINTERS only works in kernel
+ ///// mode on local paging files or the system hives. The paging file is guaranteed to have a one-to-one mapping from the VCN in a volume to the
+ ///// LCN that refer more directly to the underlying physical storage. You must not use FSCTL_QUERY_RETRIEVAL_POINTERS with files other than
+ ///// the page file, because they might reside on volumes, such as mirrored volumes, that have one-to-many mappings of VCNs to LCNs.
+ /////
+ //FSCTL_QUERY_RETRIEVAL_POINTERS = (FILE_DEVICE.FILE_SYSTEM << 16) | (14 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves the current compression state of a file or directory on a volume whose file system supports per-stream compression.
+ //FSCTL_GET_COMPRESSION = (FILE_DEVICE.FILE_SYSTEM << 16) | (15 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /// Sets the compression state of a file or directory on a volume whose file system supports per-file and per-directory compression. You can use FSCTL_SET_COMPRESSION to compress or uncompress a file or directory on such a volume.
+ FSCTL_SET_COMPRESSION = (FILE_DEVICE.FILE_SYSTEM << 16) | (16 << 2) | IoControlMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ /////
+ ///// The FSCTL_MARK_AS_SYSTEM_HIVE control code informs the file system that the specified file contains the registry's system hive. The file
+ ///// system must flush system hive data to disk at just the right moment to avoid deadlocks and to ensure data integrity. Do not use this file
+ ///// system control code with any file other than the file that contains the registry's system hive. This control code does not work with a
+ ///// directory or volume handle. File system redirectors that access files on remote machines treat this control code as a no-op.
+ ///// Only kernel-level components can use this filesystem control code.
+ /////
+ //FSCTL_MARK_AS_SYSTEM_HIVE = (FILE_DEVICE.FILE_SYSTEM << 16) | (19 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_OPLOCK_BREAK_ACK_NO_2 control code responds to notification that an exclusive (level 1, batch, or filter) opportunistic lock
+ ///// (oplock) on a file has been broken.
+ ///// A client application sends this control code to indicate that it acknowledges the oplock break and that, if the oplock is a level 1 oplock
+ ///// that was broken to level 2, it does not want the level 2 oplock.
+ ///// To process this control code, a minifilter calls FltOplockFsctrl with the following parameters. A file system or legacy filter driver
+ ///// calls FsRtlOplockFsctrl.
+ ///// For more information about opportunistic locking and about the FSCTL_OPLOCK_BREAK_ACK_NO_2 control code, see the Microsoft Windows SDK
+ ///// documentation.
+ /////
+ //FSCTL_OPLOCK_BREAK_ACK_NO_2 = (FILE_DEVICE.FILE_SYSTEM << 16) | (20 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_INVALIDATE_VOLUMES control code finds and removes all the volumes mounted on the device represented by the specified file object
+ ///// or handle.
+ ///// To perform this operation, minifilter drivers call FltFsControlFile, and file systems, redirectors, and legacy file system filter drivers
+ ///// call ZwFsControlFile, using the following parameters.
+ /////
+ //FSCTL_INVALIDATE_VOLUMES = (FILE_DEVICE.FILE_SYSTEM << 16) | (21 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FSCTL_QUERY_FAT_BPB = (FILE_DEVICE.FILE_SYSTEM << 16) | (22 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_REQUEST_FILTER_OPLOCK control code requests a filter opportunistic lock (oplock) on a file.
+ ///// To process this control code, a minifilter calls FltOplockFsctrl with the following parameters. A file system or legacy filter driver
+ ///// calls FsRtlOplockFsctrl.
+ ///// For more information about opportunistic locking and about the FSCTL_REQUEST_FILTER_OPLOCK control code, see the Microsoft Windows SDK
+ ///// documentation.
+ /////
+ //FSCTL_REQUEST_FILTER_OPLOCK = (FILE_DEVICE.FILE_SYSTEM << 16) | (23 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves the information from various file system performance counters.
+ //FSCTL_FILESYSTEM_GET_STATISTICS = (FILE_DEVICE.FILE_SYSTEM << 16) | (24 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves information about the specified NTFS file system volume.
+ //FSCTL_GET_NTFS_VOLUME_DATA = (FILE_DEVICE.FILE_SYSTEM << 16) | (25 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves the first file record that is in use and is of a lesser than or equal ordinal value to the requested file reference number.
+ //FSCTL_GET_NTFS_FILE_RECORD = (FILE_DEVICE.FILE_SYSTEM << 16) | (26 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves a bitmap of occupied and available clusters on a volume.
+ //FSCTL_GET_VOLUME_BITMAP = (FILE_DEVICE.FILE_SYSTEM << 16) | (27 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Given a file handle, retrieves a data structure that describes the allocation and location on disk of a specific file, or, given a volume handle, the locations of bad clusters on a volume.
+ //FSCTL_GET_RETRIEVAL_POINTERS = (FILE_DEVICE.FILE_SYSTEM << 16) | (28 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Relocates one or more virtual clusters of a file from one logical cluster to another within the same volume. This operation is used during defragmentation.
+ //FSCTL_MOVE_FILE = (FILE_DEVICE.FILE_SYSTEM << 16) | (29 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_IS_VOLUME_DIRTY control code determines whether the specified volume is dirty.
+ ///// If the volume information file is corrupted, NTFS will return STATUS_FILE_CORRUPT_ERROR.
+ ///// To perform this operation, minifilter drivers call FltFsControlFile with the following parameters, and file systems, redirectors, and
+ ///// legacy file system filter drivers call ZwFsControlFile with the following parameters.
+ /////
+ //FSCTL_IS_VOLUME_DIRTY = (FILE_DEVICE.FILE_SYSTEM << 16) | (30 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlGetHfsInformation = (FILE_DEVICE.FILE_SYSTEM << 16) | (31 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Signals the file system driver not to perform any I/O boundary checks on partition read or write calls. Instead, boundary checks are performed by the device driver.
+ //FSCTL_ALLOW_EXTENDED_DASD_IO = (FILE_DEVICE.FILE_SYSTEM << 16) | (32 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlReadPropertyData = (FILE_DEVICE.FILE_SYSTEM << 16) | (33 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlWritePropertyData = (FILE_DEVICE.FILE_SYSTEM << 16) | (34 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlDumpPropertyData = (FILE_DEVICE.FILE_SYSTEM << 16) | (37 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Searches a directory for a file whose creator owner matches the specified SID.
+ //FSCTL_FIND_FILES_BY_SID = (FILE_DEVICE.FILE_SYSTEM << 16) | (35 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Sets the object identifier for the specified file or directory.
+ //FSCTL_SET_OBJECT_ID = (FILE_DEVICE.FILE_SYSTEM << 16) | (38 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves the object identifier for the specified file or directory.
+ //FSCTL_GET_OBJECT_ID = (FILE_DEVICE.FILE_SYSTEM << 16) | (39 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Removes the object identifier from a specified file or directory. The underlying object is not deleted.
+ //FSCTL_DELETE_OBJECT_ID = (FILE_DEVICE.FILE_SYSTEM << 16) | (40 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///
+ /// The FSCTL_SET_REPARSE_POINT control code sets a reparse point on a file or directory.
+ /// To perform this operation, call ZwFsControlFile with the following parameters.
+ /// Minifilters should use FltTagFile instead of FSCTL_SET_REPARSE_POINT to set a reparse point.
+ /// For more information about reparse points and the FSCTL_SET_REPARSE_POINT control code, see the Microsoft Windows SDK documentation.
+ ///
+ FSCTL_SET_REPARSE_POINT = (FILE_DEVICE.FILE_SYSTEM << 16) | (41 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///
+ /// The FSCTL_GET_REPARSE_POINT control code retrieves the reparse point data associated with the specified file or directory.
+ /// To perform this operation, call FltFsControlFile or ZwFsControlFile with the following parameters.
+ /// For more information about reparse points and the FSCTL_GET_REPARSE_POINT control code, see the Microsoft Windows SDK documentation.
+ ///
+ FSCTL_GET_REPARSE_POINT = (FILE_DEVICE.FILE_SYSTEM << 16) | (42 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///
+ /// The FSCTL_DELETE_REPARSE_POINT control code deletes a reparse point from the specified file or directory.
+ /// Using FSCTL_DELETE_REPARSE_POINT does not delete the file or directory.
+ /// To perform this operation, call ZwFsControlFile with the following parameters.
+ /// Minifilters should use FltUntagFile instead of FSCTL_DELETE_REPARSE_POINT to delete a reparse point.
+ /// For more information about reparse points and the FSCTL_DELETE_REPARSE_POINT control code, see the Microsoft Windows SDK documentation.
+ ///
+ FSCTL_DELETE_REPARSE_POINT = (FILE_DEVICE.FILE_SYSTEM << 16) | (43 << 2) | IoControlMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// Enumerates the update sequence number (USN) data between two specified boundaries to obtain master file table (MFT) records.
+ /////
+ //FSCTL_ENUM_USN_DATA = (FILE_DEVICE.FILE_SYSTEM << 16) | (44 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// The FSCTL_SECURITY_ID_CHECK control code performs a bulk security check of the security identifiers exposed through USN records.
+ //FSCTL_SECURITY_ID_CHECK = (FILE_DEVICE.FILE_SYSTEM << 16) | (45 << 2) | IoMethod.Neither | (FileAccess.Read << 14),
+
+
+ ///// Retrieves the set of update sequence number (USN) change journal records between two specified USN values.
+ //FSCTL_READ_USN_JOURNAL = (FILE_DEVICE.FILE_SYSTEM << 16) | (46 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Modifies user data associated with the object identifier for the specified file or directory.
+ //FSCTL_SET_OBJECT_ID_EXTENDED = (FILE_DEVICE.FILE_SYSTEM << 16) | (47 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves the object identifier for the specified file or directory. If no object identifier exists, using FSCTL_CREATE_OR_GET_OBJECT_ID creates one.
+ //FSCTL_CREATE_OR_GET_OBJECT_ID = (FILE_DEVICE.FILE_SYSTEM << 16) | (48 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Marks the indicated file as sparse or not sparse. In a sparse file, large ranges of zeros may not require disk allocation. Space for nonzero data will be allocated as needed as the file is written.
+ //FSCTL_SET_SPARSE = (FILE_DEVICE.FILE_SYSTEM << 16) | (49 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Fills a specified range of a file with zeros (0). If the file is sparse or compressed, the NTFS file system may deallocate disk space in the file. This sets the range of bytes to zeros (0) without extending the file size.
+ //FSCTL_SET_ZERO_DATA = (FILE_DEVICE.FILE_SYSTEM << 16) | (50 << 2) | IoMethod.Buffered | (FileAccess.Write << 14),
+
+
+ ///// Scans a file or alternate stream looking for ranges that may contain nonzero data. Only compressed or sparse files can have zeroed ranges known to the operating system. For other files, the output buffer will contain only a single entry that contains the starting point and the length requested.
+ //FSCTL_QUERY_ALLOCATED_RANGES = (FILE_DEVICE.FILE_SYSTEM << 16) | (51 << 2) | IoMethod.Neither | (FileAccess.Read << 14),
+
+
+ /////
+ //FsctlEnableUpgrade = (FILE_DEVICE.FILE_SYSTEM << 16) | (52 << 2) | IoMethod.Buffered | (FileAccess.Write << 14),
+
+
+ /////
+ ///// The FSCTL_SET_ENCRYPTION request sets the encryption for the file or directory associated with the given handle.
+ ///// The message contains an ENCRYPTION_BUFFER structure that indicates whether to encrypt/decrypt a file or an individual stream.
+ /////
+ //FSCTL_SET_ENCRYPTION = (FILE_DEVICE.FILE_SYSTEM << 16) | (53 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlEncryptionFsctlIo = (FILE_DEVICE.FILE_SYSTEM << 16) | (54 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlWriteRawEncrypted = (FILE_DEVICE.FILE_SYSTEM << 16) | (55 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlReadRawEncrypted = (FILE_DEVICE.FILE_SYSTEM << 16) | (56 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Creates an update sequence number (USN) change journal stream on a target volume, or modifies an existing change journal stream.
+ //FSCTL_CREATE_USN_JOURNAL = (FILE_DEVICE.FILE_SYSTEM << 16) | (57 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Retrieves the update sequence number (USN) change-journal information for the specified file or directory.
+ //FSCTL_READ_FILE_USN_DATA = (FILE_DEVICE.FILE_SYSTEM << 16) | (58 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Generates a record in the update sequence number (USN) change journal stream for the input file. This record will have the USN_REASON_CLOSE flag.
+ //FSCTL_WRITE_USN_CLOSE_RECORD = (FILE_DEVICE.FILE_SYSTEM << 16) | (59 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Increases the size of a mounted volume.
+ //FSCTL_EXTEND_VOLUME = (FILE_DEVICE.FILE_SYSTEM << 16) | (60 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Queries for information on the current update sequence number (USN) change journal, its records, and its capacity.
+ //FSCTL_QUERY_USN_JOURNAL = (FILE_DEVICE.FILE_SYSTEM << 16) | (61 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Deletes the update sequence number (USN) change journal on a volume, or waits for notification of change journal deletion.
+ //FSCTL_DELETE_USN_JOURNAL = (FILE_DEVICE.FILE_SYSTEM << 16) | (62 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ ///// Marks a specified file or directory and its change journal record with information about changes to that file or directory.
+ //FSCTL_MARK_HANDLE = (FILE_DEVICE.FILE_SYSTEM << 16) | (63 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ ///// The FSCTL_SIS_COPYFILE request message requests that the server use the single-instance storage (SIS)filter to copy a file.
+ ///// The message contains an SI_COPYFILE data element. For more information about single-instance storage, see [SIS].
+ ///// If the SIS filter is installed on the server, it will attempt to copy the specified source file to the specified destination
+ ///// file by creating an SIS link instead of actually copying the file data. If necessary and allowed, the source file is placed under
+ ///// SIS control before the destination file is created.
+ ///// This FSCTL can be issued against either a file or directory handle. The source and destination files MUST reside on the volume
+ ///// associated with the given handle.
+ /////
+ //FSCTL_SIS_COPYFILE = (FILE_DEVICE.FILE_SYSTEM << 16) | (64 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+
+ /////
+ //FsctlSisLinkFiles = (FILE_DEVICE.FILE_SYSTEM << 16) | (65 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ /////
+ //FsctlHsmMsg = (FILE_DEVICE.FILE_SYSTEM << 16) | (66 << 2) | IoMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ /////
+ //FsctlNssControl = (FILE_DEVICE.FILE_SYSTEM << 16) | (67 << 2) | IoMethod.Buffered | (FileAccess.Write << 14),
+
+
+ /////
+ //FsctlNssRcontrol = (FILE_DEVICE.FILE_SYSTEM << 16) | (70 << 2) | IoMethod.Buffered | (FileAccess.Read << 14),
+
+
+ /////
+ //FsctlHsmData = (FILE_DEVICE.FILE_SYSTEM << 16) | (68 << 2) | IoMethod.Neither | ((FileAccess.Read | FileAccess.Write) << 14),
+
+
+ ///// Recalls a file from storage media that Remote Storage manages, which is the hierarchical storage management software.
+ //FSCTL_RECALL_FILE = (FILE_DEVICE.FILE_SYSTEM << 16) | (69 << 2) | IoMethod.Neither | (FILE_ANY_ACCESS << 14),
+
+
+ ///// The FSCTL_GET_BOOT_AREA_INFO control code retrieves the locations of boot sectors for a volume.
+ //FSCTL_GET_BOOT_AREA_INFO = (FILE_DEVICE.FILE_SYSTEM << 16) | (140 << 2) | IoMethod.Buffered | (FILE_ANY_ACCESS << 14),
+
+ #endregion // FILE_SYSTEM
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/IoControlMethod.cs b/AlphaFS/Device/Native Other/IoControlMethod.cs
new file mode 100644
index 000000000..54c98f9b0
--- /dev/null
+++ b/AlphaFS/Device/Native Other/IoControlMethod.cs
@@ -0,0 +1,35 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Define values for DeviceIoControl.
+ private enum IoControlMethod : uint
+ {
+ Buffered = 0,
+ InDirect = 1,
+ OutDirect = 2,
+ Neither = 3
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/MEDIA_TYPE.cs b/AlphaFS/Device/Native Other/MEDIA_TYPE.cs
new file mode 100644
index 000000000..bdb035df0
--- /dev/null
+++ b/AlphaFS/Device/Native Other/MEDIA_TYPE.cs
@@ -0,0 +1,305 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Represents the various forms of device media.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ public enum MEDIA_TYPE
+ {
+ /// Format is unknown.
+ Unknown = 0,
+
+ /// A 5.25" floppy, with 1.2MB and 512 bytes/sector.
+ F5_1Pt2_512 = 1,
+
+ /// A 3.5" floppy, with 1.44MB and 512 bytes/sector.
+ F3_1Pt44_512 = 2,
+
+ /// A 3.5" floppy, with 2.88MB and 512 bytes/sector.
+ F3_2Pt88_512 = 3,
+
+ /// A 3.5" floppy, with 20.8MB and 512 bytes/sector.
+ F3_20Pt8_512 = 4,
+
+ /// A 3.5" floppy, with 720KB and 512 bytes/sector.
+ F3_720_512 = 5,
+
+ /// A 5.25" floppy, with 360KB and 512 bytes/sector.
+ F5_360_512 = 6,
+
+ /// A 5.25" floppy, with 320KB and 512 bytes/sector.
+ F5_320_512 = 7,
+
+ /// A 5.25" floppy, with 320KB and 1024 bytes/sector.
+ F5_320_1024 = 8,
+
+ /// A 5.25" floppy, with 180KB and 512 bytes/sector.
+ F5_180_512 = 9,
+
+ /// A 5.25" floppy, with 160KB and 512 bytes/sector.
+ F5_160_512 = 10,
+
+ /// Removable media other than floppy.
+ RemovableMedia = 11,
+
+ /// Fixed hard disk media.
+ FixedMedia = 12,
+
+ /// A 3.5" floppy, with 120MB and 512 bytes/sector.
+ F3_120M_512 = 13,
+
+ /// A 3.5" floppy, with 640KB and 512 bytes/sector.
+ F3_640_512 = 14,
+
+ /// A 5.25" floppy, with 640KB and 512 bytes/sector.
+ F5_640_512 = 15,
+
+ /// A 5.25" floppy, with 720KB and 512 bytes/sector.
+ F5_720_512 = 16,
+
+ /// A 3.5" floppy, with 1.2MB and 512 bytes/sector.
+ F3_1Pt2_512 = 17,
+
+ /// A 3.5" floppy, with 1.23MB and 1024 bytes/sector.
+ F3_1Pt23_1024 = 18,
+
+ /// A 5.25" floppy, with 1.23MB and 1024 bytes/sector.
+ F5_1Pt23_1024 = 19,
+
+ /// A 3.5" floppy, with 128MB and 512 bytes/sector.
+ F3_128Mb_512 = 20,
+
+ /// A 3.5" floppy, with 230MB and 512 bytes/sector.
+ F3_230Mb_512 = 21,
+
+ /// An 8" floppy, with 256KB and 128 bytes/sector.
+ F8_256_128 = 22,
+
+ /// A 3.5" floppy, with 200MB and 512 bytes/sector. (HiFD).
+ F3_200Mb_512 = 23,
+
+ /// A 3.5" floppy, with 240MB and 512 bytes/sector. (HiFD).
+ F3_240M_512 = 24,
+
+ /// A 3.5" floppy, with 32MB and 512 bytes/sector.
+ F3_32M_512 = 25,
+
+ /// One of the following tape types: DAT, DDS1, DDS2, and so on.
+ DDS_4mm = 32,
+
+ /// MiniQIC tape.
+ MiniQic = 33,
+
+ /// Travan tape (TR-1, TR-2, TR-3, and so on).
+ Travan = 34,
+
+ /// QIC tape.
+ QIC = 35,
+
+ /// An 8mm Exabyte metal particle tape.
+ MP_8mm = 36,
+
+ /// An 8mm Exabyte advanced metal evaporative tape.
+ AME_8mm = 37,
+
+ /// An 8mm Sony AIT1 tape.
+ AIT1_8mm = 38,
+
+ /// DLT compact tape (IIIxt or IV).
+ DLT = 39,
+
+ /// Philips NCTP tape.
+ NCTP = 40,
+
+ /// IBM 3480 tape.
+ IBM_3480 = 41,
+
+ /// IBM 3490E tape.
+ IBM_3490E = 42,
+
+ /// IBM Magstar 3590 tape.
+ IBM_Magstar_3590 = 43,
+
+ /// IBM Magstar MP tape.
+ IBM_Magstar_MP = 44,
+
+ /// STK data D3 tape.
+ STK_DATA_D3 = 45,
+
+ /// Sony DTF tape.
+ SONY_DTF = 46,
+
+ /// A 6mm digital videotape.
+ DV_6mm = 47,
+
+ /// Exabyte DMI tape (or compatible).
+ DMI = 48,
+
+ /// Sony D2S or D2L tape.
+ SONY_D2 = 49,
+
+ /// Cleaner (all drive types that support cleaners).
+ CLEANER_CARTRIDGE = 50,
+
+ /// CD.
+ CD_ROM = 51,
+
+ /// CD (write once).
+ CD_R = 52,
+
+ /// CD (rewriteable).
+ CD_RW = 53,
+
+ /// DVD.
+ DVD_ROM = 54,
+
+ /// DVD (write once).
+ DVD_R = 55,
+
+ /// DVD (rewriteable).
+ DVD_RW = 56,
+
+ /// Magneto-optical 3.5" (rewriteable).
+ MO_3_RW = 57,
+
+ /// Magneto-optical 5.25" (write once).
+ MO_5_WO = 58,
+
+ /// Magneto-optical 5.25" (rewriteable; not LIMDOW).
+ MO_5_RW = 59,
+
+ /// Magneto-optical 5.25" (rewriteable; LIMDOW).
+ MO_5_LIMDOW = 60,
+
+ /// Phase change 5.25" (write once).
+ PC_5_WO = 61,
+
+ /// Phase change 5.25" (rewriteable).
+ PC_5_RW = 62,
+
+ /// Phase change dual (rewriteable).
+ PD_5_RW = 63,
+
+ /// Ablative 5.25" (write once).
+ ABL_5_WO = 64,
+
+ /// Pinnacle Apex 4.6GB (rewriteable)
+ PINNACLE_APEX_5_RW = 65,
+
+ /// Sony 12" (write once).
+ SONY_12_WO = 66,
+
+ /// Philips/LMS 12" (write once).
+ PHILIPS_12_WO = 67,
+
+ /// Hitachi 12" (write once).
+ HITACHI_12_WO = 68,
+
+ /// Cygnet/ATG 12" (write once).
+ CYGNET_12_WO = 69,
+
+ /// Kodak 14" (write once).
+ KODAK_14_WO = 70,
+
+ /// MO near field recording (Terastor).
+ MO_NFR_525 = 71,
+
+ /// Nikon 12" (rewriteable).
+ NIKON_12_RW = 72,
+
+ /// Iomega Zip.
+ IOMEGA_ZIP = 73,
+
+ /// Iomega Jaz.
+ IOMEGA_JAZ = 74,
+
+ /// Syquest EZ135.
+ SYQUEST_EZ135 = 75,
+
+ /// Syquest EzFlyer.
+ SYQUEST_EZFLYER = 76,
+
+ /// Syquest SyJet.
+ SYQUEST_SYJET = 77,
+
+ /// Avatar 2.5" floppy.
+ AVATAR_F2 = 78,
+
+ /// An 8mm Hitachi tape.
+ MP2_8mm = 79,
+
+ /// Ampex DST small tape.
+ DST_S = 80,
+
+ /// Ampex DST medium tape.
+ DST_M = 81,
+
+ /// Ampex DST large tape.
+ DST_L = 82,
+
+ /// Ecrix 8mm tape.
+ VXATape_1 = 83,
+
+ /// Ecrix 8mm tape.
+ VXATape_2 = 84,
+
+ /// STK 9840.
+ STK_9840 = 85,
+
+ /// LTO Ultrium (IBM, HP, Seagate).
+ LTO_Ultrium = 86,
+
+ /// LTO Accelis (IBM, HP, Seagate).
+ LTO_Accelis = 87,
+
+ /// DVD-RAM.
+ DVD_RAM = 88,
+
+ /// AIT tape (AIT2 or higher).
+ AIT_8mm = 89,
+
+ /// OnStream ADR1.
+ ADR_1 = 90,
+
+ /// OnStream ADR2.
+ ADR_2 = 91,
+
+ /// STK 9940.
+ STK_9940 = 92,
+
+ /// SAIT tape.
+ /// Windows Server 2003: This is not supported before Windows Server 2003 with SP1.
+ ///
+ SAIT = 93,
+
+ /// Exabyte VXA tape.
+ /// Windows Server 2008: This is not supported before Windows Server 2008.
+ ///
+ VXATape = 94
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/NativeMethods.DiskPartitionType.cs b/AlphaFS/Device/Native Other/NativeMethods.DiskPartitionType.cs
new file mode 100644
index 000000000..fce9ddabe
--- /dev/null
+++ b/AlphaFS/Device/Native Other/NativeMethods.DiskPartitionType.cs
@@ -0,0 +1,60 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Valid partition types that are used by disk drivers.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ internal enum DiskPartitionType : byte
+ {
+ /// Unused partition entry.
+ PARTITION_ENTRY_UNUSED = 0,
+
+ /// DOS FAT12 primary partition or logical drive (fewer than 32,680 sectors in the volume).
+ PARTITION_FAT_12 = 1,
+
+ /// DOS 3.0+ FAT16 partition or logical drive (32,680�65,535 sectors or 16 MB�33 MB).
+ PARTITION_FAT_16 = 4,
+
+ /// DOS 3.3+ Extended partition.
+ PARTITION_EXTENDED = 5,
+
+ /// Installable File System (IFS). NTFS partition or logical drive.
+ PARTITION_IFS = 7,
+
+ /// FAT32 partition or logical drive.
+ PARTITION_FAT32 = 11,
+
+ /// LDM (Logical Disk Manager) Data partition on a dynamic disk.
+ PARTITION_LDM = 66,
+
+ /// An NTFT partition.
+ PARTITION_NTFT = 128,
+
+ /// A valid NTFT partition. The high bit of a partition type code indicates that a partition is part of an NTFT mirror or striped array.
+ VALID_NTFT = 192
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/NativeMethods.EfiPartitionAttributes.cs b/AlphaFS/Device/Native Other/NativeMethods.EfiPartitionAttributes.cs
new file mode 100644
index 000000000..cb42eb9de
--- /dev/null
+++ b/AlphaFS/Device/Native Other/NativeMethods.EfiPartitionAttributes.cs
@@ -0,0 +1,52 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// The Extensible Firmware Interface (EFI) partition attributes.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [Flags]
+ internal enum EfiPartitionAttributes : ulong
+ {
+ /// If this attribute is set, the partition is required by a Computer to function properly.
+ GPT_ATTRIBUTE_PLATFORM_REQUIRED = 0x0000000000000001,
+
+ /// If this attribute is set, the partition is read-only.
+ GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY = 0x1000000000000000,
+
+ /// If this attribute is set, the partition is a shadow copy of another partition.
+ GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY = 0x2000000000000000,
+
+ /// If this attribute is set, the partition is not detected by the Mount Manager.
+ GPT_BASIC_DATA_ATTRIBUTE_HIDDEN = 0x4000000000000000,
+
+ /// If this attribute is set, the partition does not receive a drive letter by default when the disk is moved to another Computer or when the disk is seen for the first time by a Computer.
+ GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER = 0x8000000000000000
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/PARTITION_INFORMATION_EX.cs b/AlphaFS/Device/Native Other/PARTITION_INFORMATION_EX.cs
new file mode 100644
index 000000000..d3014ef77
--- /dev/null
+++ b/AlphaFS/Device/Native Other/PARTITION_INFORMATION_EX.cs
@@ -0,0 +1,61 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains partition information for standard AT-style master boot record (MBR) and Extensible Firmware Interface (EFI) disks.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
+ internal struct PARTITION_INFORMATION_EX
+ {
+ /// The format of the partition. For a list of values, see .
+ [FieldOffset(0)] public readonly PARTITION_STYLE PartitionStyle;
+
+ /// The starting offset of the partition.
+ [FieldOffset(8)] [MarshalAs(UnmanagedType.U8)]
+ public readonly ulong StartingOffset;
+
+ /// The starting offset of the partition.
+ [FieldOffset(16)] [MarshalAs(UnmanagedType.U8)]
+ public readonly ulong PartitionLength;
+
+ /// The number of the partition (1-based).
+ [FieldOffset(24)] [MarshalAs(UnmanagedType.U4)]
+ public readonly uint PartitionNumber;
+
+ /// If this member is TRUE, the partition is rewritable. The value of this parameter should be set to TRUE.
+ [FieldOffset(28)] [MarshalAs(UnmanagedType.U1)]
+ public readonly bool RewritePartition;
+
+ /// A structure that specifies partition information specific to master boot record (MBR) disks. The MBR partition format is the standard AT-style format.
+ [FieldOffset(32)] public readonly PARTITION_INFORMATION_MBR Mbr;
+
+ /// A structure that specifies partition information specific to GUID partition table (GPT) disks. The GPT format corresponds to the EFI partition format.
+ [FieldOffset(32)] public readonly PARTITION_INFORMATION_GPT Gpt;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/PARTITION_INFORMATION_GPT.cs b/AlphaFS/Device/Native Other/PARTITION_INFORMATION_GPT.cs
new file mode 100644
index 000000000..657c3f608
--- /dev/null
+++ b/AlphaFS/Device/Native Other/PARTITION_INFORMATION_GPT.cs
@@ -0,0 +1,54 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains GUID partition table (GPT) partition information.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
+ internal struct PARTITION_INFORMATION_GPT
+ {
+ /// A GUID that identifies the partition type.
+ /// Each partition type that the EFI specification supports is identified by its own GUID, which is published by the developer of the partition.
+ ///
+ [FieldOffset(0)] public readonly Guid PartitionType;
+
+ /// The GUID of the partition.
+ [FieldOffset(16)] public readonly Guid PartitionId;
+
+ /// The Extensible Firmware Interface (EFI) attributes of the partition.
+ [FieldOffset(32)] [MarshalAs(UnmanagedType.U8)]
+ public readonly EfiPartitionAttributes Attributes;
+
+ /// A wide-character string that describes the partition.
+ [FieldOffset(40)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 36)]
+ public readonly string Name;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/PARTITION_INFORMATION_MBR.cs b/AlphaFS/Device/Native Other/PARTITION_INFORMATION_MBR.cs
new file mode 100644
index 000000000..dc4af9c4d
--- /dev/null
+++ b/AlphaFS/Device/Native Other/PARTITION_INFORMATION_MBR.cs
@@ -0,0 +1,48 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains partition information specific to master boot record (MBR) disks.
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct PARTITION_INFORMATION_MBR
+ {
+ /// The type of partition. For a list of values, see .
+ [MarshalAs(UnmanagedType.U1)] public readonly DiskPartitionType PartitionType;
+
+ /// If the member is TRUE, the partition is a boot partition. When this structure is used with the IOCTL_DISK_SET_PARTITION_INFO_EX control code, the value of this parameter is ignored.
+ [MarshalAs(UnmanagedType.Bool)] public readonly bool BootIndicator;
+
+ /// If this member is TRUE, the partition is of a recognized type. When this structure is used with the IOCTL_DISK_SET_PARTITION_INFO_EX control code, the value of this parameter is ignored.
+ [MarshalAs(UnmanagedType.Bool)] public readonly bool RecognizedPartition;
+
+ /// The number of hidden sectors to be allocated when the partition table is created.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint HiddenSectors;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/PARTITION_STYLE.cs b/AlphaFS/Device/Native Other/PARTITION_STYLE.cs
new file mode 100644
index 000000000..e16b1fbda
--- /dev/null
+++ b/AlphaFS/Device/Native Other/PARTITION_STYLE.cs
@@ -0,0 +1,43 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Represents the format of a partition.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ internal enum PARTITION_STYLE
+ {
+ /// Master boot record (MBR) format. This corresponds to standard AT-style MBR partitions.
+ PARTITION_STYLE_MBR = 0,
+
+ /// GUID Partition Table (GPT) format.
+ PARTITION_STYLE_GPT = 1,
+
+ /// Partition not formatted in either of the recognized formats; MBR or GPT.
+ PARTITION_STYLE_RAW = 2
+ }
+ }
+}
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/SetupDiGetDeviceRegistryPropertyEnum.cs b/AlphaFS/Device/Native Other/SPDRP.cs
similarity index 92%
rename from AlphaFS/Filesystem/Structures, Enumerations/SetupDiGetDeviceRegistryPropertyEnum.cs
rename to AlphaFS/Device/Native Other/SPDRP.cs
index 660891265..b8982fe98 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/SetupDiGetDeviceRegistryPropertyEnum.cs
+++ b/AlphaFS/Device/Native Other/SPDRP.cs
@@ -19,12 +19,14 @@
* THE SOFTWARE.
*/
-namespace Alphaleonis.Win32.Filesystem
+using System;
+
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
/// Flags for SetupDiGetDeviceRegistryProperty().
- internal enum SetupDiGetDeviceRegistryPropertyEnum
+ internal enum SPDRP
{
/// SPDRP_DEVICEDESC
/// Represents a description of a device instance.
@@ -57,7 +59,7 @@ internal enum SetupDiGetDeviceRegistryPropertyEnum
Class = 7,
/// SPDRP_CLASSGUID
- /// Represents the of the device setup class that a device instance belongs to.
+ /// Represents the of the device setup class that a device instance belongs to.
///
ClassGuid = 8,
@@ -91,9 +93,7 @@ internal enum SetupDiGetDeviceRegistryPropertyEnum
///
PhysicalDeviceObjectName = 14,
- ///// SPDRP_CAPABILITIES
- //// Represents the capabilities of a device instance.
- ////
+ ///// SPDRP_CAPABILITIES - Represents the capabilities of a device instance.
//Capabilities = 15,
///// SPDRP_UI_NUMBER - Represents a number for the device instance that can be displayed in a user interface item.
@@ -161,9 +161,9 @@ internal enum SetupDiGetDeviceRegistryPropertyEnum
LocationPaths = 35,
/// SPDRP_BASE_CONTAINERID
- /// Represents the value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode).
+ /// Represents the value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode).
///
BaseContainerId = 36
}
}
-}
\ No newline at end of file
+}
diff --git a/AlphaFS/Filesystem/Native Other/SP_DEVICE_INTERFACE_DATA.cs b/AlphaFS/Device/Native Other/SP_DEVICE_INTERFACE_DATA.cs
similarity index 98%
rename from AlphaFS/Filesystem/Native Other/SP_DEVICE_INTERFACE_DATA.cs
rename to AlphaFS/Device/Native Other/SP_DEVICE_INTERFACE_DATA.cs
index 94ecb6881..d6a3392d5 100644
--- a/AlphaFS/Filesystem/Native Other/SP_DEVICE_INTERFACE_DATA.cs
+++ b/AlphaFS/Device/Native Other/SP_DEVICE_INTERFACE_DATA.cs
@@ -22,7 +22,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
diff --git a/AlphaFS/Filesystem/Native Other/SP_DEVICE_INTERFACE_DETAIL_DATA.cs b/AlphaFS/Device/Native Other/SP_DEVICE_INTERFACE_DETAIL_DATA.cs
similarity index 91%
rename from AlphaFS/Filesystem/Native Other/SP_DEVICE_INTERFACE_DETAIL_DATA.cs
rename to AlphaFS/Device/Native Other/SP_DEVICE_INTERFACE_DETAIL_DATA.cs
index c44f25192..bc87ad94c 100644
--- a/AlphaFS/Filesystem/Native Other/SP_DEVICE_INTERFACE_DETAIL_DATA.cs
+++ b/AlphaFS/Device/Native Other/SP_DEVICE_INTERFACE_DETAIL_DATA.cs
@@ -21,7 +21,7 @@
using System.Runtime.InteropServices;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
@@ -33,7 +33,7 @@ internal struct SP_DEVICE_INTERFACE_DETAIL_DATA
[MarshalAs(UnmanagedType.U4)] public uint cbSize;
/// The device interface path. This path can be passed to Win32 functions such as CreateFile.
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)] public readonly string DevicePath;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = Filesystem.NativeMethods.MaxPath)] public readonly string DevicePath;
}
}
}
\ No newline at end of file
diff --git a/AlphaFS/Filesystem/Native Other/SP_DEVINFO_DATA.cs b/AlphaFS/Device/Native Other/SP_DEVINFO_DATA.cs
similarity index 98%
rename from AlphaFS/Filesystem/Native Other/SP_DEVINFO_DATA.cs
rename to AlphaFS/Device/Native Other/SP_DEVINFO_DATA.cs
index 480ed6597..96d1abfe2 100644
--- a/AlphaFS/Filesystem/Native Other/SP_DEVINFO_DATA.cs
+++ b/AlphaFS/Device/Native Other/SP_DEVINFO_DATA.cs
@@ -22,7 +22,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
diff --git a/AlphaFS/Device/Native Other/STORAGE_ADAPTER_DESCRIPTOR.cs b/AlphaFS/Device/Native Other/STORAGE_ADAPTER_DESCRIPTOR.cs
new file mode 100644
index 000000000..ad6dbc3d9
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_ADAPTER_DESCRIPTOR.cs
@@ -0,0 +1,105 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Used with the control code to retrieve the storage adapter descriptor data for a device.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct STORAGE_ADAPTER_DESCRIPTOR
+ {
+ /// Contains the size of this structure, in bytes. The value of this member will change as members are added to the structure.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint Version;
+
+ /// Specifies the total size of the data returned, in bytes. This may include data that follows this structure.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint Size;
+
+ /// Specifies the maximum number of bytes the storage adapter can transfer in a single operation.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint MaximumTransferLength;
+
+ /// Specifies the maximum number of discontinuous physical pages the storage adapter can manage in a single transfer (in other words, the extent of its scatter/gather support).
+ [MarshalAs(UnmanagedType.U4)] public readonly uint MaximumPhysicalPages;
+
+ /// Specifies the storage adapter's alignment requirements for transfers.
+ /// The alignment mask indicates alignment restrictions for buffers required by the storage adapter for transfer operations. Valid mask values are also restricted by characteristics of the memory managers on different versions of Windows.
+ ///
+ /// 0 - Buffers must be aligned on BYTE boundaries.
+ /// 1 - Buffers must be aligned on WORD boundaries.
+ /// 3 - Buffers must be aligned on DWORD32 boundaries.
+ /// 7 - Buffers must be aligned on DWORD64 boundaries.
+ ///
+ [MarshalAs(UnmanagedType.U4)] public readonly uint AlignmentMask;
+
+ /// If this member is TRUE, the storage adapter uses programmed I/O (PIO) and requires the use of system-space virtual addresses mapped to physical memory for data buffers. When this member is FALSE, the storage adapter does not use PIO.
+ [MarshalAs(UnmanagedType.U1)] public readonly bool AdapterUsesPio;
+
+ /// If this member is TRUE, the storage adapter scans down for BIOS devices, that is, the storage adapter begins scanning with the highest device number rather than the lowest. When this member is FALSE, the storage adapter begins scanning with the lowest device number.
+ /// This member is reserved for legacy miniport drivers.
+ [MarshalAs(UnmanagedType.U1)] public readonly bool AdapterScansDown;
+
+ /// If this member is TRUE, the storage adapter supports SCSI tagged queuing and/or per-logical-unit internal queues, or the non-SCSI equivalent. When this member is FALSE, the storage adapter neither supports SCSI-tagged queuing nor per-logical-unit internal queues.
+ [MarshalAs(UnmanagedType.U1)] public readonly bool CommandQueueing;
+
+ /// If this member is TRUE, the storage adapter supports synchronous transfers as a way of speeding up I/O. When this member is FALSE, the storage adapter does not support synchronous transfers as a way of speeding up I/O.
+ [MarshalAs(UnmanagedType.U1)] public readonly bool AcceleratedTransfer;
+
+ /// Specifies a value of type STORAGE_BUS_TYPE that indicates the type of the bus to which the device is connected.
+ [MarshalAs(UnmanagedType.U1)] private readonly byte busType;
+
+ /// Specifies the major version number, if any, of the storage adapter.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort BusMajorVersion;
+
+ /// Specifies the minor version number, if any, of the storage adapter.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort BusMinorVersion;
+
+ /// Specifies the SCSI request block (SRB) type used by the HBA.
+ /// SRB_TYPE_SCSI_REQUEST_BLOCK: The HBA uses SCSI request blocks.
+ /// SRB_TYPE_STORAGE_REQUEST_BLOCK: The HBA uses extended SCSI request blocks.
+ ///
+ [MarshalAs(UnmanagedType.U1)] private readonly byte SrbType;
+
+ /// Specifies the address type of the HBA.
+ /// STORAGE_ADDRESS_TYPE_BTL8: The HBA uses 8-bit bus, target, and LUN addressing.
+ ///
+ [MarshalAs(UnmanagedType.U1)] private readonly byte AddressType;
+
+ /// Specifies the version number, if any, of the storage adapter.
+ public Version BusVersion
+ {
+ get { return new Version(BusMajorVersion, BusMinorVersion); }
+ }
+
+ /// Specifies a value of type STORAGE_BUS_TYPE that indicates the type of the bus to which the device is connected.
+ public STORAGE_BUS_TYPE BusType
+ {
+ get { return (STORAGE_BUS_TYPE) busType; }
+ }
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/STORAGE_BUS_TYPE.cs b/AlphaFS/Device/Native Other/STORAGE_BUS_TYPE.cs
new file mode 100644
index 000000000..56c5c9f6c
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_BUS_TYPE.cs
@@ -0,0 +1,95 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Provides a symbolic means of representing storage bus types.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ internal enum STORAGE_BUS_TYPE
+ {
+ /// Indicates an unknown bus type.
+ BusTypeUnknown = 0,
+
+ /// Indicates a SCSI bus type.
+ BusTypeScsi = 1,
+
+ /// Indicates an ATAPI bus type.
+ BusTypeAtapi = 2,
+
+ /// Indicates an ATA bus type.
+ BusTypeAta = 3,
+
+ /// Indicates an IEEE 1394 bus type.
+ BusType1394 = 4,
+
+ /// Indicates an SSA bus type.
+ BusTypeSsa = 5,
+
+ /// Indicates a fiber channel bus type.
+ BusTypeFibre = 6,
+
+ /// Indicates a USB bus type.
+ BusTypeUsb = 7,
+
+ /// Indicates a RAID bus type.
+ BusTypeRAID = 8,
+
+ /// Indicates an iSCSI bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeiScsi = 9,
+
+ /// Indicates a serial-attached SCSI (SAS) bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeSas = 10,
+
+ /// Indicates a SATA bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeSata = 11,
+
+ /// Indicates a secure digital (SD) bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeSd = 12,
+
+ /// Indicates a multimedia card (MMC) bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeMmc = 13,
+
+ /// Indicates a virtual bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeVirtual = 14,
+
+ /// Indicates a file-backed virtual bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ BusTypeFileBackedVirtual = 15,
+
+ /// Indicates the maximum value for this value.
+ BusTypeMax = 16,
+
+ /// The maximum value of the storage bus type range.
+ BusTypeMaxReserved = 127
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/STORAGE_DEVICE_DESCRIPTOR.cs b/AlphaFS/Device/Native Other/STORAGE_DEVICE_DESCRIPTOR.cs
new file mode 100644
index 000000000..c01f317f2
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_DEVICE_DESCRIPTOR.cs
@@ -0,0 +1,76 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Used in conjunction with the IOCTL_STORAGE_QUERY_PROPERTY control code to retrieve the storage device descriptor data for a device.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct STORAGE_DEVICE_DESCRIPTOR
+ {
+ /// Contains the size of this structure, in bytes. The value of this member will change as members are added to the structure.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint Version;
+
+ /// Specifies the total size of the descriptor, in bytes, which may include vendor ID, product ID, product revision, device serial number strings and bus-specific data which are appended to the structure.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint Size;
+
+ /// Specifies the device type as defined by the Small Computer Systems Interface (SCSI) specification.
+ [MarshalAs(UnmanagedType.I1)] public readonly byte DeviceType;
+
+ /// Specifies the device type modifier, if any, as defined by the SCSI specification. If no device type modifier exists, this member is zero.
+ [MarshalAs(UnmanagedType.I1)] public readonly byte DeviceTypeModifier;
+
+ /// Indicates when TRUE that the device's media (if any) is removable. If the device has no media, this member should be ignored. When FALSE the device's media is not removable.
+ [MarshalAs(UnmanagedType.I1)] public readonly bool RemovableMedia;
+
+ /// Indicates when TRUE that the device supports multiple outstanding commands (SCSI tagged queuing or equivalent). When FALSE, the device does not support SCSI-tagged queuing or the equivalent.
+ [MarshalAs(UnmanagedType.I1)] public readonly bool CommandQueueing;
+
+ /// Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's vendor ID. If the device has no vendor ID, this member is zero.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint VendorIdOffset;
+
+ /// Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's product ID. If the device has no product ID, this member is zero.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint ProductIdOffset;
+
+ /// Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's product revision string. If the device has no product revision string, this member is zero.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint ProductRevisionOffset;
+
+ /// Specifies the byte offset from the beginning of the structure to a null-terminated ASCII string that contains the device's serial number. If the device has no serial number, this member is zero.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint SerialNumberOffset;
+
+ /// Specifies an enumerator value of type STORAGE_BUS_TYPE that indicates the type of bus to which the device is connected. This should be used to interpret the raw device properties at the end of this structure (if any).
+ [MarshalAs(UnmanagedType.U4)] public readonly STORAGE_BUS_TYPE BusType;
+
+ /// Indicates the number of bytes of bus-specific data that have been appended to this descriptor.
+ [MarshalAs(UnmanagedType.U4)] public readonly uint RawPropertiesLength;
+
+ /// Contains an array of length one that serves as a place holder for the first byte of the bus specific property data.
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] public readonly byte[] RawDeviceProperties;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/STORAGE_DEVICE_NUMBER.cs b/AlphaFS/Device/Native Other/STORAGE_DEVICE_NUMBER.cs
new file mode 100644
index 000000000..0a4b59065
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_DEVICE_NUMBER.cs
@@ -0,0 +1,48 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Contains information about a device. This structure is used by the IOCTL_STORAGE_GET_DEVICE_NUMBER control code.
+ ///
+ /// Minimum supported client: Windows XP
+ /// Minimum supported server: Windows Server 2003
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct STORAGE_DEVICE_NUMBER
+ {
+ /// Specifies one of the system-defined XXX constants indicating the type of device (such as DISK, KEYBOARD, and so forth) or a vendor-defined value for a new type of device.
+ [MarshalAs(UnmanagedType.U4)] internal readonly FILE_DEVICE DeviceType;
+
+ /// Indicates the number of this device. This value is set to 0xFFFFFFFF (-1) for the disks that represent the physical paths of an MPIO disk.
+ [MarshalAs(UnmanagedType.U4)]
+ internal readonly int DeviceNumber; // 2018-02-28: On MSDN this is defined as ULONG.
+
+ /// Indicates the partition number of the device is returned in this member, if the device can be partitioned. Otherwise, -1 is returned.
+ [MarshalAs(UnmanagedType.U4)]
+ internal readonly int PartitionNumber; // 2018-02-28: On MSDN this is defined as ULONG.
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/STORAGE_PROPERTY_ID.cs b/AlphaFS/Device/Native Other/STORAGE_PROPERTY_ID.cs
new file mode 100644
index 000000000..71224b85f
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_PROPERTY_ID.cs
@@ -0,0 +1,109 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Enumerates the possible values of the PropertyId member of the structure passed as input to the IOCTL_STORAGE_QUERY_PROPERTY request to retrieve the properties of a storage device or adapter.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ public enum STORAGE_PROPERTY_ID
+ {
+ /// Indicates that the caller is querying for the device descriptor, .
+ StorageDeviceProperty = 0,
+
+ /// Indicates that the caller is querying for the adapter descriptor, .
+ StorageAdapterProperty
+
+ ///// Indicates that the caller is querying for the device identifiers provided with the SCSI vital product data pages. Data is returned using the STORAGE_DEVICE_ID_DESCRIPTOR structure.
+ //StorageDeviceIdProperty,
+
+ ///// Indicates that the caller is querying for the unique device identifiers. Data is returned using the STORAGE_DEVICE_UNIQUE_IDENTIFIER structure.
+ //StorageDeviceUniqueIdProperty,
+
+ ///// Indicates that the caller is querying for the write cache property. Data is returned using the STORAGE_WRITE_CACHE_PROPERTY structure.
+ //StorageDeviceWriteCacheProperty,
+
+ ///// Reserved for system use.
+ //StorageMiniportProperty,
+
+ ///// Indicates that the caller is querying for the access alignment descriptor, STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR.
+ //StorageAccessAlignmentProperty,
+
+ ///// Indicates that the caller is querying for the seek penalty descriptor, DEVICE_SEEK_PENALTY_DESCRIPTOR.
+ //StorageDeviceSeekPenaltyProperty,
+
+ ///// Indicates that the caller is querying for the trim descriptor, DEVICE_TRIM_DESCRIPTOR.
+ //StorageDeviceTrimProperty,
+
+ ///// Reserved for system use.
+ //StorageDeviceWriteAggregationProperty,
+
+ ///// Reserved for system use.
+ //StorageDeviceDeviceTelemetryProperty,
+
+ ///// Indicates that the caller is querying for the logical block provisioning property. Data is returned using the DEVICE_LB_PROVISIONING_DESCRIPTOR structure.
+ //StorageDeviceLBProvisioningProperty,
+
+ ///// Indicates that the caller is querying for the device power descriptor. Data is returned using the DEVICE_POWER_DESCRIPTOR structure.
+ //StorageDevicePowerProperty,
+
+ ///// Indicates that the caller is querying for the copy offload parameters property. Data is returned using the DEVICE_COPY_OFFLOAD_DESCRIPTOR structure.
+ //StorageDeviceCopyOffloadProperty,
+
+ ///// Reserved for system use.
+ //StorageDeviceResiliencyProperty,
+
+ ///// Indicates that the caller is querying for the medium product type. Data is returned using the STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR structure.
+ //StorageDeviceMediumProductType,
+
+ ///// Reserved for system use.
+ //StorageAdapterCryptoProperty,
+
+ ///// Indicates that the caller is querying for the device I/O capability property. Data is returned using the DEVICE_IO_CAPABILITY_DESCRIPTOR structure.
+ //StorageDeviceIoCapabilityProperty = 48,
+
+ ///// Indicates that the caller is querying for protocol-specific data from the adapter. Data is returned using the STORAGE_PROTOCOL_DATA_DESCRIPTOR structure. See the remarks for more info.
+ //StorageAdapterProtocolSpecificProperty,
+
+ ///// Indicates that the caller is querying for protocol-specific data from the device. Data is returned using the STORAGE_PROTOCOL_DATA_DESCRIPTOR structure. See the remarks for more info.
+ //StorageDeviceProtocolSpecificProperty,
+
+ ///// Indicates that the caller is querying temperature data from the adapter. Data is returned using the STORAGE_TEMPERATURE_DATA_DESCRIPTOR structure.
+ //StorageAdapterTemperatureProperty,
+
+ ///// Indicates that the caller is querying for temperature data from the device. Data is returned using the STORAGE_TEMPERATURE_DATA_DESCRIPTOR structure.
+ //StorageDeviceTemperatureProperty,
+
+ ///// Indicates that the caller is querying for topology information from the adapter. Data is returned using the STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR structure.
+ //StorageAdapterPhysicalTopologyProperty,
+
+ ///// Indicates that the caller is querying for topology information from the device. Data is returned using the STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR structure.
+ //StorageDevicePhysicalTopologyProperty,
+
+ ///// Indicates that the caller is querying for attributes information from the device. Data is returned using the STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR structure.
+ //StorageDeviceAttributesProperty
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/STORAGE_PROPERTY_QUERY.cs b/AlphaFS/Device/Native Other/STORAGE_PROPERTY_QUERY.cs
new file mode 100644
index 000000000..578e6a495
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_PROPERTY_QUERY.cs
@@ -0,0 +1,52 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Indicates the properties of a storage device or adapter to retrieve as the input buffer passed to the IOCTL_STORAGE_QUERY_PROPERTY control code.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ public struct STORAGE_PROPERTY_QUERY
+ {
+ /// Indicates whether the caller is requesting a device descriptor, an adapter descriptor, a write cache property, a device unique ID (DUID),
+ /// or the device identifiers provided in the device's SCSI vital product data (VPD) page. For a list of the property IDs that can be assigned to this member, see STORAGE_PROPERTY_ID.
+ ///
+ [MarshalAs(UnmanagedType.U4)] public STORAGE_PROPERTY_ID PropertyId;
+
+ /// Contains flags indicating the type of query to be performed as enumerated by the STORAGE_QUERY_TYPE enumeration.
+ /// PropertyStandardQuery = 0: Instructs the port driver to report a device descriptor, an adapter descriptor or a unique hardware device ID(DUID).
+ /// PropertyExistsQuery = 1: Instructs the port driver to report whether the descriptor is supported.
+ ///
+ [MarshalAs(UnmanagedType.U4)] public STORAGE_QUERY_TYPE QueryType;
+
+ /// Contains an array of bytes that can be used to retrieve additional parameters for specific queries.
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
+ public byte[] AdditionalParameters;
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/STORAGE_QUERY_TYPE.cs b/AlphaFS/Device/Native Other/STORAGE_QUERY_TYPE.cs
new file mode 100644
index 000000000..69323a3c3
--- /dev/null
+++ b/AlphaFS/Device/Native Other/STORAGE_QUERY_TYPE.cs
@@ -0,0 +1,46 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Used by the structure passed to the IOCTL_STORAGE_QUERY_PROPERTY control code to indicate what information is returned about a property of a storage device or adapter.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ public enum STORAGE_QUERY_TYPE
+ {
+ /// Instructs the driver to return an appropriate descriptor.
+ PropertyStandardQuery = 0
+
+ ///// Instructs the driver to report whether the descriptor is supported.
+ //PropertyExistsQuery = 1,
+
+ ///// Not currently supported. Do not use.
+ //PropertyMaskQuery = 2,
+
+ ///// Specifies the upper limit of the list of query types. This is used to validate the query type.
+ //PropertyQueryMaxDefined = 3
+ }
+ }
+}
diff --git a/AlphaFS/Device/Native Other/VOLUME_DISK_EXTENTS.cs b/AlphaFS/Device/Native Other/VOLUME_DISK_EXTENTS.cs
new file mode 100644
index 000000000..66dbab8e0
--- /dev/null
+++ b/AlphaFS/Device/Native Other/VOLUME_DISK_EXTENTS.cs
@@ -0,0 +1,39 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Runtime.InteropServices;
+
+namespace Alphaleonis.Win32.Device
+{
+ internal static partial class NativeMethods
+ {
+ /// Represents a physical location on a disk. It is the output buffer for the control code.
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct VOLUME_DISK_EXTENTS
+ {
+ /// The number of disks in the volume (a volume can span multiple disks).
+ [MarshalAs(UnmanagedType.U4)] public uint NumberOfDiskExtents;
+
+ /// An array of structures.
+ [MarshalAs(UnmanagedType.ByValArray)] public DISK_EXTENT[] Extents;
+ }
+ }
+}
diff --git a/AlphaFS/Filesystem/Native Other/VOLUME_INFO_FLAGS.cs b/AlphaFS/Device/Native Other/VOLUME_INFO_FLAGS.cs
similarity index 99%
rename from AlphaFS/Filesystem/Native Other/VOLUME_INFO_FLAGS.cs
rename to AlphaFS/Device/Native Other/VOLUME_INFO_FLAGS.cs
index 9a4037614..5e39fcb0c 100644
--- a/AlphaFS/Filesystem/Native Other/VOLUME_INFO_FLAGS.cs
+++ b/AlphaFS/Device/Native Other/VOLUME_INFO_FLAGS.cs
@@ -21,7 +21,7 @@
using System;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
internal static partial class NativeMethods
{
diff --git a/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.ContainsVolume.cs b/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.ContainsVolume.cs
new file mode 100644
index 000000000..c14aac908
--- /dev/null
+++ b/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.ContainsVolume.cs
@@ -0,0 +1,63 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Linq;
+using Alphaleonis.Win32.Filesystem;
+
+namespace Alphaleonis.Win32.Device
+{
+ public sealed partial class PhysicalDiskInfo
+ {
+ /// Checks if the volume/logical drive is located on the physical disk.
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ ///
+ /// true if the volume/logical drive is located on the physical disk; otherwise, false.
+ ///
+ /// A disk path such as: \\.\PhysicalDrive0
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// A string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ public bool ContainsVolume(string devicePath)
+ {
+ bool isDrive;
+ bool isVolume;
+ bool isDeviceInfo;
+
+ devicePath = FilesystemHelper.GetValidatedDevicePath(devicePath, out isDrive, out isVolume, out isDeviceInfo);
+
+
+ if (isDrive && null != LogicalDrives)
+ {
+ devicePath = devicePath.Replace(Path.LogicalDrivePrefix, string.Empty);
+
+ devicePath = Path.RemoveTrailingDirectorySeparator(devicePath, false);
+
+ return LogicalDrives.Any(driveName => driveName.Equals(devicePath, StringComparison.OrdinalIgnoreCase));
+ }
+
+
+ return isVolume && null != VolumeGuids && VolumeGuids.Any(guid => guid.Equals(devicePath, StringComparison.OrdinalIgnoreCase));
+ }
+ }
+}
diff --git a/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.CreatePhysicalDiskInfoInstance.cs b/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.CreatePhysicalDiskInfoInstance.cs
new file mode 100644
index 000000000..722e322a9
--- /dev/null
+++ b/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.CreatePhysicalDiskInfoInstance.cs
@@ -0,0 +1,252 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Security;
+using System.Security.AccessControl;
+using Alphaleonis.Win32.Filesystem;
+using Alphaleonis.Win32.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ public sealed partial class PhysicalDiskInfo
+ {
+ [SecurityCritical]
+ private void CreatePhysicalDiskInfoInstance(int deviceNumber, string devicePath, StorageDeviceInfo storageDeviceInfo, DeviceInfo deviceInfo)
+ {
+ var isElevated = ProcessContext.IsElevatedProcess;
+ var getByDeviceNumber = deviceNumber > -1;
+ string physicalDriveNumberPath = null;
+
+ bool isDrive;
+ bool isVolume;
+ bool isDevice;
+
+ if (null != deviceInfo)
+ devicePath = deviceInfo.DevicePath;
+
+ var localDevicePath = FilesystemHelper.GetValidatedDevicePath(getByDeviceNumber ? Path.PhysicalDrivePrefix + deviceNumber.ToString(CultureInfo.InvariantCulture) : devicePath, out isDrive, out isVolume, out isDevice);
+
+ localDevicePath = FilesystemHelper.GetLocalDevicePath(localDevicePath);
+
+
+ // The StorageDeviceInfo is always needed as it contains the device- and partition number.
+
+ StorageDeviceInfo = storageDeviceInfo ?? Local.GetStorageDeviceInfo(isElevated, isDevice, deviceNumber, localDevicePath, out physicalDriveNumberPath);
+
+ if (null == StorageDeviceInfo)
+ return;
+
+ deviceNumber = getByDeviceNumber ? deviceNumber : StorageDeviceInfo.DeviceNumber;
+
+ if (!SetDeviceInfoDataFromDeviceNumber(isElevated, deviceNumber, deviceInfo))
+ return;
+
+
+ // If physicalDriveNumberPath != null, the drive is opened using: "\\.\PhysicalDriveX" path format
+ // which is the device, not the volume/logical drive.
+
+ localDevicePath = FilesystemHelper.GetValidatedDevicePath(physicalDriveNumberPath ?? localDevicePath, out isDrive, out isVolume, out isDevice);
+
+
+ AddDeviceInfoData(isElevated, isDevice, deviceNumber, localDevicePath);
+ }
+
+
+ private void AddDeviceInfoData(bool isElevated, bool isDevice, int deviceNumber, string localDevicePath)
+ {
+ DosDeviceName = Volume.QueryDosDevice(Path.GetRegularPathCore(localDevicePath, GetFullPathOptions.None, false));
+
+
+ using (var safeFileHandle = Local.OpenDevice(localDevicePath, isElevated ? FileSystemRights.Read : NativeMethods.FILE_ANY_ACCESS))
+ {
+ StorageAdapterInfo = Local.GetStorageAdapterInfo(safeFileHandle, deviceNumber, localDevicePath, DeviceInfo.BusReportedDeviceDescription);
+
+ StoragePartitionInfo = Local.GetStoragePartitionInfo(safeFileHandle, deviceNumber, localDevicePath);
+ }
+
+
+ UpdateDevicePartitionData(isElevated, isDevice, localDevicePath);
+
+ PopulatePhysicalDisk(isElevated);
+ }
+
+
+ /// Retrieves volumes/logical drives that belong to the PhysicalDiskInfo instance.
+ [SecurityCritical]
+ private void PopulatePhysicalDisk(bool isElevated)
+ {
+ var deviceNumber = StorageDeviceInfo.DeviceNumber;
+
+ _partitionIndexCollection = new Collection();
+ _volumeGuidCollection = new Collection();
+ _logicalDriveCollection = new Collection();
+
+
+ foreach (var volumeGuid in Volume.EnumerateVolumes())
+ {
+ string unusedLocalDevicePath;
+
+ // The StorageDeviceInfo is always needed as it contains the device- and partition number.
+
+ var storageDeviceInfo = Local.GetStorageDeviceInfo(isElevated, false, deviceNumber, volumeGuid, out unusedLocalDevicePath);
+
+ if (null == storageDeviceInfo)
+ continue;
+
+
+ _partitionIndexCollection.Add(storageDeviceInfo.PartitionNumber);
+
+ _volumeGuidCollection.Add(volumeGuid);
+
+
+ // Resolve logical drive from volume matching DeviceNumber and PartitionNumber.
+
+ var driveName = Volume.GetVolumeDisplayName(volumeGuid);
+
+ if (!Utils.IsNullOrWhiteSpace(driveName))
+
+ _logicalDriveCollection.Add(Path.RemoveTrailingDirectorySeparator(driveName));
+ }
+
+
+ PartitionIndexes = _partitionIndexCollection;
+
+ VolumeGuids = _volumeGuidCollection;
+
+ LogicalDrives = _logicalDriveCollection;
+ }
+
+
+ [SecurityCritical]
+ private bool SetDeviceInfoDataFromDeviceNumber(bool isElevated, int deviceNumber, DeviceInfo deviceInfo)
+ {
+ if (null == deviceInfo)
+ foreach (var device in Local.EnumerateDevicesCore(null, new[] {DeviceGuid.Disk, DeviceGuid.CDRom}, false))
+ {
+ string unusedDevicePath;
+
+ var storageDeviceInfo = Local.GetStorageDeviceInfo(isElevated, true, deviceNumber, device.DevicePath, out unusedDevicePath);
+
+ if (null != storageDeviceInfo)
+ {
+ deviceInfo = device;
+ break;
+ }
+ }
+
+
+ DeviceInfo = deviceInfo;
+
+ return null != deviceInfo && !Utils.IsNullOrWhiteSpace(deviceInfo.DevicePath);
+ }
+
+
+ [SecurityCritical]
+ private void UpdateDevicePartitionData(bool isElevated, bool isDevice, string localDevicePath)
+ {
+ if (StoragePartitionInfo.OnDynamicDisk)
+ {
+ // At this point, PartitionNumber = 0 which points to the device.
+ // Get the user data partition; the partition that normally occupies most of the disk space.
+
+ foreach (var partition in StoragePartitionInfo.GptPartitionInfo)
+ {
+ if (partition.PartitionType == PartitionType.LdmData)
+ {
+ StorageDeviceInfo.PartitionNumber = partition.PartitionNumber;
+
+ StorageDeviceInfo.TotalSize = partition.PartitionLength;
+
+ break;
+ }
+ }
+ }
+
+ else if (!isElevated && StorageDeviceInfo.TotalSize == 0 && null != StoragePartitionInfo)
+
+ StorageDeviceInfo.TotalSize = isDevice ? StoragePartitionInfo.TotalSize : new DiskSpaceInfo(localDevicePath, false, true, true).TotalNumberOfBytes;
+ }
+
+
+
+
+ /// Returns the "FriendlyName" of the physical disk.
+ /// Returns a string that represents this instance.
+ public override string ToString()
+ {
+ return Name ?? DevicePath;
+ }
+
+
+ /// Determines whether the specified Object is equal to the current Object.
+ /// Another object to compare to.
+ /// true if the specified Object is equal to the current Object; otherwise, false.
+ public override bool Equals(object obj)
+ {
+ if (null == obj || GetType() != obj.GetType())
+ return false;
+
+ var other = obj as PhysicalDiskInfo;
+
+ return null != other &&
+ other.Name == Name &&
+ other.DevicePath == DevicePath &&
+ other.DosDeviceName == DosDeviceName &&
+ other.PhysicalDeviceObjectName == PhysicalDeviceObjectName &&
+ other.PartitionIndexes == PartitionIndexes &&
+ other.VolumeGuids == VolumeGuids &&
+ other.LogicalDrives == LogicalDrives &&
+ other.StorageAdapterInfo == StorageAdapterInfo &&
+ other.StorageDeviceInfo == StorageDeviceInfo &&
+ other.StoragePartitionInfo == StoragePartitionInfo;
+ }
+
+
+ /// Serves as a hash function for a particular type.
+ /// Returns a hash code for the current Object.
+ public override int GetHashCode()
+ {
+ return null != DevicePath ? DevicePath.GetHashCode() : 0;
+ }
+
+
+ /// Implements the operator ==
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator ==(PhysicalDiskInfo left, PhysicalDiskInfo right)
+ {
+ return ReferenceEquals(left, null) && ReferenceEquals(right, null) || !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right);
+ }
+
+
+ /// Implements the operator !=
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator !=(PhysicalDiskInfo left, PhysicalDiskInfo right)
+ {
+ return !(left == right);
+ }
+ }
+}
diff --git a/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.cs b/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.cs
new file mode 100644
index 000000000..0f66d1721
--- /dev/null
+++ b/AlphaFS/Device/PhysicalDisk Class/PhysicalDiskInfo.cs
@@ -0,0 +1,159 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Security;
+using Alphaleonis.Win32.Filesystem;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides access to information of a physical disk on the Computer.
+ [Serializable]
+ [SecurityCritical]
+ public sealed partial class PhysicalDiskInfo
+ {
+ #region Fields
+
+ private Collection _partitionIndexCollection;
+ private Collection _volumeGuidCollection;
+ private Collection _logicalDriveCollection;
+
+ #endregion // Fields
+
+
+ #region Constructors
+
+ private PhysicalDiskInfo()
+ {
+ }
+
+
+ /// [AlphaFS] Initializes an instance from a physical disk device number.
+ /// A device number that indicates a physical disk on the Computer.
+ public PhysicalDiskInfo(int deviceNumber)
+ {
+ if (deviceNumber < 0)
+ throw new ArgumentOutOfRangeException("deviceNumber");
+
+ CreatePhysicalDiskInfoInstance(deviceNumber, null, null, null);
+ }
+
+
+ /// [AlphaFS] Initializes an instance from a physical disk device path.
+ ///
+ /// Creating an instance for every volume/logical drive on the Computer is expensive as each call queries all physical disks, associated volumes/logical drives.
+ /// Instead, use method and property or .
+ ///
+ ///
+ /// A disk path such as: \\.\PhysicalDrive0
+ /// A drive path such as: C, C: or C:\
+ /// A volume such as: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// A string such as: \\?\scsi#disk...{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
+ ///
+ public PhysicalDiskInfo(string devicePath)
+ {
+ CreatePhysicalDiskInfoInstance(-1, devicePath, null, null);
+ }
+
+
+ /// Used by
+ internal PhysicalDiskInfo(int deviceNumber, StorageDeviceInfo storageDeviceInfo, DeviceInfo deviceInfo)
+ {
+ CreatePhysicalDiskInfoInstance(deviceNumber, null, storageDeviceInfo, deviceInfo);
+ }
+
+ #endregion // Constructors
+
+
+ #region Properties
+
+ /// An initialized instance.
+ private DeviceInfo DeviceInfo { get; set; }
+
+
+ /// The device description.
+ public string DeviceDescription
+ {
+ get { return null != DeviceInfo ? DeviceInfo.DeviceDescription : string.Empty; }
+ }
+
+
+ /// The device path.
+ public string DevicePath
+ {
+ get { return null != DeviceInfo ? DeviceInfo.DevicePath : string.Empty; }
+ }
+
+
+ /// The Win32 device name.
+ public string DosDeviceName { get; private set; }
+
+
+ /// An of logical drives that are located on the physical disk.
+ public IEnumerable LogicalDrives { get; private set; }
+
+
+ /// The device (friendly) name.
+ public string Name
+ {
+ get { return null != DeviceInfo ? DeviceInfo.FriendlyName : string.Empty; }
+ }
+
+
+ /// An of partition index numbers that are located on the physical disk.
+ public IEnumerable PartitionIndexes { get; private set; }
+
+
+ /// The device (PDO) information provided by a device's firmware to Windows.
+ public string PhysicalDeviceObjectName
+ {
+ get { return null != DeviceInfo ? DeviceInfo.PhysicalDeviceObjectName : string.Empty; }
+ }
+
+
+ /// Retrieves the current power state of the device.
+ /// This property is not cached.
+ public bool PowerStateEnabled
+ {
+ get { return !Utils.IsNullOrWhiteSpace(DevicePath) && Local.GetDevicePowerState(DevicePath); }
+ }
+
+
+ /// The storage device adapter information.
+ public StorageAdapterInfo StorageAdapterInfo { get; private set; }
+
+
+ /// The storage device information.
+ public StorageDeviceInfo StorageDeviceInfo { get; private set; }
+
+
+ /// The storage device partition information.
+ public StoragePartitionInfo StoragePartitionInfo { get; private set; }
+
+
+ /// An of volume strings that are located on the physical disk.
+ public IEnumerable VolumeGuids { get; private set; }
+
+ #endregion // Properties
+ }
+}
diff --git a/AlphaFS/Device/Storage/Device.StorageAdapterInfo.cs b/AlphaFS/Device/Storage/Device.StorageAdapterInfo.cs
new file mode 100644
index 000000000..02b61caa3
--- /dev/null
+++ b/AlphaFS/Device/Storage/Device.StorageAdapterInfo.cs
@@ -0,0 +1,181 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides access to adapter information of a storage device.
+ [Serializable]
+ [SecurityCritical]
+ public sealed class StorageAdapterInfo
+ {
+ #region Constructors
+
+ /// [AlphaFS] Initializes an empty StorageAdapterInfo instance.
+ public StorageAdapterInfo()
+ {
+ BusType = StorageBusType.Unknown;
+
+ DeviceNumber = -1;
+ }
+
+
+ internal StorageAdapterInfo(int diskNumber, NativeMethods.STORAGE_ADAPTER_DESCRIPTOR adapter) : this()
+ {
+ DeviceNumber = diskNumber;
+
+ BusType = (StorageBusType) adapter.BusType;
+
+ AcceleratedTransfer = adapter.AcceleratedTransfer;
+
+ AdapterScansDown = adapter.AdapterScansDown;
+
+ AdapterUsesPio = adapter.AdapterUsesPio;
+
+ BusVersion = adapter.BusVersion;
+
+ CommandQueueing = adapter.CommandQueueing;
+
+ MaximumTransferBytes = (int) adapter.MaximumTransferLength;
+ }
+
+ #endregion // Constructors
+
+
+ #region Properties
+
+ /// When true, the storage adapter supports synchronous transfers as a way of speeding up I/O.
+ public bool AcceleratedTransfer { get; private set; }
+
+
+ /// When true, the storage adapter scans down for BIOS devices, that is, the storage adapter begins scanning with the highest device number rather than the lowest.
+ public bool AdapterScansDown { get; private set; }
+
+
+ /// When true, the storage adapter uses programmed I/O (PIO).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pio")]
+ public bool AdapterUsesPio { get; private set; }
+
+
+ /// The bus type of the storage adapter.
+ public StorageBusType BusType { get; private set; }
+
+
+ /// Represents a description of a device instance as identified by the bus.
+ public string BusReportedDeviceDescription { get; internal set; }
+
+ /// The version number, if any, of the storage adapter.
+ public Version BusVersion { get; private set; }
+
+
+ /// When true, the storage adapter supports SCSI tagged queuing and/or per-logical-unit internal queues, or the non-SCSI equivalent.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Queueing")]
+ public bool CommandQueueing { get; private set; }
+
+
+ /// The device number connected to this storage adapter, starting at 0.
+ public int DeviceNumber { get; private set; }
+
+
+ /// Specifies the maximum number of bytes the storage adapter can transfer in a single operation.
+ public int MaximumTransferBytes { get; private set; }
+
+
+#if DEBUG
+ /// Specifies the maximum number of bytes the storage adapter can transfer in a single operation, formatted as a unit size.
+ public string MaximumTransferBytesUnitSize
+ {
+ get { return Utils.UnitSizeToText(MaximumTransferBytes); }
+ }
+#endif
+
+ #endregion // Properties
+
+
+ #region Methods
+
+ /// Returns storage device as: "BusType MaximumTransferBytes".
+ /// Returns a string that represents this instance.
+ public override string ToString()
+ {
+ return BusType == StorageBusType.Unknown ? StorageBusType.Unknown.ToString() : string.Format(CultureInfo.CurrentCulture, "{0} {1}", (BusType.ToString() + " " ).Trim(), Utils.UnitSizeToText(MaximumTransferBytes));
+ }
+
+
+ /// Determines whether the specified Object is equal to the current Object.
+ /// Another object to compare to.
+ /// true if the specified Object is equal to the current Object; otherwise, false.
+ public override bool Equals(object obj)
+ {
+ if (null == obj || GetType() != obj.GetType())
+ return false;
+
+ var other = obj as StorageAdapterInfo;
+
+ return null != other &&
+ other.AcceleratedTransfer == AcceleratedTransfer &&
+ other.AdapterScansDown == AdapterScansDown &&
+ other.AdapterUsesPio == AdapterUsesPio &&
+ other.BusReportedDeviceDescription == BusReportedDeviceDescription &&
+ other.BusType == BusType &&
+ other.BusVersion == BusVersion &&
+ other.CommandQueueing == CommandQueueing &&
+ other.MaximumTransferBytes == MaximumTransferBytes;
+ }
+
+
+ /// Serves as a hash function for a particular type.
+ /// Returns a hash code for the current Object.
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return MaximumTransferBytes.GetHashCode() + AcceleratedTransfer.GetHashCode() + AcceleratedTransfer.GetHashCode() + CommandQueueing.GetHashCode() + BusType.GetHashCode();
+ }
+ }
+
+
+ /// Implements the operator ==
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator ==(StorageAdapterInfo left, StorageAdapterInfo right)
+ {
+ return ReferenceEquals(left, null) && ReferenceEquals(right, null) || !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right);
+ }
+
+
+ /// Implements the operator !=
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator !=(StorageAdapterInfo left, StorageAdapterInfo right)
+ {
+ return !(left == right);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/AlphaFS/Device/Storage/Device.StorageDeviceInfo.cs b/AlphaFS/Device/Storage/Device.StorageDeviceInfo.cs
new file mode 100644
index 000000000..10f0c06a9
--- /dev/null
+++ b/AlphaFS/Device/Storage/Device.StorageDeviceInfo.cs
@@ -0,0 +1,198 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides access to information of a storage device.
+ [Serializable]
+ [SecurityCritical]
+ public sealed class StorageDeviceInfo
+ {
+ #region Fields
+
+
+ #endregion // Private Fields
+
+
+ #region Constructors
+
+ /// [AlphaFS] Initializes an empty StorageDeviceInfo instance.
+ public StorageDeviceInfo()
+ {
+ DeviceType = DeviceType.Unknown;
+
+ DeviceNumber = -1;
+
+ PartitionNumber = -1;
+ }
+
+
+ internal StorageDeviceInfo(NativeMethods.STORAGE_DEVICE_NUMBER device) : this()
+ {
+ DeviceType = (DeviceType) device.DeviceType;
+
+ DeviceNumber = device.DeviceNumber;
+
+ PartitionNumber = device.PartitionNumber;
+ }
+
+ #endregion // Constructors
+
+
+ #region Properties
+
+ /// The type of the bus to which the device is connected.
+ public StorageBusType BusType { get; internal set; }
+
+
+ ///
+ /// Indicates if the physical disk supports multiple outstanding commands (SCSI tagged queuing or equivalent).
+ /// When false the physical disk does not support SCSI-tagged queuing or the equivalent.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Queueing")]
+ public bool CommandQueueing { get; internal set; }
+
+
+ /// The storage device type.
+ public DeviceType DeviceType { get; private set; }
+
+
+ /// The device number of the storage device, starting at 0.
+ public int DeviceNumber { get; private set; }
+
+
+ ///
+ /// The partition number of the storage device, starting at 1.
+ /// If the device cannot be partitioned, like a CD/DVD-ROM, -1 is returned.
+ /// If this value is 0, the information points to the device, not partition.
+ /// If the partition is on a dynamic disk (), the partition's number is returned.
+ ///
+ public int PartitionNumber { get; internal set; }
+
+
+ /// The product ID of the physical disk.
+ public string ProductId { get; internal set; }
+
+
+ /// The product revision of the physical disk.
+ public string ProductRevision { get; internal set; }
+
+
+ ///
+ /// Indicates if the physical disk is removable. When true the physical disk's media (if any) is removable.
+ /// If the device has no media, this member should be ignored. When false the physical disk's media is not removable.
+ ///
+ public bool RemovableMedia { get; internal set; }
+
+
+ /// The serial number of the physical disk. If the physical disk has no serial number null is returned.
+ public string SerialNumber { get; internal set; }
+
+
+ /// The total size of the physical disk.
+ public long TotalSize { get; internal set; }
+
+
+ /// The of the physical disk, formatted as a unit size.
+ public string TotalSizeUnitSize
+ {
+ get { return Utils.UnitSizeToText(TotalSize); }
+ }
+
+
+ /// The Vendor ID of the physical disk.
+ public string VendorId { get; internal set; }
+
+ #endregion // Properties
+
+
+ #region Methods
+
+ /// Returns storage device as: "DeviceType DeviceNumber:PartitionNumber VendorId ProductId".
+ /// Returns a string that represents this instance.
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "Device: {0}:{1} {2}", DeviceNumber.ToString(CultureInfo.InvariantCulture), PartitionNumber.ToString(CultureInfo.InvariantCulture), (VendorId + " " + ProductId + " " + ProductRevision).Trim()).Trim();
+ }
+
+
+ /// Determines whether the specified Object is equal to the current Object.
+ /// Another object to compare to.
+ /// true if the specified Object is equal to the current Object; otherwise, false.
+ public override bool Equals(object obj)
+ {
+ if (null == obj || GetType() != obj.GetType())
+ return false;
+
+ var other = obj as StorageDeviceInfo;
+
+ return null != other &&
+ other.BusType == BusType &&
+ other.DeviceNumber == DeviceNumber &&
+ other.DeviceType == DeviceType &&
+ other.PartitionNumber == PartitionNumber &&
+ other.ProductId == ProductId &&
+ other.ProductRevision == ProductRevision &&
+ other.RemovableMedia == RemovableMedia &&
+ other.SerialNumber == SerialNumber &&
+ other.TotalSize == TotalSize &&
+ other.VendorId == VendorId;
+ }
+
+
+ /// Serves as a hash function for a particular type.
+ /// Returns a hash code for the current Object.
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return RemovableMedia.GetHashCode() + TotalSize.GetHashCode() + DeviceNumber.GetHashCode() + PartitionNumber.GetHashCode();
+ }
+ }
+
+
+ /// Implements the operator ==
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator ==(StorageDeviceInfo left, StorageDeviceInfo right)
+ {
+ return ReferenceEquals(left, null) && ReferenceEquals(right, null) || !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right);
+ }
+
+
+ /// Implements the operator !=
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator !=(StorageDeviceInfo left, StorageDeviceInfo right)
+ {
+ return !(left == right);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/AlphaFS/Device/Storage/Device.StorageGptPartitionInfo.cs b/AlphaFS/Device/Storage/Device.StorageGptPartitionInfo.cs
new file mode 100644
index 000000000..64993cdd5
--- /dev/null
+++ b/AlphaFS/Device/Storage/Device.StorageGptPartitionInfo.cs
@@ -0,0 +1,253 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides access to GPT partition information of a storage device.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt"), Serializable]
+ [SecurityCritical]
+ public sealed class StorageGptPartitionInfo
+ {
+ #region Fields
+
+ private readonly int _partitionNumber;
+ private ulong _partitionLength;
+ private ulong _startingOffset;
+
+ #endregion // Private Fields
+
+
+ #region Constructors
+
+ /// [AlphaFS] Initializes an empty StorageGptPartitionInfo instance.
+ public StorageGptPartitionInfo()
+ {
+ _partitionNumber = -1;
+ }
+
+
+ internal StorageGptPartitionInfo(NativeMethods.PARTITION_INFORMATION_EX partition, PartitionType[] partitionTypes) : this()
+ {
+ _partitionLength = partition.PartitionLength;
+
+ _startingOffset = partition.StartingOffset;
+
+ _partitionNumber = (int) partition.PartitionNumber;
+
+
+ RewritePartition = partition.RewritePartition;
+
+ var gptPartition = partition.Gpt;
+
+ Description = gptPartition.Name.Trim();
+
+ PartitionId = gptPartition.PartitionId;
+
+
+
+
+ // Convert the native enum since it is of type ulong.
+
+ var attrs = gptPartition.Attributes;
+
+ if ((attrs & NativeMethods.EfiPartitionAttributes.GPT_ATTRIBUTE_PLATFORM_REQUIRED) != 0)
+ Attributes |= EfiPartitionAttributes.PlatformRequired;
+
+ if ((attrs & NativeMethods.EfiPartitionAttributes.GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY) != 0)
+ Attributes |= EfiPartitionAttributes.ReadOnly;
+
+ if ((attrs & NativeMethods.EfiPartitionAttributes.GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY) != 0)
+ Attributes |= EfiPartitionAttributes.ShadowCopy;
+
+ if ((attrs & NativeMethods.EfiPartitionAttributes.GPT_BASIC_DATA_ATTRIBUTE_HIDDEN) != 0)
+ Attributes |= EfiPartitionAttributes.Hidden;
+
+ if ((attrs & NativeMethods.EfiPartitionAttributes.GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER) != 0)
+ Attributes |= EfiPartitionAttributes.NoDriveLetter;
+
+
+
+
+ var partitionType = gptPartition.PartitionType.ToString();
+
+ foreach (var guid in partitionTypes)
+ if (partitionType.Equals(Utils.GetEnumDescription(guid), StringComparison.OrdinalIgnoreCase))
+ {
+ PartitionType = guid;
+ break;
+ }
+ }
+
+ #endregion // Constructors
+
+
+ #region Properties
+
+ /// The Extensible Firmware Interface (EFI) attributes of the partition.
+ public EfiPartitionAttributes Attributes { get; private set; }
+
+
+ /// The description of the partition.
+ public string Description { get; private set; }
+
+
+ /// The GUID of the partition.
+ public Guid PartitionId { get; private set; }
+
+
+ /// The size of the partition.
+ public long PartitionLength
+ {
+ get
+ {
+ unchecked
+ {
+ return (long) _partitionLength;
+ }
+ }
+
+ internal set
+ {
+ unchecked
+ {
+ _partitionLength = (ulong) value;
+ }
+ }
+ }
+
+
+#if DEBUG
+ ///
+ public string PartitionLengthUnitSize
+ {
+ get { return Utils.UnitSizeToText(PartitionLength); }
+ }
+#endif
+
+
+ /// The storage partition number, starting at 1.
+ public int PartitionNumber
+ {
+ get { return _partitionNumber; }
+ }
+
+
+ /// The the partition type. Each partition type that the EFI specification supports is identified by its own GUID, which is published by the developer of the partition.
+ public PartitionType PartitionType { get; private set; }
+
+
+ /// The rewritable status of the storage partition.
+ public bool RewritePartition { get; private set; }
+
+
+ /// The starting offset of the partition.
+ public long StartingOffset
+ {
+ get
+ {
+ unchecked
+ {
+ return (long) _startingOffset;
+ }
+ }
+
+ internal set
+ {
+ unchecked
+ {
+ _startingOffset = (ulong) value;
+ }
+ }
+ }
+
+ #endregion // Properties
+
+
+ #region Methods
+
+ /// Returns storage device as: "VendorId ProductId DeviceType DeviceNumber:PartitionNumber".
+ /// Returns a string that represents this instance.
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "{0} {1}", Description, Attributes.ToString()).Trim();
+ }
+
+
+ /// Determines whether the specified Object is equal to the current Object.
+ /// Another object to compare to.
+ /// true if the specified Object is equal to the current Object; otherwise, false.
+ public override bool Equals(object obj)
+ {
+ if (null == obj || GetType() != obj.GetType())
+ return false;
+
+ var other = obj as StorageGptPartitionInfo;
+
+ return null != other &&
+ other.Attributes == Attributes &&
+ other.Description == Description &&
+ other.PartitionId == PartitionId &&
+ other.PartitionLength == PartitionLength &&
+ other.PartitionNumber == PartitionNumber &&
+ other.PartitionType == PartitionType &&
+ other.RewritePartition == RewritePartition &&
+ other.StartingOffset == StartingOffset;
+ }
+
+
+ /// Serves as a hash function for a particular type.
+ /// Returns a hash code for the current Object.
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return PartitionLength.GetHashCode() + StartingOffset.GetHashCode() + PartitionNumber.GetHashCode();
+ }
+ }
+
+
+ /// Implements the operator ==
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator ==(StorageGptPartitionInfo left, StorageGptPartitionInfo right)
+ {
+ return ReferenceEquals(left, null) && ReferenceEquals(right, null) || !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right);
+ }
+
+
+ /// Implements the operator !=
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator !=(StorageGptPartitionInfo left, StorageGptPartitionInfo right)
+ {
+ return !(left == right);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/AlphaFS/Device/Storage/Device.StorageMbrPartitionInfo.cs b/AlphaFS/Device/Storage/Device.StorageMbrPartitionInfo.cs
new file mode 100644
index 000000000..dd225ab5d
--- /dev/null
+++ b/AlphaFS/Device/Storage/Device.StorageMbrPartitionInfo.cs
@@ -0,0 +1,227 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides access to MBR partition information of a storage device.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mbr"), Serializable]
+ [SecurityCritical]
+ public sealed class StorageMbrPartitionInfo
+ {
+ #region Fields
+
+ private readonly int _partitionNumber;
+ private ulong _partitionLength;
+ private ulong _startingOffset;
+
+ #endregion // Private Fields
+
+
+ #region Constructors
+
+ /// [AlphaFS] Initializes an empty StorageMbrPartitionInfo instance.
+ public StorageMbrPartitionInfo()
+ {
+ _partitionNumber = -1;
+
+ HiddenSectors = -1;
+ }
+
+
+
+ internal StorageMbrPartitionInfo(NativeMethods.PARTITION_INFORMATION_EX partition) : this()
+ {
+ _partitionNumber = (int) partition.PartitionNumber;
+
+ _partitionLength = partition.PartitionLength;
+
+ _startingOffset = partition.StartingOffset;
+
+
+ RewritePartition = partition.RewritePartition;
+
+ var mbrPartition = partition.Mbr;
+
+ BootIndicator = mbrPartition.BootIndicator;
+
+ HiddenSectors = (int) mbrPartition.HiddenSectors;
+
+ RecognizedPartition = mbrPartition.RecognizedPartition;
+
+ DiskPartitionType = (DiskPartitionType) mbrPartition.PartitionType;
+ }
+
+ #endregion // Constructors
+
+
+ #region Properties
+
+ /// true if the partition is a boot partition.
+ public bool BootIndicator { get; private set; }
+
+
+ /// The type of the partition.
+ public DiskPartitionType DiskPartitionType { get; private set; }
+
+
+ /// The number of hidden sectors to be allocated when the partition table is created.
+ public int HiddenSectors { get; private set; }
+
+
+ /// The size of the partition.
+ public long PartitionLength
+ {
+ get
+ {
+ unchecked
+ {
+ return (long) _partitionLength;
+ }
+ }
+
+ internal set
+ {
+ unchecked
+ {
+ _partitionLength = (ulong) value;
+ }
+ }
+ }
+
+
+#if DEBUG
+ ///
+ public string PartitionLengthUnitSize
+ {
+ get { return Utils.UnitSizeToText(PartitionLength); }
+ }
+#endif
+
+
+ /// The storage partition number, starting at 1.
+ public int PartitionNumber
+ {
+ get { return _partitionNumber; }
+ }
+
+
+ /// true if the partition is of a recognized type.
+ public bool RecognizedPartition { get; private set; }
+
+
+ /// The rewritable status of the storage partition.
+ public bool RewritePartition { get; private set; }
+
+
+ /// The starting offset of the partition.
+ public long StartingOffset
+ {
+ get
+ {
+ unchecked
+ {
+ return (long) _startingOffset;
+ }
+ }
+
+ internal set
+ {
+ unchecked
+ {
+ _startingOffset = (ulong) value;
+ }
+ }
+ }
+
+ #endregion // Properties
+
+
+ #region Methods
+
+ /// Returns storage device as: "VendorId ProductId DeviceType DeviceNumber:PartitionNumber".
+ /// Returns a string that represents this instance.
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "BootIndicator: {0}, Type: {1}, RecognizedPartition: {2}", BootIndicator.ToString(), DiskPartitionType.ToString(), RecognizedPartition.ToString()).Trim();
+ }
+
+
+ /// Determines whether the specified Object is equal to the current Object.
+ /// Another object to compare to.
+ /// true if the specified Object is equal to the current Object; otherwise, false.
+ public override bool Equals(object obj)
+ {
+ if (null == obj || GetType() != obj.GetType())
+ return false;
+
+ var other = obj as StorageMbrPartitionInfo;
+
+ return null != other &&
+ other.BootIndicator == BootIndicator &&
+ other.DiskPartitionType == DiskPartitionType &&
+ other.HiddenSectors == HiddenSectors &&
+ other.PartitionLength == PartitionLength &&
+ other.PartitionNumber == PartitionNumber &&
+ other.RecognizedPartition == RecognizedPartition &&
+ other.RewritePartition == RewritePartition &&
+ other.StartingOffset == StartingOffset;
+
+ }
+
+
+ /// Serves as a hash function for a particular type.
+ /// Returns a hash code for the current Object.
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return PartitionLength.GetHashCode() + StartingOffset.GetHashCode() + PartitionNumber.GetHashCode();
+ }
+ }
+
+
+ /// Implements the operator ==
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator ==(StorageMbrPartitionInfo left, StorageMbrPartitionInfo right)
+ {
+ return ReferenceEquals(left, null) && ReferenceEquals(right, null) || !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right);
+ }
+
+
+ /// Implements the operator !=
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator !=(StorageMbrPartitionInfo left, StorageMbrPartitionInfo right)
+ {
+ return !(left == right);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/AlphaFS/Device/Storage/Device.StoragePartitionInfo.cs b/AlphaFS/Device/Storage/Device.StoragePartitionInfo.cs
new file mode 100644
index 000000000..29754b203
--- /dev/null
+++ b/AlphaFS/Device/Storage/Device.StoragePartitionInfo.cs
@@ -0,0 +1,316 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Linq;
+using System.Security;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// [AlphaFS] Provides access to partition information of a storage device.
+ [Serializable]
+ [SecurityCritical]
+ public sealed class StoragePartitionInfo
+ {
+ #region Fields
+
+ private ulong _gptStartingUsableOffset;
+ private ulong _gptUsableLength;
+
+ #endregion // Private Fields
+
+
+ #region Constructors
+
+ /// [AlphaFS] Initializes an empty StoragePartitionInfo instance.
+ public StoragePartitionInfo()
+ {
+ DeviceNumber = -1;
+
+ PartitionCount = -1;
+
+ PartitionStyle = PartitionStyle.Raw;
+ }
+
+
+ internal StoragePartitionInfo(int diskNumber, NativeMethods.DISK_GEOMETRY_EX disk, NativeMethods.DRIVE_LAYOUT_INFORMATION_EX drive, NativeMethods.PARTITION_INFORMATION_EX[] partitions) : this()
+ {
+ DeviceNumber = diskNumber;
+
+ MediaType = (StorageMediaType) disk.Geometry.MediaType;
+
+ PartitionCount = (int) drive.PartitionCount;
+
+ MbrSignature = disk.PartitionInformation.MbrSignature;
+
+ GptDiskId = disk.PartitionInformation.DiskId;
+
+ TotalSize = disk.DiskSize;
+
+ PartitionStyle = (PartitionStyle) disk.PartitionInformation.PartitionStyle;
+
+ switch (PartitionStyle)
+ {
+ case PartitionStyle.Gpt:
+
+ GptMaxPartitionCount = (int) drive.Gpt.MaxPartitionCount;
+
+ _gptStartingUsableOffset = drive.Gpt.StartingUsableOffset;
+
+ _gptUsableLength = drive.Gpt.UsableLength;
+
+
+ if (PartitionCount > 0)
+ {
+ GptPartitionInfo = new Collection();
+
+ var partitionTypes = Utils.EnumToArray();
+
+ for (var i = 0; i <= PartitionCount - 1; i++)
+ GptPartitionInfo.Add(new StorageGptPartitionInfo(partitions[i], partitionTypes));
+ }
+
+ break;
+
+
+ case PartitionStyle.Mbr:
+
+ if (PartitionCount > 0)
+ {
+ MbrPartitionInfo = new Collection();
+
+ for (var i = 0; i <= PartitionCount - 1; i++)
+ {
+ var partition = partitions[i];
+
+ // MSDN: PartitionCount: On hard disks with the MBR layout, this value will always be a multiple of 4.
+ // Any partitions that are actually unused will have a partition type of PARTITION_ENTRY_UNUSED (0).
+
+ if (partition.Mbr.PartitionType == (NativeMethods.DiskPartitionType) DiskPartitionType.UnusedEntry)
+ continue;
+
+
+ MbrPartitionInfo.Add(new StorageMbrPartitionInfo(partition));
+ }
+
+
+ // Update to reflect the real number of used partition entries.
+ PartitionCount = MbrPartitionInfo.Count;
+ }
+
+ break;
+ }
+ }
+
+ #endregion // Constructors
+
+
+ #region Properties
+
+ /// The GUID of the disk.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ public Guid GptDiskId { get; private set; }
+
+
+ /// The device number of the storage partition, starting at 0.
+ public int DeviceNumber { get; private set; }
+
+
+ /// The maximum number of partitions that can be defined in the usable block.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ public int GptMaxPartitionCount { get; private set; }
+
+
+ /// Contains GUID partition table (GPT) partition information.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ public ICollection GptPartitionInfo { get; private set; }
+
+
+ /// The starting byte offset of the first usable block.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ public long GptStartingUsableOffset
+ {
+ get
+ {
+ unchecked
+ {
+ return (long) _gptStartingUsableOffset;
+ }
+ }
+
+ internal set
+ {
+ unchecked
+ {
+ _gptStartingUsableOffset = (ulong) value;
+ }
+ }
+ }
+
+
+ /// The size of the usable blocks on the disk in bytes.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ public long GptUsableLength
+ {
+ get
+ {
+ unchecked
+ {
+ return (long) _gptUsableLength;
+ }
+ }
+
+ internal set
+ {
+ unchecked
+ {
+ _gptUsableLength = (ulong) value;
+ }
+ }
+ }
+
+
+#if DEBUG
+ /// The size of the usable blocks on the disk in bytes, formatted as a unit size.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ public string GptUsableLengthUnitSize
+ {
+ get { return Utils.UnitSizeToText(GptUsableLength); }
+ }
+#endif
+
+
+ /// true if the partition is on a dynamic disk.
+ public bool OnDynamicDisk
+ {
+ get
+ {
+ return null != GptPartitionInfo && GptPartitionInfo.Any(partition => partition.PartitionType == PartitionType.LdmData || partition.PartitionType == PartitionType.LdmMetadata) ||
+
+ null != MbrPartitionInfo && MbrPartitionInfo.Any(partition => partition.DiskPartitionType == DiskPartitionType.Ldm);
+ }
+ }
+
+
+ /// Contains partition information specific to master boot record (MBR) disks.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mbr")]
+ public ICollection MbrPartitionInfo { get; private set; }
+
+
+ /// The MBR signature of the drive.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mbr")]
+ public long MbrSignature { get; private set; }
+
+
+ /// The media type of the storage partition.
+ public StorageMediaType MediaType { get; private set; }
+
+
+ /// The number of partitions on the drive.
+ public int PartitionCount { get; private set; }
+
+ /// The format of the partition. For a list of values, see .
+ public PartitionStyle PartitionStyle { get; private set; }
+
+
+ /// The total size of the storage partition.
+ public long TotalSize { get; private set; }
+
+
+
+ /// The total size of the storage partition, formatted as a unit size.
+ public string TotalSizeUnitSize
+ {
+ get { return Utils.UnitSizeToText(TotalSize); }
+ }
+
+ #endregion // Properties
+
+
+ #region Methods
+
+ /// Returns storage device as: "VendorId ProductId DeviceType DeviceNumber:PartitionNumber".
+ /// Returns a string that represents this instance.
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "Device: {0} PartitionStyle: {1}", DeviceNumber.ToString(CultureInfo.InvariantCulture), PartitionStyle.ToString().ToUpperInvariant()).Trim();
+ }
+
+
+ /// Determines whether the specified Object is equal to the current Object.
+ /// Another object to compare to.
+ /// true if the specified Object is equal to the current Object; otherwise, false.
+ public override bool Equals(object obj)
+ {
+ if (null == obj || GetType() != obj.GetType())
+ return false;
+
+ var other = obj as StoragePartitionInfo;
+
+ return null != other &&
+ other.DeviceNumber == DeviceNumber &&
+ other.GptDiskId == GptDiskId &&
+ other.GptStartingUsableOffset == GptStartingUsableOffset &&
+ other.GptUsableLength == GptUsableLength &&
+ other.MediaType == MediaType &&
+ other.PartitionCount == PartitionCount &&
+ other.PartitionStyle == PartitionStyle &&
+ other.TotalSize == TotalSize;
+ }
+
+
+ /// Serves as a hash function for a particular type.
+ /// Returns a hash code for the current Object.
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return GptUsableLength.GetHashCode() + GptStartingUsableOffset.GetHashCode() + DeviceNumber.GetHashCode() + PartitionCount.GetHashCode();
+ }
+ }
+
+
+ /// Implements the operator ==
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator ==(StoragePartitionInfo left, StoragePartitionInfo right)
+ {
+ return ReferenceEquals(left, null) && ReferenceEquals(right, null) || !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right);
+ }
+
+
+ /// Implements the operator !=
+ /// A.
+ /// B.
+ /// The result of the operator.
+ public static bool operator !=(StoragePartitionInfo left, StoragePartitionInfo right)
+ {
+ return !(left == right);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/AlphaFS/Device/Structures, Enumerations/DetectionType.cs b/AlphaFS/Device/Structures, Enumerations/DetectionType.cs
new file mode 100644
index 000000000..5028f9ad3
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/DetectionType.cs
@@ -0,0 +1,36 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32.Device
+{
+ /// The DETECTION_TYPE enumeration type is used in conjunction with the IOCTL_DISK_GET_DRIVE_GEOMETRY_EX request and the DISK_GEOMETRY_EX structure to determine the type of formatting used by the BIOS to record the disk geometry.
+ public enum DetectionType
+ {
+ /// Indicates that the disk contains neither an INT 13h partition nor an extended INT 13h partition.
+ DetectNone = 0,
+
+ /// Indicates that the disk has a standard INT 13h partition.
+ DetectInt13 = 1,
+
+ /// Indicates that the disk contains an extended INT 13h partition.
+ DetectExInt13 = 2
+ }
+}
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/DeviceGuid.cs b/AlphaFS/Device/Structures, Enumerations/DeviceGuid.cs
similarity index 73%
rename from AlphaFS/Filesystem/Structures, Enumerations/DeviceGuid.cs
rename to AlphaFS/Device/Structures, Enumerations/DeviceGuid.cs
index 1ecb21b23..4e1fdefaa 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/DeviceGuid.cs
+++ b/AlphaFS/Device/Structures, Enumerations/DeviceGuid.cs
@@ -22,7 +22,7 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
/// System-Defined Device Interface Classes
/// http://msdn.microsoft.com/en-us/library/windows/hardware/ff541389%28v=vs.85%29.aspx
@@ -31,124 +31,152 @@ public enum DeviceGuid
#region 1394 and 61883 Devices
/// The BUS1394_CLASS_GUID device interface class is defined for 1394 bus devices.
- [Description("6BDD1FC1-810F-11d0-BEC7-08002BE2092F")] Bus1394,
+ [Description("6BDD1FC1-810F-11d0-BEC7-08002BE2092F")]
+ Bus1394,
/// The GUID_61883_CLASS device interface class is defined for devices in the 61883 device setup class.
- [Description("7EBEFBC0-3200-11d2-B4C2-00A0C9697D07")] Guid61883,
+ [Description("7EBEFBC0-3200-11d2-B4C2-00A0C9697D07")]
+ Guid61883,
#endregion // 1394 and 61883 Devices
-
+
#region Battery and ACPI devices
/// The GUID_DEVICE_APPLICATIONLAUNCH_BUTTON device interface class is defined for Advanced Configuration and Power Interface (ACPI) application start buttons.
- [Description("629758EE-986E-4D9E-8E47-DE27F8AB054D")] ApplicationLaunchButton,
+ [Description("629758EE-986E-4D9E-8E47-DE27F8AB054D")]
+ ApplicationLaunchButton,
/// The GUID_DEVICE_BATTERY device interface class is defined for battery devices.
- [Description("72631E54-78A4-11D0-BCF7-00AA00B7B32A")] Battery,
+ [Description("72631E54-78A4-11D0-BCF7-00AA00B7B32A")]
+ Battery,
/// The GUID_DEVICE_LID device interface class is defined for Advanced Configuration and Power Interface (ACPI) lid devices.
- [Description("4AFA3D52-74A7-11d0-be5e-00A0C9062857")] Lid,
+ [Description("4AFA3D52-74A7-11d0-be5e-00A0C9062857")]
+ Lid,
/// The GUID_DEVICE_MEMORY device interface class is defined for Advanced Configuration and Power Interface (ACPI) memory devices.
- [Description("3FD0F03D-92E0-45FB-B75C-5ED8FFB01021")] Memory,
+ [Description("3FD0F03D-92E0-45FB-B75C-5ED8FFB01021")]
+ Memory,
/// The GUID_DEVICE_MESSAGE_INDICATOR device interface class is defined for Advanced Configuration and Power Interface (ACPI) message indicator devices.
- [Description("CD48A365-FA94-4CE2-A232-A1B764E5D8B4")] MessageIndicator,
+ [Description("CD48A365-FA94-4CE2-A232-A1B764E5D8B4")]
+ MessageIndicator,
/// The GUID_DEVICE_PROCESSOR device interface class is defined for Advanced Configuration and Power Interface (ACPI) processor devices.
- [Description("97FADB10-4E33-40AE-359C-8BEF029DBDD0")] Processor,
+ [Description("97FADB10-4E33-40AE-359C-8BEF029DBDD0")]
+ Processor,
/// The GUID_DEVICE_SYS_BUTTON device interface classis defined for Advanced Configuration and Power Interface (ACPI) system power button devices.
- [Description("4AFA3D53-74A7-11d0-be5e-00A0C9062857")] SysButton,
+ [Description("4AFA3D53-74A7-11d0-be5e-00A0C9062857")]
+ SysButton,
/// The GUID_DEVICE_THERMAL_ZONE device interface class is defined for Advanced Configuration and Power Interface (ACPI) thermal zone devices.
- [Description("4AFA3D51-74A7-11d0-be5e-00A0C9062857")] ThermalZone,
+ [Description("4AFA3D51-74A7-11d0-be5e-00A0C9062857")]
+ ThermalZone,
#endregion // Battery and ACPI devices
-
+
#region Bluetooth Devices
/// The GUID_BTHPORT_DEVICE_INTERFACE device interface class is defined for Bluetooth radios.
- [Description("0850302A-B344-4fda-9BE9-90576B8D46F0")] Bluetooth,
+ [Description("0850302A-B344-4fda-9BE9-90576B8D46F0")]
+ Bluetooth,
#endregion // Bluetooth Devices
-
+
#region Display and Image Devices
/// The GUID_DEVINTERFACE_BRIGHTNESS device interface class is defined for display adapter drivers that operate in the context of the Windows Vista Display Driver Model and support brightness control of monitor child devices.
- [Description("FDE5BBA4-B3F9-46FB-BDAA-0728CE3100B4")] Brightness,
+ [Description("FDE5BBA4-B3F9-46FB-BDAA-0728CE3100B4")]
+ Brightness,
/// The GUID_DEVINTERFACE_DISPLAY_ADAPTER device interface class is defined for display views that are supported by display adapters.
- [Description("5B45201D-F2F2-4F3B-85BB-30FF1F953599")] DisplayAdapter,
+ [Description("5B45201D-F2F2-4F3B-85BB-30FF1F953599")]
+ DisplayAdapter,
/// The GUID_DEVINTERFACE_I2C device interface class is defined for display adapter drivers that operate in the context of the Windows Vista Display Driver Model and perform I2C transactions with monitor child devices.
- [Description("2564AA4F-DDDB-4495-B497-6AD4A84163D7")] I2C,
+ [Description("2564AA4F-DDDB-4495-B497-6AD4A84163D7")]
+ I2C,
/// The GUID_DEVINTERFACE_IMAGE device interface class is defined for WIA devices and Still Image (STI) devices, including digital cameras and scanners.
- [Description("6BDD1FC6-810F-11D0-BEC7-08002BE2092F")] StillImage,
+ [Description("6BDD1FC6-810F-11D0-BEC7-08002BE2092F")]
+ Image,
/// The GUID_DEVINTERFACE_MONITOR device interface class is defined for monitor devices.
- [Description("E6F07B5F-EE97-4a90-B076-33F57BF4EAA7")] Monitor,
+ [Description("E6F07B5F-EE97-4a90-B076-33F57BF4EAA7")]
+ Monitor,
/// The GUID_DEVINTERFACE_OPM device interface class is defined for display adapter drivers that operate in the context of the Windows Vista Display Driver Model and support output protection management (OPM) for monitor child devices.
- [Description("BF4672DE-6B4E-4BE4-A325-68A91EA49C09")] OutputProtectionManagement,
+ [Description("BF4672DE-6B4E-4BE4-A325-68A91EA49C09")]
+ OutputProtectionManagement,
/// The GUID_DEVINTERFACE_VIDEO_OUTPUT_ARRIVAL device interface class is defined for child devices of display devices.
- [Description("1AD9E4F0-F88D-4360-BAB9-4C2D55E564CD")] VideoOutputArrival,
+ [Description("1AD9E4F0-F88D-4360-BAB9-4C2D55E564CD")]
+ VideoOutputArrival,
/// The GUID_DISPLAY_DEVICE_ARRIVAL device interface class is defined for display adapters.
- [Description("1CA05180-A699-450A-9A0C-DE4FBE3DDD89")] DisplayDeviceArrival,
+ [Description("1CA05180-A699-450A-9A0C-DE4FBE3DDD89")]
+ DisplayDeviceArrival,
#endregion // Display and Image Devices
-
+
#region Interactive Input Devices
/// The GUID_DEVINTERFACE_HID device interface class is defined for HID collections.
- [Description("4D1E55B2-F16F-11CF-88CB-001111000030")] Hid,
+ [Description("4D1E55B2-F16F-11CF-88CB-001111000030")]
+ Hid,
/// The GUID_DEVINTERFACE_KEYBOARD device interface class is defined for keyboard devices.
- [Description("4D1E55B2-F16F-11CF-88CB-001111000030")] Keyboard,
+ [Description("4D1E55B2-F16F-11CF-88CB-001111000030")]
+ Keyboard,
/// The GUID_DEVINTERFACE_MOUSE device interface class is defined for mouse devices.
- [Description("378DE44C-56EF-11D1-BC8C-00A0C91405DD")] Mouse,
+ [Description("378DE44C-56EF-11D1-BC8C-00A0C91405DD")]
+ Mouse,
#endregion // Interactive Input Devices
-
+
#region Modem Devices
/// The GUID_DEVINTERFACE_MODEM device interface class is defined for modem devices.
- [Description("2C7089AA-2E0E-11D1-B114-00C04FC2AAE4")] Modem,
+ [Description("2C7089AA-2E0E-11D1-B114-00C04FC2AAE4")]
+ Modem,
#endregion // Modem Devices
-
+
#region Network Devices
/// The GUID_DEVINTERFACE_NET device interface class is defined for network devices.
- [Description("CAC88484-7515-4C03-82E6-71A87ABAC361")] Network,
+ [Description("CAC88484-7515-4C03-82E6-71A87ABAC361")]
+ Network,
#endregion // Network Devices
-
+
#region Serial and Parallel Port Devices
/// The GUID_DEVINTERFACE_COMPORT device interface class is defined for COM ports.
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ComPort")]
- [Description("86E0D1E0-8089-11D0-9CE4-08003E301F73")] ComPort,
+ [Description("86E0D1E0-8089-11D0-9CE4-08003E301F73")]
+ ComPort,
/// The GUID_DEVINTERFACE_PARALLEL device interface class is defined for parallel ports that support an IEEE 1284-compatible hardware interface.
- [Description("97F76EF0-F883-11D0-AF1F-0000F800845C")] Parallel,
+ [Description("97F76EF0-F883-11D0-AF1F-0000F800845C")]
+ Parallel,
/// The GUID_DEVINTERFACE_PARCLASS device interface class is defined for devices that are attached to a parallel port.
- [Description("811FC6A5-F728-11D0-A537-0000F8753ED1")] ParallelClass,
+ [Description("811FC6A5-F728-11D0-A537-0000F8753ED1")]
+ ParallelClass,
/// The GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR device interface class is defined for Plug and Play (PnP) serial ports.
- [Description("4D36E978-E325-11CE-BFC1-08002BE10318")] SerialEnumBusEnumerator,
+ [Description("4D36E978-E325-11CE-BFC1-08002BE10318")]
+ SerialEnumBusEnumerator,
#endregion // Serial and Parallel Port Devices
@@ -156,36 +184,44 @@ public enum DeviceGuid
#region Storage Devices
/// The GUID_DEVINTERFACE_CDCHANGER device interface class is defined for CD-ROM changer devices.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cdrom")]
- [Description("53F56312-B6BF-11D0-94F2-00A0C91EFB8B")] CdromChanger,
+ [Description("53F56312-B6BF-11D0-94F2-00A0C91EFB8B")]
+ CDChanger,
/// The GUID_DEVINTERFACE_CDROM device interface class is defined for CD-ROM storage devices.
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cdrom")]
- [Description("53F56308-B6BF-11D0-94F2-00A0C91EFB8B")] Cdrom,
-
+ [Description("53F56308-B6BF-11D0-94F2-00A0C91EFB8B")]
+ CDRom,
+
/// The GUID_DEVINTERFACE_DISK device interface class is defined for hard disk storage devices.
- [Description("53F56307-B6BF-11D0-94F2-00A0C91EFB8B")] Disk,
+ [Description("53F56307-B6BF-11D0-94F2-00A0C91EFB8B")]
+ Disk,
/// The GUID_DEVINTERFACE_FLOPPY device interface class is defined for floppy disk storage devices.
- [Description("53F56311-B6BF-11D0-94F2-00A0C91EFB8B")] Floppy,
+ [Description("53F56311-B6BF-11D0-94F2-00A0C91EFB8B")]
+ Floppy,
/// The GUID_DEVINTERFACE_MEDIUMCHANGER device interface class is defined for medium changer devices.
- [Description("53F56310-B6BF-11D0-94F2-00A0C91EFB8B")] MediumChanger,
+ [Description("53F56310-B6BF-11D0-94F2-00A0C91EFB8B")]
+ MediumChanger,
/// The GUID_DEVINTERFACE_PARTITION device interface class is defined for partition devices.
- [Description("53F5630A-B6BF-11D0-94F2-00A0C91EFB8B")] Partition,
+ [Description("53F5630A-B6BF-11D0-94F2-00A0C91EFB8B")]
+ Partition,
/// The GUID_DEVINTERFACE_STORAGEPORT device interface class is defined for storage port devices.
- [Description("2ACCFE60-C130-11D2-B082-00A0C91EFB8B")] StoragePort,
+ [Description("2ACCFE60-C130-11D2-B082-00A0C91EFB8B")]
+ StoragePort,
/// The GUID_DEVINTERFACE_TAPE device interface class is defined for tape storage devices.
- [Description("53F5630B-B6BF-11D0-94F2-00A0C91EFB8B")] Tape,
+ [Description("53F5630B-B6BF-11D0-94F2-00A0C91EFB8B")]
+ Tape,
/// The GUID_DEVINTERFACE_VOLUME device interface class is defined for volume devices.
- [Description("53F5630D-B6BF-11D0-94F2-00A0C91EFB8B")] Volume,
+ [Description("53F5630D-B6BF-11D0-94F2-00A0C91EFB8B")]
+ Volume,
/// The GUID_DEVINTERFACE_WRITEONCEDISK device interface class is defined for write-once disk devices.
- [Description("53F5630C-B6BF-11D0-94F2-00A0C91EFB8B")] WriteOnceDisk,
+ [Description("53F5630C-B6BF-11D0-94F2-00A0C91EFB8B")]
+ WriteOnceDisk,
#endregion // Storage Devices
@@ -194,15 +230,18 @@ public enum DeviceGuid
/// The GUID_DEVINTERFACE_USB_DEVICE device interface class is defined for USB devices that are attached to a USB hub.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")]
- [Description("A5DCBF10-6530-11D2-901F-00C04FB951ED")] UsbDevice,
+ [Description("A5DCBF10-6530-11D2-901F-00C04FB951ED")]
+ UsbDevice,
/// The GUID_DEVINTERFACE_USB_HOST_CONTROLLER device interface class is defined for USB host controller devices.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")]
- [Description("3ABF6F2D-71C4-462A-8A92-1E6861E6AF27")] UsbHostController,
+ [Description("3ABF6F2D-71C4-462A-8A92-1E6861E6AF27")]
+ UsbHostController,
/// The GUID_DEVINTERFACE_USB_HUB device interface class is defined for USB hub devices.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")]
- [Description("F18A0E88-C30C-11D0-8815-00A0C906BED8")] UsbHub,
+ [Description("F18A0E88-C30C-11D0-8815-00A0C906BED8")]
+ UsbHub,
#endregion // USB Devices
@@ -212,12 +251,14 @@ public enum DeviceGuid
/// The GUID_DEVINTERFACE_WPD device interface class is defined for Windows Portable Devices (WPD).
/// Available in Windows Vista, Windows XP, and later versions of Windows.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wpd")]
- [Description("6AC27878-A6FA-4155-BA85-F98F491D4F33")] Wpd,
+ [Description("6AC27878-A6FA-4155-BA85-F98F491D4F33")]
+ Wpd,
/// The GUID_DEVINTERFACE_WPD_PRIVATE device interface class is defined for specialized Windows Portable Devices (WPD).
/// Available in Windows Vista, Windows XP, and later versions of Windows.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wpd")]
- [Description("BA0C718F-4DED-49B7-BDD3-FABE28661211")] WpdPrivate
+ [Description("BA0C718F-4DED-49B7-BDD3-FABE28661211")]
+ WpdPrivate
#endregion // Windows Portable devices
}
diff --git a/AlphaFS/Device/Structures, Enumerations/DeviceType.cs b/AlphaFS/Device/Structures, Enumerations/DeviceType.cs
new file mode 100644
index 000000000..2de95cf40
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/DeviceType.cs
@@ -0,0 +1,280 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// The type of device. Values from 0 through 32,767 are reserved for use by Microsoft. Values from 32,768 through 65,535 are reserved for use by other vendors.
+ /// The following values are defined by Microsoft.
+ [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags", Justification = "Enum values should not be combinable.")]
+ public enum DeviceType
+ {
+ /// Indicates an unknown storage device type.
+ None = 0,
+
+ /// BEEP parameter.
+ Beep = NativeMethods.FILE_DEVICE.BEEP,
+
+ /// CD_ROM parameter.
+ CDRom = NativeMethods.FILE_DEVICE.CD_ROM, // .NET DriveInfo.DriveType property also uses "CDRom" instead of "CdRom".
+
+ /// CD_ROM_FILE_SYSTEM parameter.
+ CDRomFileSystem = NativeMethods.FILE_DEVICE.CD_ROM_FILE_SYSTEM,
+
+ /// CONTROLLER parameter.
+ Controller = NativeMethods.FILE_DEVICE.CONTROLLER,
+
+ /// DATALINK parameter.
+ DataLink = NativeMethods.FILE_DEVICE.DATALINK,
+
+ /// DFS parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")]
+ Dfs = NativeMethods.FILE_DEVICE.DFS,
+
+ /// DISK parameter.
+ Disk = NativeMethods.FILE_DEVICE.DISK,
+
+ /// DISK_FILE_SYSTEM parameter.
+ DiskFileSystem = NativeMethods.FILE_DEVICE.DISK_FILE_SYSTEM,
+
+ /// FILE_SYSTEM parameter.
+ FileSystem = NativeMethods.FILE_DEVICE.FILE_SYSTEM,
+
+ /// INPORT_PORT parameter.
+ InPort = NativeMethods.FILE_DEVICE.INPORT_PORT,
+
+ /// KEYBOARD parameter.
+ Keyboard = NativeMethods.FILE_DEVICE.KEYBOARD,
+
+ /// MAILSLOT parameter.
+ MailSlot = NativeMethods.FILE_DEVICE.MAILSLOT,
+
+ /// MIDI_IN parameter.
+ MidiIn = NativeMethods.FILE_DEVICE.MIDI_IN,
+
+ /// MIDI_OUT parameter.
+ MidiOut = NativeMethods.FILE_DEVICE.MIDI_OUT,
+
+ /// MOUSE parameter.
+ Mouse = NativeMethods.FILE_DEVICE.MOUSE,
+
+ /// MULTI_UNC_PROVIDER parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")]
+ MultiUncProvider = NativeMethods.FILE_DEVICE.MULTI_UNC_PROVIDER,
+
+ /// NAMED_PIPE parameter.
+ NamedPipe = NativeMethods.FILE_DEVICE.NAMED_PIPE,
+
+ /// NETWORK parameter.
+ Network = NativeMethods.FILE_DEVICE.NETWORK,
+
+ /// NETWORK_BROWSER parameter.
+ NetworkBrowser = NativeMethods.FILE_DEVICE.NETWORK_BROWSER,
+
+ /// NETWORK_FILE_SYSTEM parameter.
+ NetworkFileSystem = NativeMethods.FILE_DEVICE.NETWORK_FILE_SYSTEM,
+
+ /// NULL parameter.
+ NullDevice = NativeMethods.FILE_DEVICE.NULL,
+
+ /// PARALLEL_PORT parameter.
+ ParallelPort = NativeMethods.FILE_DEVICE.PARALLEL_PORT,
+
+ /// PHYSICAL_NETCARD parameter.
+ PhysicalNetCard = NativeMethods.FILE_DEVICE.PHYSICAL_NETCARD,
+
+ /// PRINTER parameter.
+ Printer = NativeMethods.FILE_DEVICE.PRINTER,
+
+ /// SCANNER parameter.
+ Scanner = NativeMethods.FILE_DEVICE.SCANNER,
+
+ /// SERIAL_MOUSE_PORT parameter.
+ SerialMousePort = NativeMethods.FILE_DEVICE.SERIAL_MOUSE_PORT,
+
+ /// SERIAL_PORT parameter.
+ SerialPort = NativeMethods.FILE_DEVICE.SERIAL_PORT,
+
+ /// SCREEN parameter.
+ Screen = NativeMethods.FILE_DEVICE.SCREEN,
+
+ /// SOUND parameter.
+ Sound = NativeMethods.FILE_DEVICE.SOUND,
+
+ /// STREAMS parameter.
+ Streams = NativeMethods.FILE_DEVICE.STREAMS,
+
+ /// TAPE parameter.
+ Tape = NativeMethods.FILE_DEVICE.TAPE,
+
+ /// TAPE_FILE_SYSTEM parameter.
+ TapeFileSystem = NativeMethods.FILE_DEVICE.TAPE_FILE_SYSTEM,
+
+ /// TRANSPORT parameter.
+ Transport = NativeMethods.FILE_DEVICE.TRANSPORT,
+
+ /// UNKNOWN parameter.
+ Unknown = NativeMethods.FILE_DEVICE.UNKNOWN,
+
+ /// VIDEO parameter.
+ Video = NativeMethods.FILE_DEVICE.VIDEO,
+
+ /// VIRTUAL_DISK parameter.
+ VirtualDisk = NativeMethods.FILE_DEVICE.VIRTUAL_DISK,
+
+ /// WAVE_IN parameter.
+ WaveIn = NativeMethods.FILE_DEVICE.WAVE_IN,
+
+ /// WAVE_OUT parameter.
+ WaveOut = NativeMethods.FILE_DEVICE.WAVE_OUT,
+
+ /// 8042_PORT parameter.
+ Port8042 = NativeMethods.FILE_DEVICE.PORT_8042,
+
+ /// NETWORK_REDIRECTOR parameter.
+ NetworkRedirector = NativeMethods.FILE_DEVICE.NETWORK_REDIRECTOR,
+
+ /// BATTERY parameter.
+ Battery = NativeMethods.FILE_DEVICE.BATTERY,
+
+ /// BUS_EXTENDER parameter.
+ BusExtender = NativeMethods.FILE_DEVICE.BUS_EXTENDER,
+
+ /// MODEM parameter.
+ Modem = NativeMethods.FILE_DEVICE.MODEM,
+
+ /// VDM parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vdm")]
+ Vdm = NativeMethods.FILE_DEVICE.VDM,
+
+ /// MASS_STORAGE parameter.
+ MassStorage = NativeMethods.FILE_DEVICE.MASS_STORAGE,
+
+ /// SMB parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Smb")]
+ Smb = NativeMethods.FILE_DEVICE.SMB,
+
+ /// KS parameter.
+ KS = NativeMethods.FILE_DEVICE.KS,
+
+ /// CHANGER parameter.
+ Changer = NativeMethods.FILE_DEVICE.CHANGER,
+
+ /// SMARTCARD parameter.
+ Smartcard = NativeMethods.FILE_DEVICE.SMARTCARD,
+
+ /// ACPI parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Acpi")]
+ Acpi = NativeMethods.FILE_DEVICE.ACPI,
+
+ /// DVD parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dvd")]
+ Dvd = NativeMethods.FILE_DEVICE.DVD,
+
+ /// FULLSCREEN_VIDEO parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Fullscreen")]
+ FullscreenVideo = NativeMethods.FILE_DEVICE.FULLSCREEN_VIDEO,
+
+ /// DFS_FILE_SYSTEM parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")]
+ DfsFileSystem = NativeMethods.FILE_DEVICE.DFS_FILE_SYSTEM,
+
+ /// DFS_VOLUME parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")]
+ DfsVolume = NativeMethods.FILE_DEVICE.DFS_VOLUME,
+
+ /// SERENUM parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Serenum")]
+ Serenum = NativeMethods.FILE_DEVICE.SERENUM,
+
+ /// TERMSRV parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Termsrv")]
+ Termsrv = NativeMethods.FILE_DEVICE.TERMSRV,
+
+ /// KSEC parameter.
+ KSec = NativeMethods.FILE_DEVICE.KSEC,
+
+ /// FIPS parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Fips")]
+ Fips = NativeMethods.FILE_DEVICE.FIPS,
+
+ /// INFINIBAND parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infiniband")]
+ Infiniband = NativeMethods.FILE_DEVICE.INFINIBAND,
+
+ /// VMBUS parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Vm")]
+ VmBus = NativeMethods.FILE_DEVICE.VMBUS,
+
+ /// CRYPT_PROVIDER parameter.
+ CryptProvider = NativeMethods.FILE_DEVICE.CRYPT_PROVIDER,
+
+ /// WPD parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wpd")]
+ Wpd = NativeMethods.FILE_DEVICE.WPD,
+
+ /// BLUETOOTH parameter.
+ Bluetooth = NativeMethods.FILE_DEVICE.BLUETOOTH,
+
+ /// MT_COMPOSITE parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mt")]
+ MtComposite = NativeMethods.FILE_DEVICE.MT_COMPOSITE,
+
+ /// MT_TRANSPORT parameter.
+ MTTransport = NativeMethods.FILE_DEVICE.MT_TRANSPORT,
+
+ /// BIOMETRIC parameter.
+ Biometric = NativeMethods.FILE_DEVICE.BIOMETRIC,
+
+ /// PMI parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pmi")]
+ Pmi = NativeMethods.FILE_DEVICE.PMI,
+
+ /// EHSTOR parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ehstor")]
+ Ehstor = NativeMethods.FILE_DEVICE.EHSTOR,
+
+ /// DEVAPI parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Devapi")]
+ Devapi = NativeMethods.FILE_DEVICE.DEVAPI,
+
+ /// GPIO parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpio")]
+ Gpio = NativeMethods.FILE_DEVICE.GPIO,
+
+ /// USBEX parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usbex")]
+ Usbex = NativeMethods.FILE_DEVICE.USBEX,
+
+ /// CONSOLE parameter.
+ Console = NativeMethods.FILE_DEVICE.CONSOLE,
+
+ /// NFP parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nfp")]
+ Nfp = NativeMethods.FILE_DEVICE.NFP,
+
+ /// SYSENV parameter.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sysenv")]
+ Sysenv = NativeMethods.FILE_DEVICE.SYSENV
+ }
+}
diff --git a/AlphaFS/Device/Structures, Enumerations/DiskPartitionType.cs b/AlphaFS/Device/Structures, Enumerations/DiskPartitionType.cs
new file mode 100644
index 000000000..a4524a9ff
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/DiskPartitionType.cs
@@ -0,0 +1,124 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// Valid partition types that are used by disk drivers.
+ /// https://technet.microsoft.com/en-us/library/cc739412.aspx
+ public enum DiskPartitionType
+ {
+ /// Unused partition entry.
+ UnusedEntry = NativeMethods.DiskPartitionType.PARTITION_ENTRY_UNUSED,
+
+ /// DOS FAT12 primary partition or logical drive (fewer than 32,680 sectors in the volume).
+ Fat12 = NativeMethods.DiskPartitionType.PARTITION_FAT_12,
+
+ /// A XENIX root partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xenix")]
+ XenixRoot = 2,
+
+ /// A XENIX /usr partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xenix")]
+ XenixUser = 3,
+
+ /// DOS 3.0+ FAT16 partition or logical drive (32,680�65,535 sectors or 16 MB�33 MB).
+ Fat16 = NativeMethods.DiskPartitionType.PARTITION_FAT_16,
+
+ /// DOS 3.3+ Extended partition.
+ Extended = NativeMethods.DiskPartitionType.PARTITION_EXTENDED,
+
+ /// DOS 3.31+ BIGDOS FAT16 partition or logical drive (33 MB�4 GB).
+ Fat16B = 6,
+
+ /// Installable File System (IFS). NTFS partition or logical drive.
+ Ifs = NativeMethods.DiskPartitionType.PARTITION_IFS,
+
+ /// FAT32 partition or logical drive.
+ Fat32 = NativeMethods.DiskPartitionType.PARTITION_FAT32,
+
+ /// FAT32 partition or logical drive using BIOS INT 13h extensions.
+ Fat32Int13 = 12,
+
+ /// BIGDOS FAT16 partition or logical drive using BIOS INT 13h extensions
+ Fat16BInt13 = 14,
+
+ /// Extended partition using BIOS INT 13h extensions
+ ExtendedInt13 = 15,
+
+ /// EISA partition or OEM partition
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Eisa")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Oem")]
+ EisaOem = 18,
+
+ /// A PC PReP (Power PC Reference Platform) Boot partition.
+ Prep = 65,
+
+ /// LDM (Logical Disk Manager) Data partition on a dynamic disk.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ldm")]
+ Ldm = NativeMethods.DiskPartitionType.PARTITION_LDM,
+
+ /// SCO Unix, ISC, UnixWare, AT+T System V/386, ix, MtXinu BSD 4.3 on Mach, GNU HURD.
+ Unix = 99,
+
+ /// An NTFT partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ntft")]
+ Ntft = NativeMethods.DiskPartitionType.PARTITION_NTFT,
+
+ /// Power management hibernation partition.
+ PowerManagementHibernation = 132,
+
+ /// Multidisk FAT16 volume created by using Windows NT 4.0
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")]
+ Fat16MultiDisk = 134,
+
+ /// Multidisk NTFS volume created by using Windows NT 4.0
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")]
+ NtfsMultiDisk = 135,
+
+ /// Laptop hibernation partition
+ LaptopHibernation = 160,
+
+ /// A valid NTFT partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ntft")]
+ ValidNtft = NativeMethods.DiskPartitionType.VALID_NTFT,
+
+ /// Dell OEM partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Oem")]
+ DellOem = 222,
+
+ /// IBM OEM partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ibm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Oem")]
+ IbmOem = 254,
+
+ /// GPT partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ Gpt = 238,
+
+ /// EFI System partition on an MBR disk.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Efi")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mbr")]
+ EfiSystemOnMbr = 239
+
+ }
+}
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/DosDeviceAttributes.cs b/AlphaFS/Device/Structures, Enumerations/DosDeviceAttributes.cs
similarity index 98%
rename from AlphaFS/Filesystem/Structures, Enumerations/DosDeviceAttributes.cs
rename to AlphaFS/Device/Structures, Enumerations/DosDeviceAttributes.cs
index 8a1994e3b..2e06e0874 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/DosDeviceAttributes.cs
+++ b/AlphaFS/Device/Structures, Enumerations/DosDeviceAttributes.cs
@@ -18,9 +18,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
using System;
-namespace Alphaleonis.Win32.Filesystem
+namespace Alphaleonis.Win32.Device
{
/// Defines the controllable aspects of the Volume.DefineDosDevice() method.
[Flags]
diff --git a/AlphaFS/Device/Structures, Enumerations/EfiPartitionAttributes.cs b/AlphaFS/Device/Structures, Enumerations/EfiPartitionAttributes.cs
new file mode 100644
index 000000000..d727e54fe
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/EfiPartitionAttributes.cs
@@ -0,0 +1,54 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// The Extensible Firmware Interface (EFI) partition attributes.
+ [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Efi")]
+ [Flags]
+ public enum EfiPartitionAttributes
+ {
+ /// None.
+ None = 0,
+
+ /// If this attribute is set, the partition is required by a Computer to function properly.
+ PlatformRequired,
+
+ /// If this attribute is set, the partition is an MBR partition.
+ BiosBoot = 4,
+
+ /// If this attribute is set, the partition is read-only.
+ ReadOnly,
+
+ /// If this attribute is set, the partition is a shadow copy of another partition.
+ ShadowCopy,
+
+ /// If this attribute is set, the partition is not detected by the Mount Manager.
+ Hidden,
+
+ /// If this attribute is set, the partition does not receive a drive letter by default when the disk is moved to another Computer or when the disk is seen for the first time by a Computer.
+ NoDriveLetter
+ }
+}
diff --git a/AlphaFS/Device/Structures, Enumerations/PartitionStyle.cs b/AlphaFS/Device/Structures, Enumerations/PartitionStyle.cs
new file mode 100644
index 000000000..09fabf9fe
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/PartitionStyle.cs
@@ -0,0 +1,44 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// Represents the format of a partition.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only]
+ /// Minimum supported server: Windows Server 2003 [desktop apps only]
+ ///
+ public enum PartitionStyle
+ {
+ /// Master boot record (MBR) format. This corresponds to standard AT-style MBR partitions.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mbr")]
+ Mbr = NativeMethods.PARTITION_STYLE.PARTITION_STYLE_MBR,
+
+ /// GUID Partition Table (GPT) format.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpt")]
+ Gpt = NativeMethods.PARTITION_STYLE.PARTITION_STYLE_GPT,
+
+ /// Partition not formatted in either of the recognized formats; MBR or GPT.
+ Raw = NativeMethods.PARTITION_STYLE.PARTITION_STYLE_RAW
+ }
+}
diff --git a/AlphaFS/Device/Structures, Enumerations/PartitionType..cs b/AlphaFS/Device/Structures, Enumerations/PartitionType..cs
new file mode 100644
index 000000000..c767a8590
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/PartitionType..cs
@@ -0,0 +1,874 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// Specifies the different types of partition GUIDs.
+ /// https://en.wikipedia.org/wiki/GUID_Partition_Table
+ ///
+ public enum PartitionType
+ {
+ /// There is no partition or the partition is an unused entry.
+ /// This value can be set for basic and dynamic disks.
+ [Description("00000000-0000-0000-0000-000000000000")]
+ None = 0,
+
+
+ #region Non-OS
+
+ ///// There is no partition.
+ ///// This value can be set for basic and dynamic disks.
+ //[Description("00000000-0000-0000-0000-000000000000")]
+ //UnusedEntry,
+
+ /// Legacy MBR partition. A partition that is sub-partitioned by a Master Boot Record; "partitions-inside-a-slice configuration".
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mbr")]
+ [Description("024DEE41-33E7-11D3-9D69-0008C781F39F")]
+ LegacyMbr,
+
+ /// The partition is an EFI system partition.
+ /// This value can be set for basic and dynamic disks.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Efi")]
+ [Description("C12A7328-F81F-11D2-BA4B-00A0C93EC93B")]
+ EfiSystem,
+
+ /// BIOS boot partition.
+ [Description("21686148-6449-6E6F-744E-656564454649F")]
+ BiosBoot,
+
+ /// Intel Fast Flash (iFFS, Intel Rapid Start technology) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Iffs")]
+ [Description("D3BFE2DE-3DAF-11DF-BA40-E3A556D89593")]
+ Iffs,
+
+ /// Sony boot partition.
+ [Description("F4019732-066E-4E12-8273-346C5641494F")]
+ SonyBoot,
+
+ /// Lenovo boot partition.
+ [Description("BFBFAFE7-A34F-448A-9A5B-6213EB736C22")]
+ LenovoBoot,
+
+ #endregion // Non-OS
+
+
+ #region Windows
+
+ /// The partition is a Microsoft reserved partition.
+ /// This value can be set for basic and dynamic disks.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Msft")]
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("E3C9E316-0B5C-4DB8-817D-F92DF00215AE")]
+ MsftReserved,
+
+ /// The data partition type that is created and recognized by Windows.
+ ///
+ /// This value can be set only for basic disks, with one exception.
+ /// Only partitions of this type can be assigned drive letters, receive volume paths, host mounted folders (also called volume mount points), and be enumerated by calls to FindFirstVolume and FindNextVolume.
+ ///
+ [Description("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7")]
+ BasicData,
+
+ /// The partition is a Logical Disk Manager (LDM) metadata partition on a dynamic disk.
+ /// This value can be set only for dynamic disks.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ldm")]
+ [Description("5808C8AA-7E8F-42E0-85D2-E1E90434CFB3")]
+ LdmMetadata,
+
+ /// The partition is an LDM data partition on a dynamic disk.
+ /// This value can be set only for dynamic disks.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ldm")]
+ [Description("AF9B60A0-1431-4F62-BC68-3311714A69AD")]
+ LdmData,
+
+ /// The partition is a Microsoft recovery partition.
+ /// This value can be set for basic and dynamic disks.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Msft")]
+ [Description("DE94BBA4-06D1-4D40-A16A-BFD50179D6AC")]
+ MsftRecovery,
+
+ /// IBM General Parallel File System (GPFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ibm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpfs")]
+ [Description("37AFFC90-EF7D-4E96-91C3-2D7AE055B174")]
+ IbmGpfs,
+
+ /// Storage Spaces partition.
+ [Description("E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D")]
+ StorageSpace,
+
+ #endregion // Windows
+
+
+ #region HP-UX
+
+ /// HP-UX Data partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ux")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hp")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ux")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Hp")]
+ [Description("75894C1E-3AEB-11D3-B7C1-7B03A0000000")]
+ HpUxData,
+
+ /// HP-UX Service partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ux")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ux")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hp")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Hp")]
+ [Description("E2A1E728-32E3-11D6-A682-7B03A0000000")]
+ HpUxService,
+
+ #endregion // HP-UX
+
+
+ #region Linux
+
+ /// Linux filesystem data partition.
+ [Description("0FC63DAF-8483-4772-8E79-3D69D8477DE4")]
+ LinuxData,
+
+ /// Linux RAID partition.
+ [Description("A19D880F-05FC-4D3B-A006-743F0F84911E")]
+ LinuxRaid,
+
+ /// Linux Root (x86) partition.
+ [Description("44479540-F297-41B2-9AF7-D131D5F0458A")]
+ LinuxRootX86,
+
+ /// Linux Root (x86-64) partition.
+ [Description("4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709")]
+ LinuxRootX8664,
+
+ /// Linux Root (32bit ARM) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "bit")]
+ [Description("69DAD710-2CE4-4E3C-B16C-21A1D49ABED3")]
+ LinuxRoot32bitArm,
+
+ /// Linux Root (64bit ARM/AArch64) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "bit")]
+ [Description("B921B045-1DF0-41C3-AF44-4C6F280D3FAE")]
+ LinuxRoot64bitArm,
+
+ /// Linux Swap partition.
+ [Description("0657FD6D-A4AB-43C4-84E5-0933C84B4F4F")]
+ LinuxSwap,
+
+ /// Linux Logical Volume Manager(LVM) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lvm")]
+ [Description("E6D6D379-F507-44C2-A23C-238F2A3DF928")]
+ LinuxLvm,
+
+ /// LinuxLinux /home partition.
+ [Description("933AC7E1-2EB4-4F13-B844-0E14E2AEF915")]
+ LinuxHome,
+
+ /// Linux /srv (server data) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Srv")]
+ [Description("3B8F8425-20E0-4F3B-907F-1A25A76F98E8")]
+ LinuxSrv,
+
+ /// Linux Plain dm-crypt partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("7FFEC5C9-2D00-49B7-8941-3EA10A5586B7")]
+ LinuxPlainDmCrypt,
+
+ /// Linux LUKS partition.
+ [Description("CA7D7CCB-63ED-4C53-861C-1742536059CC")]
+ LinuxLuks,
+
+ /// Linux Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("8DA63339-0007-60C0-C436-083AC8230908")]
+ LinuxReserved,
+
+ #endregion // Linux
+
+
+ #region FreeBSD
+
+ /// FreeBSD Boot partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("83BD6B9D-7F41-11DC-BE0B-001560B84F0F")]
+ FreeBsdBoot,
+
+ /// FreeBSD Data partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("516E7CB4-6ECF-11D6-8FF8-00022D09712B")]
+ FreeBsdData,
+
+ /// FreeBSD Swap partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("516E7CB5-6ECF-11D6-8FF8-00022D09712B")]
+ FreeBsdSwap,
+
+ /// FreeBSD Unix File System (UFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ufs")]
+ [Description("516E7CB6-6ECF-11D6-8FF8-00022D09712B")]
+ FreeBsdUfs,
+
+ /// FreeBSD Vinum Volume Manager partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vvm")]
+ [Description("516E7CB8-6ECF-11D6-8FF8-00022D09712B")]
+ FreeBsdVvm,
+
+ /// FreeBSD ZFS partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zfs")]
+ [Description("516E7CBA-6ECF-11D6-8FF8-00022D09712B")]
+ FreeBsdZfs,
+
+ #endregion // FreeBSD
+
+
+ #region MacOS Darwin
+
+ /// OSX Hierarchical File System Plus (HFS+) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hfs")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [Description("48465300-0000-11AA-AA11-00306543ECAC")]
+ OsXHfs,
+
+ /// OSX Apple APFS partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Apfs")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("7C3457EF-0000-11AA-AA11-00306543ECAC")]
+ OsXAppleApfs,
+
+ /// OSX Apple UFS partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ufs")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [Description("55465300-0000-11AA-AA11-00306543ECAC")]
+ OsXAppleUfs,
+
+ /// OSX ZFS partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zfs")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("6A898CC3-1DD2-11B2-99A6-080020736631")]
+ OsXZfs,
+
+ /// OSX Apple RAID partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [Description("52414944-0000-11AA-AA11-00306543ECAC")]
+ OsXAppleRaid,
+
+ /// OSX Apple RAID offline partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("52414944-5F4F-11AA-AA11-00306543ECAC")]
+ OsXAppleRaidOffline,
+
+ /// OSX Apple Boot (Recovery HD) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [Description("426F6F74-0000-11AA-AA11-00306543ECAC")]
+ OsXBootRecovery,
+
+ /// OSX Apple Label partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("C616265-6C00-11AA-AA11-00306543ECAC")]
+ OsXLabel,
+
+ /// OSX Apple TV Recovery partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tv")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Tv")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("5265636F-7665-11AA-AA11-00306543ECAC")]
+ OsXTvRecovery,
+
+ /// OSX Apple Core Storage (i.e. Lion FileVault) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("53746F72-6167-11AA-AA11-00306543ECAC")]
+ OsXCoreStorage,
+
+ /// OSX SoftRAID_Status partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("B6FA30DA-92D2-4A9A-96F1-871EC6486200")]
+ OsXSoftRaidStatus,
+
+ /// OSX SoftRAID_Scratch partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("2E313465-19B9-463F-8126-8A7993773801")]
+ OsXSoftRaidScratch,
+
+ /// OSX SoftRAID_Volume partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("FA709C7E-65B1-4593-BFD5-E71D61DE9B02")]
+ OsXSoftRaidVolume,
+
+ /// OSX SoftRAID_Cache partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [Description("BBBA6DF5-F46F-4A89-8F59-8765B2727503")]
+ OsXSoftRaidCache,
+
+ #endregion // MacOS Darwin
+
+
+ #region Solaris Illumos
+
+ /// Solaris Boot partition.
+ [Description("6A82CB45-1DD2-11B2-99A6-080020736631")]
+ SolarisBoot,
+
+ /// Solaris Root partition.
+ [Description("6A85CF4D-1DD2-11B2-99A6-080020736631")]
+ SolarisRoot,
+
+ /// Solaris Swap partition.
+ [Description("6A87C46F-1DD2-11B2-99A6-080020736631")]
+ SolarisSwap,
+
+ /// Solaris Backup partition.
+ [Description("6A8B642B-1DD2-11B2-99A6-080020736631")]
+ SolarisBackup,
+
+ /// Solaris /usr partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usr")]
+ [Description("6A898CC3-1DD2-11B2-99A6-080020736631")]
+ SolarisUsr,
+
+ /// Solaris /var partition.
+ [Description("6A8EF2E9-1DD2-11B2-99A6-080020736631")]
+ SolarisVar,
+
+ /// Solaris /home partition.
+ [Description("6A90BA39-1DD2-11B2-99A6-080020736631")]
+ SolarisHome,
+
+ /// Solaris Alternate sector partition.
+ [Description("6A9283A5-1DD2-11B2-99A6-080020736631")]
+ SolarisAlternateSector,
+
+ /// Solaris Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("6A945A3B-1DD2-11B2-99A6-080020736631")]
+ SolarisReserved1,
+
+ /// Solaris Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("6A9630D1-1DD2-11B2-99A6-080020736631")]
+ SolarisReserved2,
+
+ /// Solaris Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("6A980767-1DD2-11B2-99A6-080020736631")]
+ SolarisReserved3,
+
+ /// Solaris Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("6A96237F-1DD2-11B2-99A6-080020736631")]
+ SolarisReserved4,
+
+ /// Solaris Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("6A8D2AC7-1DD2-11B2-99A6-080020736631")]
+ SolarisReserved5,
+
+ #endregion // Solaris Illumos
+
+
+ #region NetBSD
+
+ /// NetBSD Swap partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("6A82CB45-1DD2-11B2-99A6-080020736631")]
+ NetBsdSwap,
+
+ /// NetBSD Fast File System (FFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ffs")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("49F48D5A-B10E-11DC-B99B-0019D1879648")]
+ NetBsdFfs,
+
+ /// NetBSD Log-Structured File System (LFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lfs")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("49F48D82-B10E-11DC-B99B-0019D1879648")]
+ NetBsdLfs,
+
+ /// NetBSD RAID partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("49F48DAA-B10E-11DC-B99B-0019D1879648")]
+ NetBsdRaid,
+
+ /// NetBSD Concatenated partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("2DB519C4-B10F-11DC-B99B-0019D1879648")]
+ NetBsdConcatenated,
+
+ /// NetBSD Encrypted partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("2DB519EC-B10F-11DC-B99B-0019D1879648")]
+ NetBsdEncrypted,
+
+ #endregion // NetBSD
+
+
+ #region Chrome OS
+
+ /// Chrome OS Kernel partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("FE3A2A5D-4F32-41A7-B725-ACCC3285A309")]
+ ChromeOsKernel,
+
+ /// Chrome OS RootFS partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Fs")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Fs")]
+ [Description("3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC")]
+ ChromeOsRootFs,
+
+ /// Chrome OS (future use) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [Description("2E0A753D-9E48-43B0-8337-B15192CB1B5E")]
+ ChromeOsFutureUse,
+
+ #endregion // Chrome OS
+
+
+ #region Haiku
+
+ /// Haiku Be File System (BFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bfs")]
+ [Description("42465331-3BA3-10F1-802A-4861696B7521")]
+ HaikuBfs,
+
+ #endregion // Haiku
+
+
+ #region MidnightBSD
+
+ /// MidnightBSD Boot partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("85D5E45E-237C-11E1-B4B3-E89A8F7FC3A7")]
+ MidnightBsdBoot,
+
+ /// MidnightBSD Data partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("85D5E45A-237C-11E1-B4B3-E89A8F7FC3A7")]
+ MidnightBsdData,
+
+ /// MidnightBSD Swap partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("85D5E45B-237C-11E1-B4B3-E89A8F7FC3A7")]
+ MidnightBsdSwap,
+
+ /// MidnightBSD Unix File System (UFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ufs")]
+ [Description("0394EF8B-237E-11E1-B4B3-E89A8F7FC3A7")]
+ MidnightBsdUfs,
+
+ /// MidnightBSD Vinum Volume Manager partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vvm")]
+ [Description("85D5E45C-237C-11E1-B4B3-E89A8F7FC3A7")]
+ MidnightBsdVvm,
+
+ /// MidnightBSD ZFS partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zfs")]
+ [Description("85D5E45D-237C-11E1-B4B3-E89A8F7FC3A7")]
+ MidnightBsdZfs,
+
+ #endregion // MidnightBSD
+
+
+ #region Ceph
+
+ /// Ceph journal partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("45B0969E-9B03-4F30-B4C6-B4B80CEFF106")]
+ CephJournal,
+
+ /// Ceph dm-crypt journal partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [Description("45B0969E-9B03-4F30-B4C6-5EC00CEFF106")]
+ CephDmCryptJournal,
+
+ /// Ceph OSD partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Osd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D")]
+ CephOsd,
+
+ /// Ceph dm-crypt OSD partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Osd")]
+ [Description("4FBD7E29-9D25-41B8-AFD0-5EC00CEFF05D")]
+ CephDmCryptOsd,
+
+ /// Ceph disk in creation partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("89C57F98-2FE5-4DC0-89C1-F3AD0CEFF2BE")]
+ CephDiskInCreation,
+
+ /// Ceph dm-crypt disk in creation partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("89C57F98-2FE5-4DC0-89C1-5EC00CEFF2BE")]
+ CephDmCryptDiskInCreation,
+
+ /// Ceph block partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("CAFECAFE-9B03-4F30-B4C6-B4B80CEFF106")]
+ CephBlock,
+
+ /// Ceph block DB partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("30CD0809-C2B2-499C-8879-2D6B78529876")]
+ CephBlockDb,
+
+ /// Ceph block write-ahead log partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("5CE17FCE-4087-4169-B7FF-056CC58473F9")]
+ CephBlockWriteAheadLog,
+
+ /// Ceph lockbox for dm-crypt keys partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("FB3AABF9-D25F-47CC-BF5E-721D1816496B")]
+ CephDmCryptKeysLockbox,
+
+ /// Ceph multipath OSD partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Osd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("4FBD7E29-8AE0-4982-BF9D-5A8D867AF560")]
+ CephMultipathOsd,
+
+ /// Ceph multipath journal partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("45B0969E-8AE0-4982-BF9D-5A8D867AF560")]
+ CephMultipathJournal,
+
+ /// Ceph multipath block partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("CAFECAFE-8AE0-4982-BF9D-5A8D867AF560")]
+ CephMultipathBlock1,
+
+ /// Ceph multipath block partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("7F4A666A-16F3-47A2-8445-152EF4D03F6C")]
+ CephMultipathBlock2,
+
+ /// Ceph multipath block DB partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("EC6D6385-E346-45DC-BE91-DA2A7C8B3261")]
+ CephMultipathBlockDb,
+
+ /// Ceph multipath block write-ahead log partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [Description("01B41E1B-002A-453C-9F17-88793989FF8F")]
+ CephMultipathBlockWriteAheadLog,
+
+ /// Ceph dm-crypt block partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("CAFECAFE-9B03-4F30-B4C6-5EC00CEFF106")]
+ CephDmCryptBlock,
+
+ /// Ceph dm-crypt block DB partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("93B0052D-02D9-4D8A-A43B-33A3EE4DFBC3")]
+ CephDmCryptBlockDb,
+
+ /// Ceph dm-crypt block write-ahead log partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("306E8683-4FE2-4330-B7C0-00A917C16966")]
+ CephDmCryptBlockWriteAheadLog,
+
+ /// Ceph dm-crypt LUKS journal partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("45B0969E-9B03-4F30-B4C6-35865CEFF106")]
+ CephDmCryptLuksJournal,
+
+ /// Ceph dm-crypt LUKS block partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("CAFECAFE-9B03-4F30-B4C6-35865CEFF106")]
+ CephDmCryptLuksBlock,
+
+ /// Ceph dm-crypt LUKS block DB partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("166418DA-C469-4022-ADF4-B30AFD37F176")]
+ CephDmCryptLuksBlockDb,
+
+ /// Ceph dm-crypt LUKS block write-ahead log partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("166418DA-C469-4022-ADF4-B30AFD37F176")]
+ CephDmCryptLuksBlockWriteAheadLog,
+
+ /// Ceph dm-crypt LUKS OSD partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ceph")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Osd")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dm")]
+ [Description("166418DA-C469-4022-ADF4-B30AFD37F176")]
+ CephDmCryptLuksOsd,
+
+ #endregion // Ceph
+
+
+ #region OpenBSD
+
+ /// OpenBSD Data partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bsd")]
+ [Description("824CC7A0-36A8-11E3-890A-952519AD3F61")]
+ OpenBsdData,
+
+ #endregion // OpenBSD
+
+
+ #region QNX
+
+ /// QNX Power-safe (QNX6) file system partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qnx")]
+ [Description("CEF5A9AD-73BC-4601-89F3-CDEEEEE321A1")]
+ Qnx6,
+
+ #endregion // QNX
+
+
+ #region Plan 9
+
+ /// Plan 9 partition.
+ [Description("C91818F9-8025-47AF-89D2-F030D7000C2C")]
+ Plan9,
+
+ #endregion // Plan 9
+
+
+ #region VMware ESX
+
+ /// VMware ESX vmkcore (coredump) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Esx")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Vm")]
+ [Description("9D275380-40AD-11DB-BF97-000C2911D1B8")]
+ VmWareEsxCore,
+
+ /// VMware ESX Virtual Machine File System (VMFS) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vmfs")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Esx")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Vm")]
+ [Description("AA31E02A-400F-11DB-9590-000C2911D1B8")]
+ VmWareEsxVmfs,
+
+ /// VMware ESX Reserved partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Esx")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Vm")]
+ [SuppressMessage("Microsoft.Naming", "CA1700:DoNotNameEnumValuesReserved")]
+ [Description("9198EFFC-31C0-11DB-8F78-000C2911D1B8")]
+ VmWareEsxReserved,
+
+ #endregion // VMware ESX
+
+
+ #region Android-IA
+
+ /// Android-IA Bootloader partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bootloader")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("2568845D-2332-4675-BC39-8FA5A4748D15")]
+ AndroidIaBootloader,
+
+ /// Android-IA Bootloader2 partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bootloader")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("114EAFFE-1552-4022-B26E-9B053604CF84")]
+ AndroidIaBootloader2,
+
+ /// Android-IA Boot partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("49A4D17F-93A3-45C1-A0DE-F50B2EBE2599")]
+ AndroidIaBoot,
+
+ /// Android-IA Recovery partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("4177C722-9E92-4AAB-8644-43502BFD5506")]
+ AndroidIaRecovery,
+
+ /// Android-IA Misc partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("EF32A33B-A409-486C-9141-9FFB711F6266")]
+ AndroidIaMisc,
+
+ /// Android-IA Metadata partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("20AC26BE-20B7-11E3-84C5-6CFDB94711E9")]
+ AndroidIaMetadata,
+
+ /// Android-IA System partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("38F428E6-D326-425D-9140-6E0EA133647C")]
+ AndroidIaSystem,
+
+ /// Android-IA Cache partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("A893EF21-E428-470A-9E55-0668FD91A2D9")]
+ AndroidIaCache,
+
+ /// Android-IA Data partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("DC76DDA9-5AC1-491C-AF42-A82591580C0D")]
+ AndroidIaData,
+
+ /// Android-IA Persistent partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("EBC597D0-2053-4B15-8B64-E0AAC75F4DB1")]
+ AndroidIaPersistent,
+
+ /// Android-IA Vendor partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("C5A0AEEC-13EA-11E5-A1B1-001E67CA0C3C")]
+ AndroidIaVendor,
+
+ /// Android-IA Config partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("BD59408B-4514-490D-BF12-9878D963F378")]
+ AndroidIaConfig,
+
+ /// Android-IA Factory partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("8F68CC74-C5E5-48DA-BE91-A0C8C15E9C80")]
+ AndroidIaFactory,
+
+ /// Android-IA Factory (Alternate) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("9FDAA6EF-4B3F-40D2-BA8D-BFF16BFB887B")]
+ AndroidIaFactoryAlternate,
+
+ /// Android-IA Tertiary partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("767941D0-2085-11E3-AD3B-6CFDB94711E9")]
+ AndroidIaTertiary,
+
+ /// Android-IA OEM partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Oem")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ [Description("AC6D7924-EB71-4DF8-B48D-E267B27148FF")]
+ AndroidIaOem,
+
+ #endregion // Android-IA
+
+
+ #region ONIE
+
+ /// Open Network Install Environment (ONIE) Boot partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Onie")]
+ [Description("7412F7D5-A156-4B13-81DC-867174929325")]
+ OnieBoot,
+
+ /// Open Network Install Environment (ONIE) Config partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Onie")]
+ [Description("D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149")]
+ OnieConfig,
+
+ #endregion // ONIE
+
+
+ #region PowerPC
+
+ /// PowerPC PReP Boot partition.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pc")]
+ [Description("9E1A2D38-C612-4316-AA26-8B49521E5A8B")]
+ PowerPcPrepBoot,
+
+ #endregion // PowerPC
+
+
+ #region freedesktop.org OSes (Linux, etc.)
+
+ /// Shared boot loader configuration partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Bootloader")]
+ [Description("BC13C2FF-59E6-4262-A352-B275FD6F7172")]
+ SharedBootloaderConfiguration,
+
+ #endregion // freedesktop.org OSes (Linux, etc.)
+
+
+ #region Atari TOS
+
+ /// Atari TOS Basic data (GEM, BGM, F32) partition.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tos")]
+ [Description("734E5AFE-F61A-11E6-BC64-92361F002671")]
+ AtariTosBasicData
+
+ #endregion // Atari TOS
+ }
+}
diff --git a/AlphaFS/Device/Structures, Enumerations/StorageBusType.cs b/AlphaFS/Device/Structures, Enumerations/StorageBusType.cs
new file mode 100644
index 000000000..582274b72
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/StorageBusType.cs
@@ -0,0 +1,97 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// Provides a symbolic means of representing storage bus types.
+ public enum StorageBusType
+ {
+ /// Indicates an unknown bus type.
+ Unknown = NativeMethods.STORAGE_BUS_TYPE.BusTypeUnknown,
+
+ /// Indicates a SCSI bus type.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scsi")]
+ Scsi = NativeMethods.STORAGE_BUS_TYPE.BusTypeScsi,
+
+ /// Indicates an ATAPI bus type.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Atapi")]
+ Atapi = NativeMethods.STORAGE_BUS_TYPE.BusTypeAtapi,
+
+ /// Indicates an ATA bus type.
+ Ata = NativeMethods.STORAGE_BUS_TYPE.BusTypeAta,
+
+ /// Indicates an IEEE 1394 bus type.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ieee")]
+ Ieee1394 = NativeMethods.STORAGE_BUS_TYPE.BusType1394,
+
+ /// Indicates an SSA bus type.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ssa")]
+ Ssa = NativeMethods.STORAGE_BUS_TYPE.BusTypeSsa,
+
+ /// Indicates a fiber channel bus type.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Fibre")]
+ Fibre = NativeMethods.STORAGE_BUS_TYPE.BusTypeFibre,
+
+ /// Indicates a USB bus type.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")]
+ Usb = NativeMethods.STORAGE_BUS_TYPE.BusTypeUsb,
+
+ /// Indicates a RAID bus type.
+ Raid = NativeMethods.STORAGE_BUS_TYPE.BusTypeRAID,
+
+ /// Indicates an iSCSI bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Scsi")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "i")]
+ iScsi = NativeMethods.STORAGE_BUS_TYPE.BusTypeiScsi,
+
+ /// Indicates a serial-attached SCSI (SAS) bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sas")]
+ Sas = NativeMethods.STORAGE_BUS_TYPE.BusTypeSas,
+
+ /// Indicates a SATA bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sata")]
+ Sata = NativeMethods.STORAGE_BUS_TYPE.BusTypeSata,
+
+ /// Indicates a secure digital (SD) bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sd")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Sd")]
+ Sd = NativeMethods.STORAGE_BUS_TYPE.BusTypeSd,
+
+ /// Indicates a multimedia card (MMC) bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mmc")]
+ Mmc = NativeMethods.STORAGE_BUS_TYPE.BusTypeMmc,
+
+ /// Indicates a virtual bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ Virtual = NativeMethods.STORAGE_BUS_TYPE.BusTypeVirtual,
+
+ /// Indicates a file-backed virtual bus type.
+ /// Windows Server 2003 and Windows XP: This value is not supported before Windows Vista and Windows Server 2008.
+ FileBackedVirtual = NativeMethods.STORAGE_BUS_TYPE.BusTypeFileBackedVirtual
+ }
+}
diff --git a/AlphaFS/Device/Structures, Enumerations/StorageMediaType.cs b/AlphaFS/Device/Structures, Enumerations/StorageMediaType.cs
new file mode 100644
index 000000000..30898dba9
--- /dev/null
+++ b/AlphaFS/Device/Structures, Enumerations/StorageMediaType.cs
@@ -0,0 +1,423 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32.Device
+{
+ /// Specifies various types of storage media.
+ [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")]
+ public enum StorageMediaType
+ {
+ /// Format is unknown.
+ Unknown = NativeMethods.MEDIA_TYPE.Unknown,
+
+ /// A 5.25" floppy, with 1.2MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ Floppy51Pt2512 = NativeMethods.MEDIA_TYPE.F5_1Pt2_512,
+
+ /// A 3.5" floppy, with 1.44MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ Floppy31Pt44512 = NativeMethods.MEDIA_TYPE.F3_1Pt44_512,
+
+ /// A 3.5" floppy, with 2.88MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ Floppy32Pt88512 = NativeMethods.MEDIA_TYPE.F3_2Pt88_512,
+
+ /// A 3.5" floppy, with 20.8MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ Floppy320Pt8512 = NativeMethods.MEDIA_TYPE.F3_20Pt8_512,
+
+ /// A 3.5" floppy, with 720KB and 512 bytes/sector.
+ Floppy3720512 = NativeMethods.MEDIA_TYPE.F3_720_512,
+
+ /// A 5.25" floppy, with 360KB and 512 bytes/sector.
+ Floppy5360512 = NativeMethods.MEDIA_TYPE.F5_360_512,
+
+ /// A 5.25" floppy, with 320KB and 512 bytes/sector.
+ Floppy5320512 = NativeMethods.MEDIA_TYPE.F5_320_512,
+
+ /// A 5.25" floppy, with 320KB and 1024 bytes/sector.
+ Floppy53201024 = NativeMethods.MEDIA_TYPE.F5_320_1024,
+
+ /// A 5.25" floppy, with 180KB and 512 bytes/sector.
+ Floppy5180512 = NativeMethods.MEDIA_TYPE.F5_180_512,
+
+ /// A 5.25" floppy, with 160KB and 512 bytes/sector.
+ Floppy5160512 = NativeMethods.MEDIA_TYPE.F5_160_512,
+
+ /// Removable media other than floppy.
+ RemovableMedia = NativeMethods.MEDIA_TYPE.RemovableMedia,
+
+ /// Fixed hard disk media.
+ FixedMedia = NativeMethods.MEDIA_TYPE.FixedMedia,
+
+ /// A 3.5" floppy, with 120MB and 512 bytes/sector.
+ Floppy3120M512 = NativeMethods.MEDIA_TYPE.F3_120M_512,
+
+ /// A 3.5" floppy, with 640KB and 512 bytes/sector.
+ Floppy3640512 = NativeMethods.MEDIA_TYPE.F3_640_512,
+
+ /// A 5.25" floppy, with 640KB and 512 bytes/sector.
+ Floppy5640512 = NativeMethods.MEDIA_TYPE.F5_640_512,
+
+ /// A 5.25" floppy, with 720KB and 512 bytes/sector.
+ Floppy5720512 = NativeMethods.MEDIA_TYPE.F5_720_512,
+
+ /// A 3.5" floppy, with 1.2MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ Floppy31Pt2512 = NativeMethods.MEDIA_TYPE.F3_1Pt2_512,
+
+ /// A 3.5" floppy, with 1.23MB and 1024 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ Floppy31Pt231024 = NativeMethods.MEDIA_TYPE.F3_1Pt23_1024,
+
+ /// A 5.25" floppy, with 1.23MB and 1024 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pt")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pt")]
+ Floppy51Pt231024 = NativeMethods.MEDIA_TYPE.F5_1Pt23_1024,
+
+ /// A 3.5" floppy, with 128MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mb")]
+ Floppy3128Mb512 = NativeMethods.MEDIA_TYPE.F3_128Mb_512,
+
+ /// A 3.5" floppy, with 230MB and 512 bytes/sector.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mb")]
+ Floppy3230Mb512 = NativeMethods.MEDIA_TYPE.F3_230Mb_512,
+
+ /// An 8" floppy, with 256KB and 128 bytes/sector.
+ Floppy8256128 = NativeMethods.MEDIA_TYPE.F8_256_128,
+
+ /// A 3.5" floppy, with 200MB and 512 bytes/sector. (HiFD).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mb")]
+ Floppy3200Mb512 = NativeMethods.MEDIA_TYPE.F3_200Mb_512,
+
+ /// A 3.5" floppy, with 240MB and 512 bytes/sector. (HiFD).
+ Floppy3240M512 = NativeMethods.MEDIA_TYPE.F3_240M_512,
+
+ /// A 3.5" floppy, with 32MB and 512 bytes/sector.
+ Floppy332M512 = NativeMethods.MEDIA_TYPE.F3_32M_512,
+
+ /// One of the following tape types: DAT, DDS1, DDS2, and so on.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dds")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ Dds4Mm = NativeMethods.MEDIA_TYPE.DDS_4mm,
+
+ /// MiniQIC tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qic")]
+ MiniQic = NativeMethods.MEDIA_TYPE.MiniQic,
+
+ /// Travan tape (TR-1, TR-2, TR-3, and so on).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Travan")]
+ Travan = NativeMethods.MEDIA_TYPE.Travan,
+
+ /// QIC tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qic")]
+ Qic = NativeMethods.MEDIA_TYPE.QIC,
+
+ /// An 8mm Exabyte metal particle tape.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mp")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mp")]
+ Mp8Mm = NativeMethods.MEDIA_TYPE.MP_8mm,
+
+ /// An 8mm Exabyte advanced metal evaporative tape.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ame")]
+ Ame8Mm = NativeMethods.MEDIA_TYPE.AME_8mm,
+
+ /// An 8mm Sony AIT1 tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ait")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ Ait18Mm = NativeMethods.MEDIA_TYPE.AIT1_8mm,
+
+ /// DLT compact tape (IIIxt or IV).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dlt")]
+ Dlt = NativeMethods.MEDIA_TYPE.DLT,
+
+ /// Philips NCTP tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nctp")]
+ Nctp = NativeMethods.MEDIA_TYPE.NCTP,
+
+ /// IBM 3480 tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ibm")]
+ Ibm3480 = NativeMethods.MEDIA_TYPE.IBM_3480,
+
+ /// IBM 3490E tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ibm")]
+ Ibm3490E = NativeMethods.MEDIA_TYPE.IBM_3490E,
+
+ /// IBM Magstar 3590 tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ibm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Magstar")]
+ IbmMagstar3590 = NativeMethods.MEDIA_TYPE.IBM_Magstar_3590,
+
+ /// IBM Magstar MP tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Magstar")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ibm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mp")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mp")]
+ IbmMagstarMp = NativeMethods.MEDIA_TYPE.IBM_Magstar_MP,
+
+ /// STK data D3 tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Stk")]
+ StkDataD3 = NativeMethods.MEDIA_TYPE.STK_DATA_D3,
+
+ /// Sony DTF tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dtf")]
+ SonyDtf = NativeMethods.MEDIA_TYPE.SONY_DTF,
+
+ /// A 6mm digital videotape.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dv")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dv")]
+ Dv6Mm = NativeMethods.MEDIA_TYPE.DV_6mm,
+
+ /// Exabyte DMI tape (or compatible).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dmi")]
+ Dmi = NativeMethods.MEDIA_TYPE.DMI,
+
+ /// Sony D2S or D2L tape.
+ SonyD2 = NativeMethods.MEDIA_TYPE.SONY_D2,
+
+ /// Cleaner (all drive types that support cleaners).
+ CleanerCartridge = NativeMethods.MEDIA_TYPE.CLEANER_CARTRIDGE,
+
+ /// CD.
+ CDRom = NativeMethods.MEDIA_TYPE.CD_ROM,
+
+ /// CD (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Cd")]
+ CdR = NativeMethods.MEDIA_TYPE.CD_R,
+
+ /// CD (rewriteable).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Cd")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ CdRw = NativeMethods.MEDIA_TYPE.CD_RW,
+
+ /// DVD.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dvd")]
+ DvdRom = NativeMethods.MEDIA_TYPE.DVD_ROM,
+
+ /// DVD (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dvd")]
+ DvdR = NativeMethods.MEDIA_TYPE.DVD_R,
+
+ /// DVD (rewriteable).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dvd")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ DvdRw = NativeMethods.MEDIA_TYPE.DVD_RW,
+
+ /// Magneto-optical 3.5" (rewriteable).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mo")]
+ Mo3Rw = NativeMethods.MEDIA_TYPE.MO_3_RW,
+
+ /// Magneto-optical 5.25" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mo")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ Mo5Wo = NativeMethods.MEDIA_TYPE.MO_5_WO,
+
+ /// Magneto-optical 5.25" (rewriteable; not LIMDOW).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mo")]
+ Mo5Rw = NativeMethods.MEDIA_TYPE.MO_5_RW,
+
+ /// Magneto-optical 5.25" (rewriteable; LIMDOW).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Limdow")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mo")]
+ Mo5Limdow = NativeMethods.MEDIA_TYPE.MO_5_LIMDOW,
+
+ /// Phase change 5.25" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pc")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ Pc5Wo = NativeMethods.MEDIA_TYPE.PC_5_WO,
+
+ /// Phase change 5.25" (rewriteable).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pc")]
+ Pc5Rw = NativeMethods.MEDIA_TYPE.PC_5_RW,
+
+ /// Phase change dual (rewriteable).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pd")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pd")]
+ Pd5Rw = NativeMethods.MEDIA_TYPE.PD_5_RW,
+
+ /// Ablative 5.25" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Abl")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ Abl5Wo = NativeMethods.MEDIA_TYPE.ABL_5_WO,
+
+ /// Pinnacle Apex 4.6GB (rewriteable)
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ PinnacleApex5Rw = NativeMethods.MEDIA_TYPE.PINNACLE_APEX_5_RW,
+
+ /// Sony 12" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ Sony12Wo = NativeMethods.MEDIA_TYPE.SONY_12_WO,
+
+ /// Philips/LMS 12" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ Philips12Wo = NativeMethods.MEDIA_TYPE.PHILIPS_12_WO,
+
+ /// Hitachi 12" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ Hitachi12Wo = NativeMethods.MEDIA_TYPE.HITACHI_12_WO,
+
+ /// Cygnet/ATG 12" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ Cygnet12Wo = NativeMethods.MEDIA_TYPE.CYGNET_12_WO,
+
+ /// Kodak 14" (write once).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wo")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Wo")]
+ Kodak14Wo = NativeMethods.MEDIA_TYPE.KODAK_14_WO,
+
+ /// MO near field recording (Terastor).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mo")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nfr")]
+ MoNfr525 = NativeMethods.MEDIA_TYPE.MO_NFR_525,
+
+ /// Nikon 12" (rewriteable).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Rw")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rw")]
+ Nikon12Rw = NativeMethods.MEDIA_TYPE.NIKON_12_RW,
+
+ /// Iomega Zip.
+ IomegaZip = NativeMethods.MEDIA_TYPE.IOMEGA_ZIP,
+
+ /// Iomega Jaz.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Jaz")]
+ IomegaJaz = NativeMethods.MEDIA_TYPE.IOMEGA_JAZ,
+
+ /// Syquest EZ135.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ez")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ez")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Syquest")]
+ SyquestEz135 = NativeMethods.MEDIA_TYPE.SYQUEST_EZ135,
+
+ /// Syquest EzFlyer.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ezflyer")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Syquest")]
+ SyquestEzflyer = NativeMethods.MEDIA_TYPE.SYQUEST_EZFLYER,
+
+ /// Syquest SyJet.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Syjet")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Syquest")]
+ SyquestSyjet = NativeMethods.MEDIA_TYPE.SYQUEST_SYJET,
+
+ /// Avatar 2.5" floppy.
+ AvatarF2 = NativeMethods.MEDIA_TYPE.AVATAR_F2,
+
+ /// An 8mm Hitachi tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mp")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mp")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ Mp28Mm = NativeMethods.MEDIA_TYPE.MP2_8mm,
+
+ /// Ampex DST small tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dst")]
+ DstS = NativeMethods.MEDIA_TYPE.DST_S,
+
+ /// Ampex DST medium tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dst")]
+ DstM = NativeMethods.MEDIA_TYPE.DST_M,
+
+ /// Ampex DST large tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dst")]
+ DstL = NativeMethods.MEDIA_TYPE.DST_L,
+
+ /// Ecrix 8mm tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vxa")]
+ VxaTape1 = NativeMethods.MEDIA_TYPE.VXATape_1,
+
+ /// Ecrix 8mm tape.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vxa")]
+ VxaTape2 = NativeMethods.MEDIA_TYPE.VXATape_2,
+
+ /// STK 9840.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Stk")]
+ Stk9840 = NativeMethods.MEDIA_TYPE.STK_9840,
+
+ /// LTO Ultrium (IBM, HP, Seagate).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lto")]
+ LtoUltrium = NativeMethods.MEDIA_TYPE.LTO_Ultrium,
+
+ /// LTO Accelis (IBM, HP, Seagate).
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Accelis")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lto")]
+ LtoAccelis = NativeMethods.MEDIA_TYPE.LTO_Accelis,
+
+ /// DVD-RAM.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dvd")]
+ DvdRam = NativeMethods.MEDIA_TYPE.DVD_RAM,
+
+ /// AIT tape (AIT2 or higher).
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Mm")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ait")]
+ Ait8Mm = NativeMethods.MEDIA_TYPE.AIT_8mm,
+
+ /// OnStream ADR1.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Adr")]
+ Adr1 = NativeMethods.MEDIA_TYPE.ADR_1,
+
+ /// OnStream ADR2.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Adr")]
+ Adr2 = NativeMethods.MEDIA_TYPE.ADR_2,
+
+ /// STK 9940.
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Stk")]
+ Stk9940 = NativeMethods.MEDIA_TYPE.STK_9940,
+
+ /// SAIT tape.
+ /// Windows Server 2003: This is not supported before Windows Server 2003 with SP1.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sait")]
+ Sait = NativeMethods.MEDIA_TYPE.SAIT,
+
+ /// Exabyte VXA tape.
+ /// Windows Server 2008: This is not supported before Windows Server 2008.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vxa")]
+ VxaTape = NativeMethods.MEDIA_TYPE.VXATape
+ }
+}
diff --git a/AlphaFS/Device/Volume/Volume.DefineDosDevice.cs b/AlphaFS/Device/Volume Class/Volume.DefineDosDevice.cs
similarity index 97%
rename from AlphaFS/Device/Volume/Volume.DefineDosDevice.cs
rename to AlphaFS/Device/Volume Class/Volume.DefineDosDevice.cs
index a9f1f7792..5d357afb9 100644
--- a/AlphaFS/Device/Volume/Volume.DefineDosDevice.cs
+++ b/AlphaFS/Device/Volume Class/Volume.DefineDosDevice.cs
@@ -22,6 +22,7 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -93,7 +94,7 @@ internal static void DefineDosDeviceCore(bool isDefine, string deviceName, strin
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
{
- var success = NativeMethods.DefineDosDevice(deviceAttributes, deviceName, targetPath);
+ var success = Device.NativeMethods.DefineDosDevice(deviceAttributes, deviceName, targetPath);
var lastError = Marshal.GetLastWin32Error();
if (!success)
diff --git a/AlphaFS/Device/Volume/Volume.DeleteDosDevice.cs b/AlphaFS/Device/Volume Class/Volume.DeleteDosDevice.cs
similarity index 99%
rename from AlphaFS/Device/Volume/Volume.DeleteDosDevice.cs
rename to AlphaFS/Device/Volume Class/Volume.DeleteDosDevice.cs
index 60f7c6286..1ca2f1266 100644
--- a/AlphaFS/Device/Volume/Volume.DeleteDosDevice.cs
+++ b/AlphaFS/Device/Volume Class/Volume.DeleteDosDevice.cs
@@ -21,6 +21,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
diff --git a/AlphaFS/Device/Volume/Volume.DeleteVolumeMountPoint.cs b/AlphaFS/Device/Volume Class/Volume.DeleteVolumeMountPoint.cs
similarity index 97%
rename from AlphaFS/Device/Volume/Volume.DeleteVolumeMountPoint.cs
rename to AlphaFS/Device/Volume Class/Volume.DeleteVolumeMountPoint.cs
index 820450398..6fe795f1a 100644
--- a/AlphaFS/Device/Volume/Volume.DeleteVolumeMountPoint.cs
+++ b/AlphaFS/Device/Volume Class/Volume.DeleteVolumeMountPoint.cs
@@ -76,7 +76,7 @@ internal static void DeleteVolumeMountPointCore(KernelTransaction transaction, s
// 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
// A trailing backslash is required.
- var success = NativeMethods.DeleteVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeMountPoint, false));
+ var success = Device.NativeMethods.DeleteVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeMountPoint, false));
var lastError = Marshal.GetLastWin32Error();
if (!success && !continueOnException)
diff --git a/AlphaFS/Device/Volume/Volume.DiskFreeSpace.cs b/AlphaFS/Device/Volume Class/Volume.DiskFreeSpace.cs
similarity index 85%
rename from AlphaFS/Device/Volume/Volume.DiskFreeSpace.cs
rename to AlphaFS/Device/Volume Class/Volume.DiskFreeSpace.cs
index fb35794b3..85237fdaf 100644
--- a/AlphaFS/Device/Volume/Volume.DiskFreeSpace.cs
+++ b/AlphaFS/Device/Volume Class/Volume.DiskFreeSpace.cs
@@ -31,9 +31,9 @@ public static partial class Volume
///
/// The calling application must have FILE_LIST_DIRECTORY access rights for this directory.
///
- /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
+ /// A path to a drive. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
- /// A class instance.
+ /// Returns a class instance.
[SecurityCritical]
public static DiskSpaceInfo GetDiskFreeSpace(string drivePath)
{
@@ -47,13 +47,13 @@ public static DiskSpaceInfo GetDiskFreeSpace(string drivePath)
///
/// The calling application must have FILE_LIST_DIRECTORY access rights for this directory.
///
- /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
+ /// A path to a drive. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
///
/// null gets both size- and disk cluster information. true Get only disk cluster information,
/// false Get only size information.
///
- /// A class instance.
+ /// Returns a class instance.
[SecurityCritical]
public static DiskSpaceInfo GetDiskFreeSpace(string drivePath, bool? spaceInfoType)
{
diff --git a/AlphaFS/Device/Volume/Volume.DriveType.cs b/AlphaFS/Device/Volume Class/Volume.DriveType.cs
similarity index 87%
rename from AlphaFS/Device/Volume/Volume.DriveType.cs
rename to AlphaFS/Device/Volume Class/Volume.DriveType.cs
index 024f43a4b..da9820b9f 100644
--- a/AlphaFS/Device/Volume/Volume.DriveType.cs
+++ b/AlphaFS/Device/Volume Class/Volume.DriveType.cs
@@ -28,7 +28,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Volume
{
/// [AlphaFS] Determines the disk , based on the root of the current directory.
- /// A enum value.
+ /// Returns a enum value.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[SecurityCritical]
public static DriveType GetCurrentDriveType()
@@ -38,8 +38,8 @@ public static DriveType GetCurrentDriveType()
/// [AlphaFS] Determines the disk .
- /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\"
- /// A enum value.
+ /// A path to a drive. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
+ /// Returns a enum value.
[SecurityCritical]
public static DriveType GetDriveType(string drivePath)
{
@@ -52,7 +52,7 @@ public static DriveType GetDriveType(string drivePath)
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
- return NativeMethods.GetDriveType(drivePath);
+ return Device.NativeMethods.GetDriveType(drivePath);
}
}
}
diff --git a/AlphaFS/Device/Volume/Volume.EnumerateVolumeMountPoints.cs b/AlphaFS/Device/Volume Class/Volume.EnumerateVolumeMountPoints.cs
similarity index 78%
rename from AlphaFS/Device/Volume/Volume.EnumerateVolumeMountPoints.cs
rename to AlphaFS/Device/Volume Class/Volume.EnumerateVolumeMountPoints.cs
index 44eda1b85..bdc31cdb4 100644
--- a/AlphaFS/Device/Volume/Volume.EnumerateVolumeMountPoints.cs
+++ b/AlphaFS/Device/Volume Class/Volume.EnumerateVolumeMountPoints.cs
@@ -29,17 +29,20 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS] Returns an enumerable collection of of all mounted folders (volume mount points) on the specified volume.
+ /// [AlphaFS] Returns an collection of all mounted folders (volume mount points) on the specified volume.
///
///
/// A containing the volume .
- /// An enumerable collection of of all volume mount points on the specified volume.
+ /// Returns an collection of all volume mount points on the specified volume.
[SecurityCritical]
public static IEnumerable EnumerateVolumeMountPoints(string volumeGuid)
{
- if (Utils.IsNullOrWhiteSpace(volumeGuid))
+ if (null == volumeGuid)
throw new ArgumentNullException("volumeGuid");
+ if (volumeGuid.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "volumeGuid");
+
if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(Resources.Not_A_Valid_Guid, "volumeGuid");
@@ -52,11 +55,11 @@ public static IEnumerable EnumerateVolumeMountPoints(string volumeGuid)
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
- using (var handle = NativeMethods.FindFirstVolumeMountPoint(volumeGuid, buffer, (uint)buffer.Capacity))
+ using (var handle = Device.NativeMethods.FindFirstVolumeMountPoint(volumeGuid, buffer, (uint)buffer.Capacity))
{
var lastError = Marshal.GetLastWin32Error();
- if (!NativeMethods.IsValidHandle(handle, false))
+ if (!Utils.IsValidHandle(handle, false))
{
switch ((uint)lastError)
{
@@ -73,13 +76,13 @@ public static IEnumerable EnumerateVolumeMountPoints(string volumeGuid)
yield return buffer.ToString();
- while (NativeMethods.FindNextVolumeMountPoint(handle, buffer, (uint)buffer.Capacity))
+ while (Device.NativeMethods.FindNextVolumeMountPoint(handle, buffer, (uint)buffer.Capacity))
{
lastError = Marshal.GetLastWin32Error();
var throwException = lastError != Win32Errors.ERROR_NO_MORE_FILES && lastError != Win32Errors.ERROR_PATH_NOT_FOUND && lastError != Win32Errors.ERROR_MORE_DATA;
- if (!NativeMethods.IsValidHandle(handle, lastError, volumeGuid, throwException))
+ if (!Utils.IsValidHandle(handle, lastError, volumeGuid, throwException))
yield break;
yield return buffer.ToString();
diff --git a/AlphaFS/Device/Volume/Volume.EnumerateVolumePathNames.cs b/AlphaFS/Device/Volume Class/Volume.EnumerateVolumePathNames.cs
similarity index 68%
rename from AlphaFS/Device/Volume/Volume.EnumerateVolumePathNames.cs
rename to AlphaFS/Device/Volume Class/Volume.EnumerateVolumePathNames.cs
index af5362a52..022297106 100644
--- a/AlphaFS/Device/Volume/Volume.EnumerateVolumePathNames.cs
+++ b/AlphaFS/Device/Volume Class/Volume.EnumerateVolumePathNames.cs
@@ -29,38 +29,40 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS] Returns an enumerable collection of drive letters and mounted folder paths for the specified volume.
- /// An enumerable collection of containing the path names for the specified volume.
+ /// [AlphaFS] Returns an collection of drive letters and mounted folder paths for the specified volume.
+ /// Returns an collection of path names for the specified volume.
///
///
- /// A volume path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\.
+ /// A volume path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
[SecurityCritical]
public static IEnumerable EnumerateVolumePathNames(string volumeGuid)
{
- if (Utils.IsNullOrWhiteSpace(volumeGuid))
+ if (null == volumeGuid)
throw new ArgumentNullException("volumeGuid");
+ if (volumeGuid.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "volumeGuid");
+
if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(Resources.Not_A_Valid_Guid, "volumeGuid");
- var volName = Path.AddTrailingDirectorySeparator(volumeGuid, false);
-
+ uint bufferSize = 50;
+ var buffer = new char[bufferSize];
- uint requiredLength = 10;
- var cBuffer = new char[requiredLength];
+ volumeGuid = Path.AddTrailingDirectorySeparator(volumeGuid, false);
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
- while (!NativeMethods.GetVolumePathNamesForVolumeName(volName, cBuffer, (uint)cBuffer.Length, out requiredLength))
+ while (!Device.NativeMethods.GetVolumePathNamesForVolumeName(volumeGuid, buffer, (uint) buffer.Length, out bufferSize))
{
var lastError = Marshal.GetLastWin32Error();
- switch ((uint)lastError)
+ switch ((uint) lastError)
{
case Win32Errors.ERROR_MORE_DATA:
case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
- cBuffer = new char[requiredLength];
+ buffer = new char[bufferSize];
break;
default:
@@ -70,17 +72,21 @@ public static IEnumerable EnumerateVolumePathNames(string volumeGuid)
}
- var buffer = new StringBuilder(cBuffer.Length);
- foreach (var c in cBuffer)
+ var pathNameBuffer = new StringBuilder(buffer.Length);
+
+ foreach (var c in buffer)
{
if (c != Path.StringTerminatorChar)
- buffer.Append(c);
+
+ pathNameBuffer.Append(c);
+
else
{
- if (buffer.Length > 0)
+ if (pathNameBuffer.Length > 0)
{
- yield return buffer.ToString();
- buffer.Length = 0;
+ yield return pathNameBuffer.ToString();
+
+ pathNameBuffer.Length = 0;
}
}
}
diff --git a/AlphaFS/Device/Volume/Volume.EnumerateVolumes.cs b/AlphaFS/Device/Volume Class/Volume.EnumerateVolumes.cs
similarity index 63%
rename from AlphaFS/Device/Volume/Volume.EnumerateVolumes.cs
rename to AlphaFS/Device/Volume Class/Volume.EnumerateVolumes.cs
index d45b0c892..0e650227a 100644
--- a/AlphaFS/Device/Volume/Volume.EnumerateVolumes.cs
+++ b/AlphaFS/Device/Volume Class/Volume.EnumerateVolumes.cs
@@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
@@ -30,34 +29,33 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS] Returns an enumerable collection of volumes on the computer.
- /// An enumerable collection of volume names on the computer.
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ /// [AlphaFS] Returns an collection of volume s on the Computer.
+ /// Returns an collection of volume s on the Computer.
[SecurityCritical]
public static IEnumerable EnumerateVolumes()
{
- var buffer = new StringBuilder(NativeMethods.MaxPathUnicode);
+ var buffer = new StringBuilder(50);
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
- using (var handle = NativeMethods.FindFirstVolume(buffer, (uint)buffer.Capacity))
+ using (var handle = Device.NativeMethods.FindFirstVolume(buffer, (uint) buffer.Capacity))
{
var lastError = Marshal.GetLastWin32Error();
- var throwException = lastError != Win32Errors.ERROR_NO_MORE_FILES && lastError != Win32Errors.ERROR_PATH_NOT_FOUND;
+ var throwException = lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NO_MORE_FILES && lastError != Win32Errors.ERROR_MORE_DATA;
- if (!NativeMethods.IsValidHandle(handle, lastError, String.Empty, throwException))
+ if (!Utils.IsValidHandle(handle, lastError, string.Empty, throwException))
yield break;
yield return buffer.ToString();
- while (NativeMethods.FindNextVolume(handle, buffer, (uint)buffer.Capacity))
+ while (Device.NativeMethods.FindNextVolume(handle, buffer, (uint) buffer.Capacity))
{
lastError = Marshal.GetLastWin32Error();
- throwException = lastError != Win32Errors.ERROR_NO_MORE_FILES && lastError != Win32Errors.ERROR_PATH_NOT_FOUND && lastError != Win32Errors.ERROR_MORE_DATA;
+ throwException = lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NO_MORE_FILES && lastError != Win32Errors.ERROR_MORE_DATA;
- if (!NativeMethods.IsValidHandle(handle, lastError, String.Empty, throwException))
+ if (!Utils.IsValidHandle(handle, lastError, string.Empty, throwException))
yield break;
yield return buffer.ToString();
diff --git a/AlphaFS/Device/Volume/Volume.GetDriveFormat.cs b/AlphaFS/Device/Volume Class/Volume.GetDriveFormat.cs
similarity index 91%
rename from AlphaFS/Device/Volume/Volume.GetDriveFormat.cs
rename to AlphaFS/Device/Volume Class/Volume.GetDriveFormat.cs
index 8b887d330..8288ad323 100644
--- a/AlphaFS/Device/Volume/Volume.GetDriveFormat.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetDriveFormat.cs
@@ -26,10 +26,10 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS] Gets the name of the file system, such as NTFS or FAT32.
+ /// [AlphaFS] Gets the name of the file system, such as: "NTFS" or "FAT32".
/// Use DriveFormat to determine what formatting a drive uses.
///
- /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
+ /// A path to a drive. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
/// The name of the file system on the specified drive or null on failure or if not available.
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
diff --git a/AlphaFS/Device/Volume/Volume.GetDriveNameForNtDeviceName.cs b/AlphaFS/Device/Volume Class/Volume.GetDriveNameForNtDeviceName.cs
similarity index 89%
rename from AlphaFS/Device/Volume/Volume.GetDriveNameForNtDeviceName.cs
rename to AlphaFS/Device/Volume Class/Volume.GetDriveNameForNtDeviceName.cs
index f6f81d8ae..54e433f1e 100644
--- a/AlphaFS/Device/Volume/Volume.GetDriveNameForNtDeviceName.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetDriveNameForNtDeviceName.cs
@@ -27,14 +27,14 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS] Gets the drive letter from an MS-DOS device name. For example: "\Device\HarddiskVolume2" returns "C:\".
+ /// [AlphaFS] Gets the drive letter from an MS-DOS device name. For example: \Device\HarddiskVolume2 returns C:\
/// An MS-DOS device name.
/// The drive letter from an MS-DOS device name.
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Nt")]
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nt")]
public static string GetDriveNameForNtDeviceName(string deviceName)
{
- return (from drive in Directory.EnumerateLogicalDrivesCore(false, false)
+ return (from drive in DriveInfo.EnumerateLogicalDrivesCore(false, false).OrderBy(driveName => driveName).Select(driveName => new DriveInfo(driveName))
where drive.DosDeviceName.Equals(deviceName, StringComparison.OrdinalIgnoreCase)
diff --git a/AlphaFS/Device/Volume/Volume.GetUniqueVolumeNameForPath.cs b/AlphaFS/Device/Volume Class/Volume.GetUniqueVolumeNameForPath.cs
similarity index 100%
rename from AlphaFS/Device/Volume/Volume.GetUniqueVolumeNameForPath.cs
rename to AlphaFS/Device/Volume Class/Volume.GetUniqueVolumeNameForPath.cs
diff --git a/AlphaFS/Device/Volume/Volume.GetVolumeDeviceName.cs b/AlphaFS/Device/Volume Class/Volume.GetVolumeDeviceName.cs
similarity index 92%
rename from AlphaFS/Device/Volume/Volume.GetVolumeDeviceName.cs
rename to AlphaFS/Device/Volume Class/Volume.GetVolumeDeviceName.cs
index 39da2a14b..3a59998d4 100644
--- a/AlphaFS/Device/Volume/Volume.GetVolumeDeviceName.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetVolumeDeviceName.cs
@@ -28,12 +28,13 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Volume
{
/// [AlphaFS] Retrieves the Win32 Device name from the Volume name.
- /// The Win32 Device name from the Volume name, for example: "\Device\HarddiskVolume2", or null on error or if unavailable.
+ /// The Win32 Device name from the Volume name, for example: \Device\HarddiskVolume2, or null on error or if unavailable.
/// This is the same method as .
///
///
/// Name of the Volume.
[SecurityCritical]
+ [Obsolete("Use Volume.QueryDosDevice(volumeName)")]
public static string GetVolumeDeviceName(string volumeName)
{
return QueryDosDevice(volumeName);
diff --git a/AlphaFS/Device/Volume/Volume.GetVolumeDisplayName.cs b/AlphaFS/Device/Volume Class/Volume.GetVolumeDisplayName.cs
similarity index 75%
rename from AlphaFS/Device/Volume/Volume.GetVolumeDisplayName.cs
rename to AlphaFS/Device/Volume Class/Volume.GetVolumeDisplayName.cs
index d1ce9e948..d439e0f6f 100644
--- a/AlphaFS/Device/Volume/Volume.GetVolumeDisplayName.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetVolumeDisplayName.cs
@@ -28,29 +28,32 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS] Gets the shortest display name for the specified .
+ /// [AlphaFS] Gets the shortest display name for the specified .
/// This method basically returns the shortest string returned by
- /// A volume path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\.
+ /// A volume path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
/// The shortest display name for the specified volume found, or null if no display names were found.
///
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
[SecurityCritical]
- public static string GetVolumeDisplayName(string volumeName)
+ public static string GetVolumeDisplayName(string volumeGuid)
{
- string[] smallestMountPoint = { new string(Path.WildcardStarMatchAllChar, NativeMethods.MaxPathUnicode) };
+ string[] smallestMountPoint = {new string(Path.WildcardStarMatchAllChar, NativeMethods.MaxPathUnicode)};
try
{
- foreach (var m in EnumerateVolumePathNames(volumeName).Where(m => !Utils.IsNullOrWhiteSpace(m) && m.Length < smallestMountPoint[0].Length))
- smallestMountPoint[0] = m;
+ foreach (var mountPoint in EnumerateVolumePathNames(volumeGuid).Where(mPoint => !Utils.IsNullOrWhiteSpace(mPoint) && mPoint.Length < smallestMountPoint[0].Length))
+
+ smallestMountPoint[0] = mountPoint;
}
catch
{
}
+
var result = smallestMountPoint[0][0] == Path.WildcardStarMatchAllChar ? null : smallestMountPoint[0];
- return Utils.IsNullOrWhiteSpace(result) ? null : result;
+
+ return !Utils.IsNullOrWhiteSpace(result) ? result : null;
}
}
}
diff --git a/AlphaFS/Device/Volume/Volume.GetVolumeGuid.cs b/AlphaFS/Device/Volume Class/Volume.GetVolumeGuid.cs
similarity index 92%
rename from AlphaFS/Device/Volume/Volume.GetVolumeGuid.cs
rename to AlphaFS/Device/Volume Class/Volume.GetVolumeGuid.cs
index 14b0f9875..0e594de4f 100644
--- a/AlphaFS/Device/Volume/Volume.GetVolumeGuid.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetVolumeGuid.cs
@@ -58,10 +58,10 @@ public static string GetVolumeGuid(string volumeMountPoint)
// GetVolumeNameForVolumeMountPoint()
// 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
- return NativeMethods.GetVolumeNameForVolumeMountPoint(volumeMountPoint, volumeGuid, (uint)volumeGuid.Capacity)
+ return Device.NativeMethods.GetVolumeNameForVolumeMountPoint(volumeMountPoint, volumeGuid, (uint)volumeGuid.Capacity)
// The string must end with a trailing backslash.
- ? NativeMethods.GetVolumeNameForVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeGuid.ToString(), false), uniqueName, (uint)uniqueName.Capacity)
+ ? Device.NativeMethods.GetVolumeNameForVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeGuid.ToString(), false), uniqueName, (uint)uniqueName.Capacity)
? uniqueName.ToString()
: null
diff --git a/AlphaFS/Device/Volume/Volume.GetVolumeGuidForNtDeviceName.cs b/AlphaFS/Device/Volume Class/Volume.GetVolumeGuidForNtDeviceName.cs
similarity index 80%
rename from AlphaFS/Device/Volume/Volume.GetVolumeGuidForNtDeviceName.cs
rename to AlphaFS/Device/Volume Class/Volume.GetVolumeGuidForNtDeviceName.cs
index dc59ca6fb..a801bb52b 100644
--- a/AlphaFS/Device/Volume/Volume.GetVolumeGuidForNtDeviceName.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetVolumeGuidForNtDeviceName.cs
@@ -27,17 +27,16 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
- /// [AlphaFS]
- /// Tranlates DosDevicePath to a Volume GUID. For example: "\Device\HarddiskVolumeX\path\filename.ext" can translate to: "\path\
- /// filename.ext" or: "\\?\Volume{GUID}\path\filename.ext".
+ /// [AlphaFS] Tranlates DosDevicePath to a volume .
+ /// For example: \Device\HarddiskVolumeX\path\filename.ext can translate to: \path\filename.ext or: \\?\Volume{GUID}\path\filename.ext
///
/// A DosDevicePath, for example: \Device\HarddiskVolumeX\path\filename.ext.
- /// A translated dos path.
+ /// Returns a translated dos path.
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Nt")]
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nt")]
public static string GetVolumeGuidForNtDeviceName(string dosDevice)
{
- return (from drive in Directory.EnumerateLogicalDrivesCore(false, false)
+ return (from drive in DriveInfo.EnumerateLogicalDrivesCore(false, false).OrderBy(driveName => driveName).Select(driveName => new DriveInfo(driveName))
where drive.DosDeviceName.Equals(dosDevice, StringComparison.OrdinalIgnoreCase)
diff --git a/AlphaFS/Device/Volume/Volume.GetVolumeInfo.cs b/AlphaFS/Device/Volume Class/Volume.GetVolumeInfo.cs
similarity index 63%
rename from AlphaFS/Device/Volume/Volume.GetVolumeInfo.cs
rename to AlphaFS/Device/Volume Class/Volume.GetVolumeInfo.cs
index 4396aa012..28ce049d2 100644
--- a/AlphaFS/Device/Volume/Volume.GetVolumeInfo.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetVolumeInfo.cs
@@ -19,6 +19,7 @@
* THE SOFTWARE.
*/
+using System;
using System.Security;
using Microsoft.Win32.SafeHandles;
@@ -28,18 +29,32 @@ public static partial class Volume
{
/// [AlphaFS] Retrieves information about the file system and volume associated with the specified root file or directorystream.
/// A path that contains the root directory.
- /// A instance describing the volume associatied with the specified root directory.
+ /// Returns a instance describing the volume associatied with the specified root directory.
[SecurityCritical]
+ [Obsolete("Use: new VolumeInfo(volumePath)")]
public static VolumeInfo GetVolumeInfo(string volumePath)
{
return new VolumeInfo(volumePath, true, false);
}
+ /// [AlphaFS] Retrieves information about the file system and volume associated with the specified root file or directorystream.
+ /// Returns a instance describing the volume associatied with the specified root directory.
+ /// A path that contains the root directory.
+ /// true suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
+ [SecurityCritical]
+ [Obsolete("Use: new VolumeInfo(volumePath, true, continueOnException)")]
+ public static VolumeInfo GetVolumeInfo(string volumePath, bool continueOnException)
+ {
+ return new VolumeInfo(volumePath, true, continueOnException);
+ }
+
+
/// [AlphaFS] Retrieves information about the file system and volume associated with the specified root file or directorystream.
/// An instance to a handle.
- /// A instance describing the volume associatied with the specified root directory.
+ /// Returns a instance describing the volume associatied with the specified root directory.
[SecurityCritical]
+ [Obsolete("Use: new VolumeInfo(volumeHandle, true, true)")]
public static VolumeInfo GetVolumeInfo(SafeFileHandle volumeHandle)
{
return new VolumeInfo(volumeHandle, true, true);
diff --git a/AlphaFS/Device/Volume/Volume.GetVolumePathName.cs b/AlphaFS/Device/Volume Class/Volume.GetVolumePathName.cs
similarity index 90%
rename from AlphaFS/Device/Volume/Volume.GetVolumePathName.cs
rename to AlphaFS/Device/Volume Class/Volume.GetVolumePathName.cs
index a7e6ddd85..b111b57b1 100644
--- a/AlphaFS/Device/Volume/Volume.GetVolumePathName.cs
+++ b/AlphaFS/Device/Volume Class/Volume.GetVolumePathName.cs
@@ -30,10 +30,10 @@ public static partial class Volume
{
/// [AlphaFS] Retrieves the volume mount point where the specified path is mounted.
///
- /// The path to the volume, for example: "C:\Windows".
+ /// The path to the volume, for example: C:\Windows.
///
/// Returns the nearest volume root path for a given directory.
- /// The volume path name, for example: "C:\Windows" returns: "C:\".
+ /// The volume path name, for example: C:\Windows returns: C:\
///
[SecurityCritical]
public static string GetVolumePathName(string path)
@@ -51,7 +51,7 @@ public static string GetVolumePathName(string path)
// GetVolumePathName()
// 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
- var success = NativeMethods.GetVolumePathName(pathLp, volumeRootPath, (uint) volumeRootPath.Capacity);
+ var success = Device.NativeMethods.GetVolumePathName(pathLp, volumeRootPath, (uint) volumeRootPath.Capacity);
var lastError = Marshal.GetLastWin32Error();
@@ -61,7 +61,7 @@ public static string GetVolumePathName(string path)
switch ((uint) lastError)
{
- // Don't throw exception on these errors.
+ // Do not throw exception on these errors.
case Win32Errors.ERROR_NO_MORE_FILES:
case Win32Errors.ERROR_INVALID_PARAMETER:
case Win32Errors.ERROR_INVALID_NAME:
diff --git a/AlphaFS/Device/Volume/Volume.IsReady.cs b/AlphaFS/Device/Volume Class/Volume.IsReady.cs
similarity index 92%
rename from AlphaFS/Device/Volume/Volume.IsReady.cs
rename to AlphaFS/Device/Volume Class/Volume.IsReady.cs
index e976334b1..f4301c2a4 100644
--- a/AlphaFS/Device/Volume/Volume.IsReady.cs
+++ b/AlphaFS/Device/Volume Class/Volume.IsReady.cs
@@ -27,7 +27,7 @@ public static partial class Volume
{
/// [AlphaFS] Gets a value indicating whether a drive is ready.
///
- /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
+ /// A path to a drive. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
/// true if is ready; otherwise, false.
[SecurityCritical]
diff --git a/AlphaFS/Device/Volume/Volume.IsSameVolume.cs b/AlphaFS/Device/Volume Class/Volume.IsSameVolume.cs
similarity index 97%
rename from AlphaFS/Device/Volume/Volume.IsSameVolume.cs
rename to AlphaFS/Device/Volume Class/Volume.IsSameVolume.cs
index 56e805c86..b9a062b99 100644
--- a/AlphaFS/Device/Volume/Volume.IsSameVolume.cs
+++ b/AlphaFS/Device/Volume Class/Volume.IsSameVolume.cs
@@ -30,7 +30,7 @@ public static partial class Volume
/// [AlphaFS] Determines whether the volume of two file system objects is the same, by comparing their serial numbers.
/// The first filesystem object with full path information.
/// The second file system object with full path information.
- /// true if both filesytem objects reside on the same volume, false otherwise.
+ /// true if both filesytem objects reside on the same volume; otherwise, false.
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
[SecurityCritical]
public static bool IsSameVolume(string path1, string path2)
diff --git a/AlphaFS/Device/Volume/Volume.IsVolume.cs b/AlphaFS/Device/Volume Class/Volume.IsVolume.cs
similarity index 88%
rename from AlphaFS/Device/Volume/Volume.IsVolume.cs
rename to AlphaFS/Device/Volume Class/Volume.IsVolume.cs
index 8e29d1067..9c0533b46 100644
--- a/AlphaFS/Device/Volume/Volume.IsVolume.cs
+++ b/AlphaFS/Device/Volume Class/Volume.IsVolume.cs
@@ -27,9 +27,9 @@ public static partial class Volume
{
/// [AlphaFS] Determines whether the specified volume name is a defined volume on the current computer.
///
- /// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
+ /// A path to a volume. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
- /// true on success, false otherwise.
+ /// true on success; otherwise, false.
[SecurityCritical]
public static bool IsVolume(string volumeMountPoint)
{
diff --git a/AlphaFS/Device/Volume/Volume.QueryDosDevice.cs b/AlphaFS/Device/Volume Class/Volume.QueryDosDevice.cs
similarity index 89%
rename from AlphaFS/Device/Volume/Volume.QueryDosDevice.cs
rename to AlphaFS/Device/Volume Class/Volume.QueryDosDevice.cs
index c5e993f56..7a5f821fc 100644
--- a/AlphaFS/Device/Volume/Volume.QueryDosDevice.cs
+++ b/AlphaFS/Device/Volume Class/Volume.QueryDosDevice.cs
@@ -32,7 +32,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Volume
{
/// [AlphaFS] Retrieves a sorted list of all existing MS-DOS device names.
- /// An sorted list of all existing MS-DOS device names.
+ /// Returns an sorted collection of all existing MS-DOS device names.
[SecurityCritical]
public static IEnumerable QueryAllDosDevices()
{
@@ -52,16 +52,19 @@ public static string QueryDosDevice(string deviceName)
throw new ArgumentNullException("deviceName");
- var devName = QueryDosDeviceCore(deviceName, false).ToArray()[0];
+ var devName = QueryDosDeviceCore(deviceName, false).ToArray();
- return !Utils.IsNullOrWhiteSpace(devName) ? devName : null;
+ if (null == devName || devName.Length == 0)
+ return null;
+
+ return !Utils.IsNullOrWhiteSpace(devName[0]) ? devName[0] : null;
}
/// [AlphaFS] Retrieves the current mapping for a particular MS-DOS device name. The function can also obtain a list of all existing MS-DOS device names.
- /// An sorted list of all existing MS-DOS device names or the .
+ /// Returns an sorted collection of all existing MS-DOS device names or the .
///
///
/// An MS-DOS device name string specifying the target of the query, such as: "C:", "D:" or "\\?\Volume{GUID}".
@@ -81,7 +84,7 @@ internal static IEnumerable QueryDosDeviceCore(string deviceName, bool s
yield break;
}
-
+
if (deviceName.StartsWith(Path.VolumePrefix, StringComparison.OrdinalIgnoreCase))
deviceName = deviceName.Substring(Path.LongPathPrefix.Length);
@@ -105,7 +108,7 @@ internal static IEnumerable QueryDosDeviceCore(string deviceName, bool s
{
var cBuffer = new char[bufferSize];
- returnedBufferSize = NativeMethods.QueryDosDevice(deviceName, cBuffer, bufferSize);
+ returnedBufferSize = Device.NativeMethods.QueryDosDevice(deviceName, cBuffer, bufferSize);
var lastError = Marshal.GetLastWin32Error();
@@ -116,6 +119,12 @@ internal static IEnumerable QueryDosDeviceCore(string deviceName, bool s
case Win32Errors.ERROR_INSUFFICIENT_BUFFER:
bufferSize *= 2;
continue;
+
+
+ case Win32Errors.ERROR_BAD_PATHNAME:
+ // \\server\C$
+ yield break;
+
default:
NativeError.ThrowException(lastError, deviceName);
diff --git a/AlphaFS/Device/Volume/Volume.SetVolumeMountPoint.cs b/AlphaFS/Device/Volume Class/Volume.SetVolumeMountPoint.cs
similarity index 85%
rename from AlphaFS/Device/Volume/Volume.SetVolumeMountPoint.cs
rename to AlphaFS/Device/Volume Class/Volume.SetVolumeMountPoint.cs
index 05c31f0fa..e3a6065a5 100644
--- a/AlphaFS/Device/Volume/Volume.SetVolumeMountPoint.cs
+++ b/AlphaFS/Device/Volume Class/Volume.SetVolumeMountPoint.cs
@@ -40,12 +40,21 @@ public static partial class Volume
[SecurityCritical]
public static void SetVolumeMountPoint(string volumeMountPoint, string volumeGuid)
{
- if (Utils.IsNullOrWhiteSpace(volumeMountPoint))
+ if (null == volumeMountPoint)
throw new ArgumentNullException("volumeMountPoint");
- if (Utils.IsNullOrWhiteSpace(volumeGuid))
+ if (volumeMountPoint.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "volumeMountPoint");
+
+ if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase))
+ throw new ArgumentException(Resources.Not_A_Valid_Guid, "volumeGuid");
+
+ if (null == volumeGuid)
throw new ArgumentNullException("volumeGuid");
+ if (volumeGuid.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "volumeGuid");
+
if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(Resources.Not_A_Valid_Guid, "volumeGuid");
@@ -64,7 +73,7 @@ public static void SetVolumeMountPoint(string volumeMountPoint, string volumeGui
// 2014-01-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
// The string must end with a trailing backslash.
- var success = NativeMethods.SetVolumeMountPoint(volumeMountPoint, volumeGuid);
+ var success = Device.NativeMethods.SetVolumeMountPoint(volumeMountPoint, volumeGuid);
var lastError = Marshal.GetLastWin32Error();
if (!success)
diff --git a/AlphaFS/Device/Volume/Volume.VolumeLabel.cs b/AlphaFS/Device/Volume Class/Volume.VolumeLabel.cs
similarity index 90%
rename from AlphaFS/Device/Volume/Volume.VolumeLabel.cs
rename to AlphaFS/Device/Volume Class/Volume.VolumeLabel.cs
index 3be4de8b0..8994d1598 100644
--- a/AlphaFS/Device/Volume/Volume.VolumeLabel.cs
+++ b/AlphaFS/Device/Volume Class/Volume.VolumeLabel.cs
@@ -51,7 +51,7 @@ public static void DeleteVolumeLabel(string rootPathName)
/// [AlphaFS] Retrieve the label of a file system volume.
///
- /// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\".
+ /// A path to a volume. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
///
/// The the label of the file system volume. This function can return string.Empty since a volume label is generally not mandatory.
[SecurityCritical]
@@ -71,7 +71,7 @@ public static void SetCurrentVolumeLabel(string volumeName)
throw new ArgumentNullException("volumeName");
- var success = NativeMethods.SetVolumeLabel(null, volumeName);
+ var success = Device.NativeMethods.SetVolumeLabel(null, volumeName);
var lastError = Marshal.GetLastWin32Error();
if (!success)
@@ -81,7 +81,7 @@ public static void SetCurrentVolumeLabel(string volumeName)
/// [AlphaFS] Sets the label of a file system volume.
///
- /// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\"
+ /// A path to a volume. For example: C:\, \\server\share, or \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\
/// If this parameter is null, the function uses the current drive.
///
///
@@ -103,7 +103,7 @@ public static void SetVolumeLabel(string volumePath, string volumeName)
// NTFS uses a limit of 32 characters for the volume label as of Windows Server 2003.
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
{
- var success = NativeMethods.SetVolumeLabel(volumePath, volumeName);
+ var success = Device.NativeMethods.SetVolumeLabel(volumePath, volumeName);
var lastError = Marshal.GetLastWin32Error();
if (!success)
diff --git a/AlphaFS/Device/Volume/Volume.cs b/AlphaFS/Device/Volume Class/Volume.cs
similarity index 100%
rename from AlphaFS/Device/Volume/Volume.cs
rename to AlphaFS/Device/Volume Class/Volume.cs
diff --git a/AlphaFS/Device/Volume/VolumeInfo.cs b/AlphaFS/Device/Volume Class/VolumeInfo.cs
similarity index 60%
rename from AlphaFS/Device/Volume/VolumeInfo.cs
rename to AlphaFS/Device/Volume Class/VolumeInfo.cs
index 805720d9e..76775c868 100644
--- a/AlphaFS/Device/Volume/VolumeInfo.cs
+++ b/AlphaFS/Device/Volume Class/VolumeInfo.cs
@@ -19,12 +19,13 @@
* THE SOFTWARE.
*/
-using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics.CodeAnalysis;
+using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
+using Microsoft.Win32.SafeHandles;
namespace Alphaleonis.Win32.Filesystem
{
@@ -33,40 +34,50 @@ namespace Alphaleonis.Win32.Filesystem
[SecurityCritical]
public sealed class VolumeInfo
{
+ #region Fields
+
[NonSerialized] private readonly bool _continueOnAccessError;
[NonSerialized] private readonly SafeFileHandle _volumeHandle;
- [NonSerialized] private NativeMethods.VOLUME_INFO_FLAGS _volumeInfoAttributes;
+ [NonSerialized] private string _guid;
+ [NonSerialized] private Device.NativeMethods.VOLUME_INFO_FLAGS _volumeInfoAttributes;
+
+ #endregion // Private Fields
+ #region Constructors
+
/// Initializes a VolumeInfo instance.
///
///
- /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share.
+ /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share.
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")]
[SecurityCritical]
- public VolumeInfo(string volumeName)
+ public VolumeInfo(string driveName)
{
- if (Utils.IsNullOrWhiteSpace(volumeName))
- throw new ArgumentNullException("volumeName");
+ if (null == driveName)
+ throw new ArgumentNullException("driveName");
+
+ if (driveName.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "driveName");
- if (!volumeName.StartsWith(Path.LongPathPrefix, StringComparison.Ordinal))
- volumeName = Path.IsUncPathCore(volumeName, false, false) ? Path.GetLongPathCore(volumeName, GetFullPathOptions.None) : Path.LongPathPrefix + volumeName;
+ if (!driveName.StartsWith(Path.LongPathPrefix, StringComparison.Ordinal))
+ driveName = Path.IsUncPathCore(driveName, false, false) ? Path.GetLongPathCore(driveName, GetFullPathOptions.None) : Path.LongPathPrefix + driveName;
else
{
- volumeName = volumeName.Length == 1 ? volumeName + Path.VolumeSeparatorChar : Path.GetPathRoot(volumeName, false);
+ driveName = driveName.Length == 1 ? driveName + Path.VolumeSeparatorChar : Path.GetPathRoot(driveName, false);
- if (!volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase))
- volumeName = Path.GetPathRoot(volumeName, false);
+ if (null != driveName && !driveName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase))
+ driveName = Path.GetPathRoot(driveName, false);
}
- if (Utils.IsNullOrWhiteSpace(volumeName))
- throw new ArgumentException(Resources.InvalidDriveLetterArgument, "volumeName");
+ if (Utils.IsNullOrWhiteSpace(driveName))
+ throw new ArgumentException(Resources.InvalidDriveLetterArgument, "driveName");
- Name = Path.AddTrailingDirectorySeparator(volumeName, false);
+ Name = Path.AddTrailingDirectorySeparator(driveName, false);
_volumeHandle = null;
}
@@ -91,6 +102,8 @@ public VolumeInfo(string driveName, bool refresh, bool continueOnException) : th
[SecurityCritical]
public VolumeInfo(SafeFileHandle volumeHandle)
{
+ Utils.IsValidHandle(volumeHandle);
+
_volumeHandle = volumeHandle;
}
@@ -108,115 +121,56 @@ public VolumeInfo(SafeFileHandle volumeHandle, bool refresh, bool continueOnExce
Refresh();
}
-
-
-
- /// Refreshes the state of the object.
- public void Refresh()
- {
- var volumeNameBuffer = new StringBuilder(NativeMethods.MaxPath + 1);
- var fileSystemNameBuffer = new StringBuilder(NativeMethods.MaxPath + 1);
- int maximumComponentLength;
- uint serialNumber;
-
- using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
- {
- // GetVolumeInformationXxx()
- // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
-
- uint lastError;
-
- do
- {
- var success = null != _volumeHandle && NativeMethods.IsAtLeastWindowsVista
-
- // GetVolumeInformationByHandle() / GetVolumeInformation()
- // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
-
- ? NativeMethods.GetVolumeInformationByHandle(_volumeHandle, volumeNameBuffer, (uint) volumeNameBuffer.Capacity, out serialNumber, out maximumComponentLength, out _volumeInfoAttributes, fileSystemNameBuffer, (uint) fileSystemNameBuffer.Capacity)
-
- // A trailing backslash is required.
- : NativeMethods.GetVolumeInformation(Path.AddTrailingDirectorySeparator(Name, false), volumeNameBuffer, (uint) volumeNameBuffer.Capacity, out serialNumber, out maximumComponentLength, out _volumeInfoAttributes, fileSystemNameBuffer, (uint) fileSystemNameBuffer.Capacity);
-
-
- lastError = (uint) Marshal.GetLastWin32Error();
- if (!success)
- {
- switch (lastError)
- {
- case Win32Errors.ERROR_NOT_READY:
- if (!_continueOnAccessError)
- throw new DeviceNotReadyException(Name, true);
- break;
-
- case Win32Errors.ERROR_MORE_DATA:
- // With a large enough buffer this code never executes.
- volumeNameBuffer.Capacity = volumeNameBuffer.Capacity*2;
- fileSystemNameBuffer.Capacity = fileSystemNameBuffer.Capacity*2;
- break;
-
- default:
- if (!_continueOnAccessError)
- NativeError.ThrowException(lastError, Name);
- break;
- }
- }
-
- else
- break;
-
- } while (lastError == Win32Errors.ERROR_MORE_DATA);
- }
-
- FullPath = Path.GetRegularPathCore(Name, GetFullPathOptions.None, false);
- Name = volumeNameBuffer.ToString();
-
- FileSystemName = fileSystemNameBuffer.ToString();
- FileSystemName = !Utils.IsNullOrWhiteSpace(FileSystemName) ? FileSystemName : null;
-
- MaximumComponentLength = maximumComponentLength;
- SerialNumber = serialNumber;
- }
+ #endregion // Constructors
/// Returns the full path of the volume.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return Guid;
}
-
+ #region Properties
/// The specified volume supports preserved case of file names when it places a name on disk.
public bool CasePreservedNames
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_CASE_PRESERVED_NAMES) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_CASE_PRESERVED_NAMES) != 0; }
}
/// The specified volume supports case-sensitive file names.
public bool CaseSensitiveSearch
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_CASE_SENSITIVE_SEARCH) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_CASE_SENSITIVE_SEARCH) != 0; }
}
/// The specified volume supports file-based compression.
public bool Compression
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_FILE_COMPRESSION) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_FILE_COMPRESSION) != 0; }
}
/// The specified volume is a direct access (DAX) volume.
public bool DirectAccess
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_DAX_VOLUME) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_DAX_VOLUME) != 0; }
}
+ /// Gets the drive type.
+ /// One of the values.
+ ///
+ /// The DriveType property indicates whether a drive is any of: CDRom, Fixed, Unknown, Network, NoRootDirectory,
+ /// Ram, Removable, or Unknown. Values are listed in the enumeration.
+ ///
+ internal DriveType DriveType { get; private set; }
+
+
/// Gets the name of the file system, for example, the FAT file system or the NTFS file system.
/// The name of the file system.
public string FileSystemName { get; private set; }
@@ -226,14 +180,22 @@ public bool DirectAccess
public string FullPath { get; private set; }
- private string _guid;
- /// The volume GUID.
+ /// The volume .
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public string Guid
{
get
{
- if (Utils.IsNullOrWhiteSpace(_guid))
- _guid = !Utils.IsNullOrWhiteSpace(FullPath) ? Volume.GetUniqueVolumeNameForPath(FullPath) : null;
+ if (null == _guid)
+ {
+ try
+ {
+ _guid = !Utils.IsNullOrWhiteSpace(FullPath) ? Volume.GetVolumeGuid(FullPath) : null;
+ }
+ catch
+ {
+ }
+ }
return _guid;
}
@@ -247,14 +209,14 @@ public string Guid
/// Gets the label of the volume.
/// The label of the volume.
- /// This property is the label assigned to the volume, such "MyDrive"
+ /// This property is the label assigned to the volume, such as: "MyDrive"
public string Name { get; private set; }
/// The specified volume supports named streams.
public bool NamedStreams
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_NAMED_STREAMS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_NAMED_STREAMS) != 0; }
}
@@ -262,21 +224,21 @@ public bool NamedStreams
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Acls")]
public bool PersistentAcls
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_PERSISTENT_ACLS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_PERSISTENT_ACLS) != 0; }
}
-
+
/// The specified volume is read-only.
public bool ReadOnlyVolume
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_READ_ONLY_VOLUME) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_READ_ONLY_VOLUME) != 0; }
}
-
+
/// The specified volume supports a single sequential write.
public bool SequentialWriteOnce
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SEQUENTIAL_WRITE_ONCE) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SEQUENTIAL_WRITE_ONCE) != 0; }
}
@@ -288,63 +250,63 @@ public bool SequentialWriteOnce
/// The specified volume supports the Encrypted File System (EFS).
public bool SupportsEncryption
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_ENCRYPTION) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_ENCRYPTION) != 0; }
}
/// The specified volume supports extended attributes.
public bool SupportsExtendedAttributes
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_EXTENDED_ATTRIBUTES) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_EXTENDED_ATTRIBUTES) != 0; }
}
/// The specified volume supports hard links.
public bool SupportsHardLinks
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_HARD_LINKS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_HARD_LINKS) != 0; }
}
/// The specified volume supports object identifiers.
public bool SupportsObjectIds
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_OBJECT_IDS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_OBJECT_IDS) != 0; }
}
/// The file system supports open by FileID.
public bool SupportsOpenByFileId
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_OPEN_BY_FILE_ID) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_OPEN_BY_FILE_ID) != 0; }
}
/// The specified volume supports remote storage. (This property does not appear on MSDN)
public bool SupportsRemoteStorage
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_REMOTE_STORAGE) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_REMOTE_STORAGE) != 0; }
}
/// The specified volume supports re-parse points.
public bool SupportsReparsePoints
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_REPARSE_POINTS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_REPARSE_POINTS) != 0; }
}
/// The specified volume supports sparse files.
public bool SupportsSparseFiles
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_SPARSE_FILES) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_SPARSE_FILES) != 0; }
}
/// The specified volume supports transactions.
public bool SupportsTransactions
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_TRANSACTIONS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_TRANSACTIONS) != 0; }
}
@@ -352,28 +314,99 @@ public bool SupportsTransactions
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usn")]
public bool SupportsUsnJournal
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_USN_JOURNAL) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_SUPPORTS_USN_JOURNAL) != 0; }
}
/// The specified volume supports Unicode in file names as they appear on disk.
public bool UnicodeOnDisk
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_UNICODE_ON_DISK) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_UNICODE_ON_DISK) != 0; }
}
/// The specified volume is a compressed volume, for example, a DoubleSpace volume.
public bool VolumeIsCompressed
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_VOLUME_IS_COMPRESSED) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_VOLUME_IS_COMPRESSED) != 0; }
}
/// The specified volume supports disk quotas.
public bool VolumeQuotas
{
- get { return (_volumeInfoAttributes & NativeMethods.VOLUME_INFO_FLAGS.FILE_VOLUME_QUOTAS) != 0; }
+ get { return (_volumeInfoAttributes & Device.NativeMethods.VOLUME_INFO_FLAGS.FILE_VOLUME_QUOTAS) != 0; }
+ }
+
+ #endregion // Properties
+
+
+ #region Methods
+
+ /// Refreshes the state of the object.
+ public void Refresh()
+ {
+ var volumeNameBuffer = new StringBuilder(NativeMethods.MaxPath + 1);
+ var fileSystemNameBuffer = new StringBuilder(NativeMethods.MaxPath + 1);
+ int maximumComponentLength;
+ uint serialNumber;
+
+ using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
+ {
+ uint lastError;
+
+ do
+ {
+ var success = null != _volumeHandle && NativeMethods.IsAtLeastWindowsVista
+
+ ? Device.NativeMethods.GetVolumeInformationByHandle(_volumeHandle, volumeNameBuffer, (uint) volumeNameBuffer.Capacity, out serialNumber, out maximumComponentLength, out _volumeInfoAttributes, fileSystemNameBuffer, (uint) fileSystemNameBuffer.Capacity)
+
+ // A trailing backslash is required.
+ : Device.NativeMethods.GetVolumeInformation(Path.AddTrailingDirectorySeparator(Name, false), volumeNameBuffer, (uint) volumeNameBuffer.Capacity, out serialNumber, out maximumComponentLength, out _volumeInfoAttributes, fileSystemNameBuffer, (uint) fileSystemNameBuffer.Capacity);
+
+
+ lastError = (uint) Marshal.GetLastWin32Error();
+
+ if (success)
+ break;
+
+ switch (lastError)
+ {
+ case Win32Errors.ERROR_NOT_READY:
+ if (!_continueOnAccessError)
+ throw new DeviceNotReadyException(Name, true);
+ break;
+
+ case Win32Errors.ERROR_MORE_DATA:
+ //This code should never execute.
+ volumeNameBuffer.Capacity *= 2;
+ fileSystemNameBuffer.Capacity *= 2;
+ break;
+
+ default:
+ if (!_continueOnAccessError)
+ NativeError.ThrowException(lastError, Name);
+ break;
+ }
+
+ } while (lastError == Win32Errors.ERROR_MORE_DATA);
+ }
+
+
+ FullPath = Path.GetRegularPathCore(Name, GetFullPathOptions.None, false);
+
+ Name = volumeNameBuffer.ToString();
+
+ MaximumComponentLength = maximumComponentLength;
+
+ SerialNumber = serialNumber;
+
+ FileSystemName = fileSystemNameBuffer.ToString();
+ FileSystemName = !Utils.IsNullOrWhiteSpace(FileSystemName) ? FileSystemName : null;
+
+ DriveType = Volume.GetDriveType(FullPath);
}
+
+ #endregion // Methods
}
}
diff --git a/AlphaFS/Filesystem/ByHandleFileInfo.cs b/AlphaFS/Filesystem/ByHandleFileInfo.cs
index 461810f67..76e375d43 100644
--- a/AlphaFS/Filesystem/ByHandleFileInfo.cs
+++ b/AlphaFS/Filesystem/ByHandleFileInfo.cs
@@ -37,8 +37,8 @@ internal ByHandleFileInfo(NativeMethods.BY_HANDLE_FILE_INFORMATION fibh)
LastWriteTimeUtc = DateTime.FromFileTimeUtc(fibh.ftLastWriteTime);
Attributes = fibh.dwFileAttributes;
- FileIndex = NativeMethods.ToLong(fibh.nFileIndexHigh, fibh.nFileIndexLow);
- FileSize = NativeMethods.ToLong(fibh.nFileSizeHigh, fibh.nFileSizeLow);
+ FileIndex = Utils.ToLong(fibh.nFileIndexHigh, fibh.nFileIndexLow);
+ FileSize = Utils.ToLong(fibh.nFileSizeHigh, fibh.nFileSizeLow);
NumberOfLinks = (int) fibh.nNumberOfLinks;
VolumeSerialNumber = fibh.dwVolumeSerialNumber;
}
diff --git a/AlphaFS/Device/ChangeErrorMode.cs b/AlphaFS/Filesystem/ChangeErrorMode.cs
similarity index 100%
rename from AlphaFS/Device/ChangeErrorMode.cs
rename to AlphaFS/Filesystem/ChangeErrorMode.cs
diff --git a/AlphaFS/Filesystem/CopyMoveResult.cs b/AlphaFS/Filesystem/CopyMoveResult.cs
index c17f02d18..ed15f6043 100644
--- a/AlphaFS/Filesystem/CopyMoveResult.cs
+++ b/AlphaFS/Filesystem/CopyMoveResult.cs
@@ -31,7 +31,7 @@ namespace Alphaleonis.Win32.Filesystem
[Serializable]
public sealed class CopyMoveResult
{
- #region Private Fields
+ #region Fields
[NonSerialized] internal readonly Stopwatch Stopwatch;
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompression.cs b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompression.cs
index 182b80b23..a5c7efbf6 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompression.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompression.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -39,7 +40,7 @@ public static partial class Directory
[SecurityCritical]
public static void DisableCompression(string path)
{
- Device.ToggleCompressionCore(null, true, path, false, PathFormat.RelativePath);
+ FilesystemHelper.ToggleCompressionCore(null, true, path, false, PathFormat.RelativePath);
}
@@ -56,7 +57,7 @@ public static void DisableCompression(string path)
[SecurityCritical]
public static void DisableCompression(string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(null, true, path, false, pathFormat);
+ FilesystemHelper.ToggleCompressionCore(null, true, path, false, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompressionTransacted.cs b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompressionTransacted.cs
index be85b843f..414c8c849 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompressionTransacted.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.DisableCompressionTransacted.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -40,7 +41,7 @@ public static partial class Directory
[SecurityCritical]
public static void DisableCompressionTransacted(KernelTransaction transaction, string path)
{
- Device.ToggleCompressionCore(transaction, true, path, false, PathFormat.RelativePath);
+ FilesystemHelper.ToggleCompressionCore(transaction, true, path, false, PathFormat.RelativePath);
}
@@ -58,7 +59,7 @@ public static void DisableCompressionTransacted(KernelTransaction transaction, s
[SecurityCritical]
public static void DisableCompressionTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(transaction, true, path, false, pathFormat);
+ FilesystemHelper.ToggleCompressionCore(transaction, true, path, false, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompression.cs b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompression.cs
index 6b65bbd64..61c170eac 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompression.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompression.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -39,7 +40,7 @@ public static partial class Directory
[SecurityCritical]
public static void EnableCompression(string path)
{
- Device.ToggleCompressionCore(null, true, path, true, PathFormat.RelativePath);
+ FilesystemHelper.ToggleCompressionCore(null, true, path, true, PathFormat.RelativePath);
}
@@ -56,7 +57,7 @@ public static void EnableCompression(string path)
[SecurityCritical]
public static void EnableCompression(string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(null, true, path, true, pathFormat);
+ FilesystemHelper.ToggleCompressionCore(null, true, path, true, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompressionTransacted.cs b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompressionTransacted.cs
index 21b0715a5..203b4b7f1 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompressionTransacted.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Compression/Directory.EnableCompressionTransacted.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -40,7 +41,7 @@ public static partial class Directory
[SecurityCritical]
public static void EnableCompressionTransacted(KernelTransaction transaction, string path)
{
- Device.ToggleCompressionCore(transaction, true, path, true, PathFormat.RelativePath);
+ FilesystemHelper.ToggleCompressionCore(transaction, true, path, true, PathFormat.RelativePath);
}
@@ -58,7 +59,7 @@ public static void EnableCompressionTransacted(KernelTransaction transaction, st
[SecurityCritical]
public static void EnableCompressionTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(transaction, true, path, true, pathFormat);
+ FilesystemHelper.ToggleCompressionCore(transaction, true, path, true, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CompressDecompressCore.cs b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CompressDecompressCore.cs
index 9f84da62a..c38432eae 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CompressDecompressCore.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CompressDecompressCore.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -58,12 +59,12 @@ internal static void CompressDecompressCore(KernelTransaction transaction, strin
foreach (var fsei in EnumerateFileSystemEntryInfosCore(null, transaction, pathLp, searchPattern, null, options | DirectoryEnumerationOptions.AsLongPath, filters, PathFormat.LongFullPath))
- Device.ToggleCompressionCore(transaction, fsei.IsDirectory, fsei.FullPath, compress, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(transaction, fsei.IsDirectory, fsei.FullPath, compress, PathFormat.LongFullPath);
// Process the root directory, the given path.
- Device.ToggleCompressionCore(transaction, true, pathLp, compress, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(transaction, true, pathLp, compress, PathFormat.LongFullPath);
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateDirectoryCore.cs b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateDirectoryCore.cs
index 1bbfce501..9f156b12e 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateDirectoryCore.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateDirectoryCore.cs
@@ -26,6 +26,7 @@
using System.Runtime.InteropServices;
using System.Security;
using System.Security.AccessControl;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -156,7 +157,7 @@ internal static DirectoryInfo CreateDirectoryCore(bool returnNull, KernelTransac
}
else if (compress)
- Device.ToggleCompressionCore(transaction, true, folderLp, true, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(transaction, true, folderLp, true, pathFormat);
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateJunctionCore.cs b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateJunctionCore.cs
index 020f269bf..1ee1802e5 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateJunctionCore.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.CreateJunctionCore.cs
@@ -24,6 +24,7 @@
using System.IO;
using System.Security;
using System.Security.AccessControl;
+using Alphaleonis.Win32.Device;
using Microsoft.Win32.SafeHandles;
namespace Alphaleonis.Win32.Filesystem
@@ -110,7 +111,7 @@ internal static string CreateJunctionCore(KernelTransaction transaction, string
CreateDirectoryCore(true, transaction, junctionPath, null, null, false, pathFormat);
using (var safeHandle = OpenDirectoryJunction(transaction, junctionPath, pathFormat))
- Device.CreateDirectoryJunction(safeHandle, directoryPath);
+ FilesystemHelper.CreateDirectoryJunction(safeHandle, directoryPath);
// Copy the target date and time stamps to the directory junction.
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteJunctionCore.cs b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteJunctionCore.cs
index ca9186d12..ceb14b781 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteJunctionCore.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteJunctionCore.cs
@@ -23,6 +23,7 @@
using System.Globalization;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -71,8 +72,7 @@ internal static void DeleteJunctionCore(KernelTransaction transaction, FileSyste
// Remove the directory junction.
using (var safeHandle = OpenDirectoryJunction(transaction, fsEntryInfo.LongFullPath, pathFormat))
-
- Device.DeleteDirectoryJunction(safeHandle);
+ FilesystemHelper.DeleteDirectoryJunction(safeHandle);
// Optionally the folder itself, which should and must be empty.
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.CreateSymbolicLinkTransacted.cs b/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.CreateSymbolicLinkTransacted.cs
index 2dfb10d99..18d099c5c 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.CreateSymbolicLinkTransacted.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.CreateSymbolicLinkTransacted.cs
@@ -29,13 +29,12 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Directory
{
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK /D") to a directory as a transacted operation.
- ///
///
- /// Symbolic links can point to a non-existent target.
- /// When creating a symbolic link, the operating system does not check to see if the target exists.
- /// Symbolic links are reparse points.
- /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
- /// See to run this method in an elevated state.
+ /// Symbolic links can point to a non-existent target.
+ /// When creating a symbolic link, the operating system does not check to see if the target exists.
+ /// Symbolic links are reparse points.
+ /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
+ /// See to run this method from an elevated state.
///
///
///
@@ -53,13 +52,12 @@ public static void CreateSymbolicLinkTransacted(KernelTransaction transaction, s
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK /D") to a directory as a transacted operation.
- ///
///
- /// Symbolic links can point to a non-existent target.
- /// When creating a symbolic link, the operating system does not check to see if the target exists.
- /// Symbolic links are reparse points.
- /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
- /// See to run this method in an elevated state.
+ /// Symbolic links can point to a non-existent target.
+ /// When creating a symbolic link, the operating system does not check to see if the target exists.
+ /// Symbolic links are reparse points.
+ /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
+ /// See to run this method from an elevated state.
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.DeleteJunctionTransacted.cs b/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.DeleteJunctionTransacted.cs
index b05faafef..2e050092f 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.DeleteJunctionTransacted.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.DeleteJunctionTransacted.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -30,11 +31,7 @@ public static partial class Directory
#region Obsolete
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -53,11 +50,7 @@ public static void DeleteJunction(KernelTransaction transaction, string junction
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -77,11 +70,7 @@ public static void DeleteJunction(KernelTransaction transaction, string junction
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -101,11 +90,7 @@ public static void DeleteJunction(KernelTransaction transaction, string junction
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -128,11 +113,7 @@ public static void DeleteJunction(KernelTransaction transaction, string junction
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -150,11 +131,7 @@ public static void DeleteJunctionTransacted(KernelTransaction transaction, strin
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -173,11 +150,7 @@ public static void DeleteJunctionTransacted(KernelTransaction transaction, strin
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -196,11 +169,7 @@ public static void DeleteJunctionTransacted(KernelTransaction transaction, strin
/// [AlphaFS] Deletes an NTFS directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.ExistsJunction.cs b/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.ExistsJunction.cs
index a1cdf5c50..82870ad3c 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.ExistsJunction.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory Junctions, Links/Directory.ExistsJunction.cs
@@ -29,14 +29,13 @@ public static partial class Directory
{
/// [AlphaFS] Determines whether the given path refers to an existing directory junction on disk.
///
- /// Returns true if refers to an existing directory junction.
- /// Returns false if the directory junction does not exist or an error occurs when trying to determine if the specified file exists.
+ /// Returns true if refers to an existing directory junction.
+ /// Returns false if the directory junction does not exist or an error occurs when trying to determine if the specified file exists.
///
- ///
///
- /// The Exists method returns false if any error occurs while trying to determine if the specified file exists.
- /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
- /// a failing or missing disk, or if the caller does not have permission to read the file.
+ /// The Exists method returns false if any error occurs while trying to determine if the specified file exists.
+ /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
+ /// a failing or missing disk, or if the caller does not have permission to read the file.
///
///
///
@@ -53,14 +52,13 @@ public static bool ExistsJunction(string junctionPath)
/// [AlphaFS] Determines whether the given path refers to an existing directory junction on disk.
///
- /// Returns true if refers to an existing directory junction.
- /// Returns false if the directory junction does not exist or an error occurs when trying to determine if the specified file exists.
+ /// Returns true if refers to an existing directory junction.
+ /// Returns false if the directory junction does not exist or an error occurs when trying to determine if the specified file exists.
///
- ///
///
- /// The Exists method returns false if any error occurs while trying to determine if the specified file exists.
- /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
- /// a failing or missing disk, or if the caller does not have permission to read the file.
+ /// The Exists method returns false if any error occurs while trying to determine if the specified file exists.
+ /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
+ /// a failing or missing disk, or if the caller does not have permission to read the file.
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs b/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs
index d411620c6..24cc6025c 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs
@@ -24,6 +24,7 @@
using System.IO;
using System.Security;
using System.Security.AccessControl;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs b/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
index b52fbec40..27a8c1930 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
@@ -54,7 +54,7 @@ public static void Delete(string path)
///
///
/// The name of the directory to remove.
- /// true to remove directories, subdirectories, and files in . false otherwise.
+ /// true to remove directories, subdirectories, and files in ; otherwise, false.
[SecurityCritical]
public static void Delete(string path, bool recursive)
{
@@ -90,7 +90,7 @@ public static void Delete(string path, PathFormat pathFormat)
///
///
/// The name of the directory to remove.
- /// true to remove directories, subdirectories, and files in . false otherwise.
+ /// true to remove directories, subdirectories, and files in ; otherwise, false.
/// Indicates the format of the path parameter(s).
[SecurityCritical]
public static void Delete(string path, bool recursive, PathFormat pathFormat)
@@ -108,7 +108,7 @@ public static void Delete(string path, bool recursive, PathFormat pathFormat)
///
///
/// The name of the directory to remove.
- /// true to remove directories, subdirectories, and files in . false otherwise.
+ /// true to remove directories, subdirectories, and files in ; otherwise, false.
/// true overrides read only of files and directories.
[SecurityCritical]
public static void Delete(string path, bool recursive, bool ignoreReadOnly)
@@ -126,7 +126,7 @@ public static void Delete(string path, bool recursive, bool ignoreReadOnly)
///
///
/// The name of the directory to remove.
- /// true to remove directories, subdirectories, and files in . false otherwise.
+ /// true to remove directories, subdirectories, and files in ; otherwise, false.
/// true overrides read only of files and directories.
/// Indicates the format of the path parameter(s).
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs
index d0a9c9ff8..88fde79f4 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs
@@ -23,7 +23,6 @@
using System.Collections.Generic;
using System.IO;
using System.Security;
-using SearchOption = System.IO.SearchOption;
namespace Alphaleonis.Win32.Filesystem
{
@@ -31,8 +30,8 @@ public static partial class Directory
{
#region .NET
- /// Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -47,8 +46,8 @@ public static IEnumerable EnumerateDirectories(string path)
}
- /// Returns an enumerable collection of directory names that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
+ /// Returns an collection of directory names that match a in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
///
///
///
@@ -68,8 +67,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
+ /// Returns an collection of directory names that match a in a specified , and optionally searches subdirectories.
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
///
///
///
@@ -95,8 +94,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
#endregion // .NET
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -112,8 +111,8 @@ public static IEnumerable EnumerateDirectories(string path, PathFormat p
}
- /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
+ /// [AlphaFS] Returns an collection of directory names that match a in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by and that match the specified .
///
///
///
@@ -135,8 +134,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
+ /// [AlphaFS] Returns an collection of directory names that match a in a specified , and optionally searches subdirectories.
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by and that match the specified and .
///
///
///
@@ -162,8 +161,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -179,8 +178,8 @@ public static IEnumerable EnumerateDirectories(string path, DirectoryEnu
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -197,8 +196,8 @@ public static IEnumerable EnumerateDirectories(string path, DirectoryEnu
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -220,8 +219,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -244,8 +243,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -261,8 +260,8 @@ public static IEnumerable EnumerateDirectories(string path, DirectoryEnu
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -279,8 +278,8 @@ public static IEnumerable EnumerateDirectories(string path, DirectoryEnu
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -302,8 +301,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -326,8 +325,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -344,8 +343,8 @@ public static IEnumerable EnumerateDirectories(string path, DirectoryEnu
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -363,8 +362,8 @@ public static IEnumerable EnumerateDirectories(string path, DirectoryEnu
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
@@ -387,8 +386,8 @@ public static IEnumerable EnumerateDirectories(string path, string searc
}
- /// [AlphaFS] Returns an enumerable collection of directory names in a specified .
- /// An enumerable collection of the full names (including paths) for the directories in the directory specified by .
+ /// [AlphaFS] Returns an collection of directory names in a specified .
+ /// Returns an collection of the full names (including paths) for the directories in the directory specified by .
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs
index 1a12e8928..3ef39fcf6 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs
@@ -19,18 +19,18 @@
* THE SOFTWARE.
*/
-using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security;
+using Microsoft.Win32.SafeHandles;
namespace Alphaleonis.Win32.Filesystem
{
public static partial class Directory
{
/// [AlphaFS] Retrieves information about files in the directory specified by in mode.
- /// An enumeration of records for each file system entry in the specified diretory.
+ /// Returns an enumeration of records for each file system entry in the specified directory.
/// The operating system is older than Windows Vista.
/// A path to a directory from which to retrieve information.
[SecurityCritical]
@@ -41,7 +41,7 @@ public static IEnumerable EnumerateFileIdBothDirectoryI
/// [AlphaFS] Retrieves information about files in the directory specified by in mode.
- /// An enumeration of records for each file system entry in the specified diretory.
+ /// Returns an enumeration of records for each file system entry in the specified directory.
/// The operating system is older than Windows Vista.
/// A path to a directory from which to retrieve information.
/// Indicates the format of the path parameter(s).
@@ -53,7 +53,7 @@ public static IEnumerable EnumerateFileIdBothDirectoryI
/// [AlphaFS] Retrieves information about files in the directory specified by in specified mode.
- /// An enumeration of records for each file system entry in the specified diretory.
+ /// Returns an enumeration of records for each file system entry in the specified directory.
/// The operating system is older than Windows Vista.
/// A path to a directory from which to retrieve information.
/// The mode with which to open a handle to the directory.
@@ -65,7 +65,7 @@ public static IEnumerable EnumerateFileIdBothDirectoryI
/// [AlphaFS] Retrieves information about files in the directory specified by in specified mode.
- /// An enumeration of records for each file system entry in the specified diretory.
+ /// Returns an enumeration of records for each file system entry in the specified directory.
/// The operating system is older than Windows Vista.
/// A path to a directory from which to retrieve information.
/// The mode with which to open a handle to the directory.
@@ -78,7 +78,7 @@ public static IEnumerable EnumerateFileIdBothDirectoryI
/// [AlphaFS] Retrieves information about files in the directory handle specified.
- /// An IEnumerable of records for each file system entry in the specified diretory.
+ /// Returns an collection for each file system entry in the specified directory.
/// The operating system is older than Windows Vista.
/// An open handle to the directory from which to retrieve information.
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs
index 4f2468b00..daa2474c2 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs
@@ -23,7 +23,6 @@
using System.Collections.Generic;
using System.IO;
using System.Security;
-using SearchOption = System.IO.SearchOption;
namespace Alphaleonis.Win32.Filesystem
{
@@ -31,8 +30,8 @@ public static partial class Directory
{
#region .NET
- /// Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -47,8 +46,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path)
}
- /// Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
+ /// Returns an collection of file names and directory names that match a in a specified .
+ /// Returns an collection of file system entries in the directory specified by and that match the specified .
///
///
///
@@ -68,8 +67,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
}
- /// Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of file system entries in the directory specified by and that match the specified and .
+ /// Returns an collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
+ /// Returns an collection of file system entries in the directory specified by and that match the specified and .
///
///
///
@@ -95,8 +94,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
#endregion // .NET
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -112,8 +111,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, PathFo
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
+ /// [AlphaFS] Returns an collection of file names and directory names that match a in a specified .
+ /// Returns an collection of file system entries in the directory specified by and that match the specified .
///
///
///
@@ -135,8 +134,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of file system entries in the directory specified by and that match the specified and .
+ /// [AlphaFS] Returns an collection of file names and directory names that match a in a specified , and optionally searches subdirectories.
+ /// Returns an collection of file system entries in the directory specified by and that match the specified and .
///
///
///
@@ -162,8 +161,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -179,8 +178,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, Direct
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -197,8 +196,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, Direct
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
+ /// [AlphaFS] Returns an collection of file names and directory names that match a in a specified .
+ /// Returns an collection of file system entries in the directory specified by and that match the specified .
///
///
///
@@ -220,8 +219,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
+ /// [AlphaFS] Returns an collection of file names and directory names that match a in a specified .
+ /// Returns an collection of file system entries in the directory specified by and that match the specified .
///
///
///
@@ -244,8 +243,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -261,8 +260,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, Direct
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -279,8 +278,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, Direct
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -297,8 +296,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, Direct
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified .
- /// An enumerable collection of file system entries in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names and directory names in a specified .
+ /// Returns an collection of file system entries in the directory specified by .
///
///
///
@@ -316,8 +315,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, Direct
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
+ /// [AlphaFS] Returns an collection of file names and directory names that match a in a specified .
+ /// Returns an collection of file system entries in the directory specified by and that match the specified .
///
///
///
@@ -340,8 +339,8 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string
}
- /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified .
- /// An enumerable collection of file system entries in the directory specified by and that match the specified .
+ /// [AlphaFS] Returns an collection of file names and directory names that match a in a specified .
+ /// Returns an collection of file system entries in the directory specified by and that match the specified .
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs
index d15b15bb9..bb6d1545e 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs
@@ -29,7 +29,7 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Directory
{
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -62,7 +62,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path)
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -96,7 +96,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, PathF
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -130,7 +130,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, Direc
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -165,7 +165,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, Direc
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -203,7 +203,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -242,7 +242,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using .
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path using .
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -281,7 +281,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using .
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path using .
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -321,7 +321,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -355,7 +355,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, Direc
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -390,7 +390,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, Direc
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -425,7 +425,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, Direc
}
- /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -461,7 +461,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, Direc
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -501,7 +501,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -542,7 +542,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
@@ -583,7 +583,7 @@ public static IEnumerable EnumerateFileSystemEntryInfos(string path, strin
}
- /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path.
+ /// [AlphaFS] Returns an collection of file system entries that match a in a specified path.
/// The matching file system entries. The type of the items is determined by the type .
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs
index b3d6b799d..deff52d5b 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs
@@ -23,7 +23,6 @@
using System.Collections.Generic;
using System.IO;
using System.Security;
-using SearchOption = System.IO.SearchOption;
namespace Alphaleonis.Win32.Filesystem
{
@@ -31,8 +30,8 @@ public static partial class Directory
{
#region .NET
- /// Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -47,8 +46,8 @@ public static IEnumerable EnumerateFiles(string path)
}
- /// Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -68,8 +67,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// Returns an enumerable collection of file names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
+ /// Returns an collection of file names that match a in a specified , and optionally searches subdirectories.
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
///
///
///
@@ -95,8 +94,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
#endregion // .NET
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -112,8 +111,8 @@ public static IEnumerable EnumerateFiles(string path, PathFormat pathFor
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -135,8 +134,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names that match a in a specified , and optionally searches subdirectories.
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
+ /// [AlphaFS] Returns an collection of file names that match a in a specified , and optionally searches subdirectories.
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the specified and .
///
///
///
@@ -162,8 +161,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -179,8 +178,8 @@ public static IEnumerable EnumerateFiles(string path, DirectoryEnumerati
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -197,8 +196,8 @@ public static IEnumerable EnumerateFiles(string path, DirectoryEnumerati
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -220,8 +219,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -244,8 +243,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -261,8 +260,8 @@ public static IEnumerable EnumerateFiles(string path, DirectoryEnumerati
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -279,8 +278,8 @@ public static IEnumerable EnumerateFiles(string path, DirectoryEnumerati
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -302,8 +301,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -326,8 +325,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -344,8 +343,8 @@ public static IEnumerable EnumerateFiles(string path, DirectoryEnumerati
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by .
///
///
///
@@ -363,8 +362,8 @@ public static IEnumerable EnumerateFiles(string path, DirectoryEnumerati
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
@@ -387,8 +386,8 @@ public static IEnumerable EnumerateFiles(string path, string searchPatte
}
- /// [AlphaFS] Returns an enumerable collection of file names in a specified .
- /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the .
+ /// [AlphaFS] Returns an collection of file names in a specified .
+ /// Returns an collection of the full names (including paths) for the files in the directory specified by and that match the .
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateLogicalDrives.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateLogicalDrives.cs
index 36ba7cbdd..5ca2a9c35 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateLogicalDrives.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateLogicalDrives.cs
@@ -29,108 +29,24 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Directory
{
/// [AlphaFS] Enumerates the drive names of all logical drives on the Computer with the ready status.
- /// An IEnumerable of type that represents the logical drives on the Computer.
+ /// Returns an IEnumerable of type that represents the logical drives on the Computer.
[SecurityCritical]
+ [Obsolete("Use DriveInfo.GetDrives()")]
public static IEnumerable EnumerateLogicalDrives()
{
- return EnumerateLogicalDrivesCore(false, true);
+ return DriveInfo.EnumerateLogicalDrivesCore(false, false).OrderBy(driveName => driveName).Select(driveName => new DriveInfo(driveName));
}
/// [AlphaFS] Enumerates the drive names of all logical drives on the Computer.
- /// An IEnumerable of type that represents the logical drives on the Computer.
+ /// Returns an IEnumerable of type that represents the logical drives on the Computer.
/// Retrieve logical drives as known by the Environment.
/// Retrieve only when accessible (IsReady) logical drives.
[SecurityCritical]
+ [Obsolete("Use DriveInfo.GetDrives()")]
public static IEnumerable EnumerateLogicalDrives(bool fromEnvironment, bool isReady)
{
- return EnumerateLogicalDrivesCore(fromEnvironment, isReady);
- }
-
-
-
-
- /// Enumerates the drive names of all logical drives on the Computer.
- /// An IEnumerable of type that represents the logical drives on the Computer.
- /// Retrieve logical drives as known by the Environment.
- /// Retrieve only when accessible (IsReady) logical drives.
- [SecurityCritical]
- internal static IEnumerable EnumerateLogicalDrivesCore(bool fromEnvironment, bool isReady)
- {
- // Get from Environment.
-
- if (fromEnvironment)
- {
- var drivesEnv = isReady
- ? Environment.GetLogicalDrives().Where(ld => File.ExistsCore(null, true, ld, PathFormat.FullPath))
- : Environment.GetLogicalDrives().Select(ld => ld);
-
- foreach (var drive in drivesEnv)
- {
- // Optionally check Drive .IsReady.
- if (isReady)
- {
- if (File.ExistsCore(null, true, drive, PathFormat.FullPath))
- yield return new DriveInfo(drive);
- }
-
- else
- yield return new DriveInfo(drive);
- }
-
- yield break;
- }
-
-
- // Get through NativeMethod.
-
- var lastError = NativeMethods.GetLogicalDrives();
-
- // MSDN: GetLogicalDrives(): If the function fails, the return value is zero.
- if (lastError == Win32Errors.ERROR_SUCCESS)
- NativeError.ThrowException(lastError);
-
-
- var drives = lastError;
- var count = 0;
- while (drives != 0)
- {
- if ((drives & 1) != 0)
- ++count;
-
- drives >>= 1;
- }
-
- var result = new string[count];
- char[] root = {'A', Path.VolumeSeparatorChar};
-
- drives = lastError;
- count = 0;
-
- while (drives != 0)
- {
- if ((drives & 1) != 0)
- {
- var drive = new string(root);
-
- if (isReady)
- {
- // Optionally check Drive .IsReady property.
- if (File.ExistsCore(null, true, drive, PathFormat.FullPath))
- yield return new DriveInfo(drive);
- }
- else
- {
- // Ready or not.
- yield return new DriveInfo(drive);
- }
-
- result[count++] = drive;
- }
-
- drives >>= 1;
- root[0]++;
- }
+ return DriveInfo.EnumerateLogicalDrivesCore(fromEnvironment, isReady).OrderBy(driveName => driveName).Select(driveName => new DriveInfo(driveName));
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs
index 5aac0030a..8950471ad 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs
@@ -33,7 +33,7 @@ public static partial class Directory
#region .NET
/// Gets a object that encapsulates the access control list (ACL) entries for the specified directory.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
@@ -48,7 +48,7 @@ public static DirectorySecurity GetAccessControl(string path)
/// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for the specified directory.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
@@ -76,7 +76,7 @@ public static DirectorySecurity GetAccessControl(string path, AccessControlSecti
/// [AlphaFS] Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory.
- /// A object that encapsulates the access control rules for the directory described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the directory described by the parameter.
///
///
///
@@ -91,7 +91,7 @@ public static DirectorySecurity GetAccessControl(string path, AccessControlSecti
/// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for the specified directory handle.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
@@ -104,7 +104,7 @@ public static DirectorySecurity GetAccessControl(SafeFileHandle handle)
/// [AlphaFS] Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory handle.
- /// A object that encapsulates the access control rules for the directory described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the directory described by the parameter.
///
///
///
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs
index 8b14fa7c1..5eccb78ce 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs
@@ -23,7 +23,6 @@
using System.IO;
using System.Linq;
using System.Security;
-using SearchOption = System.IO.SearchOption;
namespace Alphaleonis.Win32.Filesystem
{
@@ -32,7 +31,7 @@ public static partial class Directory
#region .NET
/// Returns the names of subdirectories (including their paths) in the specified directory.
- /// An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found.
+ /// Returns an array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found.
///
/// The names returned by this method are prefixed with the directory information provided in path.
/// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
@@ -55,7 +54,7 @@ public static string[] GetDirectories(string path)
/// Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
- /// An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found.
+ /// Returns an array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found.
///
/// The names returned by this method are prefixed with the directory information provided in path.
/// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
@@ -83,7 +82,7 @@ public static string[] GetDirectories(string path, string searchPattern)
/// Returns the names of the subdirectories (including their paths) that match the specified search pattern in the specified directory, and optionally searches subdirectories.
- /// An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.
+ /// Returns an array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.
///
/// The names returned by this method are prefixed with the directory information provided in path.
/// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetFileInfoByHandle.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetFileInfoByHandle.cs
index e29405b66..5cc78d1d2 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetFileInfoByHandle.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetFileInfoByHandle.cs
@@ -27,7 +27,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Directory
{
/// [AlphaFS] Retrieves file information for the specified directory.
- /// A instance containing the requested information.
+ /// Returns a instance containing the requested information.
/// Directory IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the directory ID for a directory can change over time.
/// The path to the directory.
[SecurityCritical]
@@ -38,7 +38,7 @@ public static ByHandleFileInfo GetFileInfoByHandle(string path)
/// [AlphaFS] Retrieves file information for the specified directory.
- /// A instance containing the requested information.
+ /// Returns a instance containing the requested information.
/// Directory IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the directory ID for a directory can change over time.
/// The path to the directory.
/// Indicates the format of the path parameter(s).
@@ -50,7 +50,7 @@ public static ByHandleFileInfo GetFileInfoByHandle(string path, PathFormat pathF
/// [AlphaFS] Retrieves file information for the specified .
- /// A instance containing the requested information.
+ /// Returns a instance containing the requested information.
/// Directory IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the directory ID for a directory can change over time.
/// A connected to the open file or directory from which to retrieve the information.
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs
index 0b3f86a35..bbd8d53cd 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs
@@ -23,7 +23,6 @@
using System.IO;
using System.Linq;
using System.Security;
-using SearchOption = System.IO.SearchOption;
namespace Alphaleonis.Win32.Filesystem
{
@@ -32,7 +31,7 @@ public static partial class Directory
#region .NET
/// Returns the names of all files and subdirectories in the specified directory.
- /// An string[] array of the names of files and subdirectories in the specified directory.
+ /// Returns a string[] array of the names of files and subdirectories in the specified directory.
///
/// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
/// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
@@ -55,7 +54,7 @@ public static string[] GetFileSystemEntries(string path)
/// Returns an array of file system entries that match the specified search criteria.
- /// An string[] array of file system entries that match the specified search criteria.
+ /// Returns a string[] array of file system entries that match the specified search criteria.
///
/// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
/// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
@@ -83,7 +82,7 @@ public static string[] GetFileSystemEntries(string path, string searchPattern)
/// Gets an array of all the file names and directory names that match a in a specified path, and optionally searches subdirectories.
- /// An string[] array of file system entries that match the specified search criteria.
+ /// Returns a string[] array of file system entries that match the specified search criteria.
///
/// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries,
/// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries,
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs
index 5bd5d7612..ab7a0cc7b 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs
@@ -23,7 +23,6 @@
using System.IO;
using System.Linq;
using System.Security;
-using SearchOption = System.IO.SearchOption;
namespace Alphaleonis.Win32.Filesystem
{
@@ -32,7 +31,7 @@ public static partial class Directory
#region .NET
/// Returns the names of files (including their paths) in the specified directory.
- /// An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.
+ /// Returns an array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.
///
/// The returned file names are appended to the supplied parameter.
/// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
@@ -56,7 +55,7 @@ public static string[] GetFiles(string path)
/// Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
- /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.
+ /// Returns an array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.
///
/// The returned file names are appended to the supplied parameter.
/// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
@@ -85,7 +84,7 @@ public static string[] GetFiles(string path, string searchPattern)
/// Returns the names of files (including their paths) that match the specified search pattern in the current directory, and optionally searches subdirectories.
- /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found.
+ /// Returns an array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found.
///
/// The returned file names are appended to the supplied parameter.
/// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs
index 8c2f48a6a..e076a4b3a 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs
@@ -28,25 +28,25 @@ public static partial class Directory
{
#region .NET
- /// Retrieves the names of the logical drives on the Computer in the form "<drive letter>:\".
- /// An array of type that represents the logical drives on the Computer.
+ /// Retrieves the names of the logical drives on the Computer in the form "drive letter:\".
+ /// Returns an array of type that represents the logical drives on the Computer.
[SecurityCritical]
public static string[] GetLogicalDrives()
{
- return EnumerateLogicalDrivesCore(false, false).Select(drive => drive.Name).ToArray();
+ return DriveInfo.EnumerateLogicalDrivesCore(false, false).ToArray();
}
#endregion // .NET
-
- /// [AlphaFS] Retrieves the names of the logical drives on the Computer in the form "C:\".
- /// An array of type that represents the logical drives on the Computer.
+
+ /// [AlphaFS] Retrieves the names of the logical drives on the Computer in the form "drive letter:\".
+ /// Returns an array of type that represents the logical drives on the Computer.
/// Retrieve logical drives as known by the Environment.
/// Retrieve only when accessible (IsReady) logical drives.
[SecurityCritical]
public static string[] GetLogicalDrives(bool fromEnvironment, bool isReady)
{
- return EnumerateLogicalDrivesCore(fromEnvironment, isReady).Select(drive => drive.Name).ToArray();
+ return DriveInfo.EnumerateLogicalDrivesCore(fromEnvironment, isReady).OrderBy(driveName => driveName).ToArray();
}
}
}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs
index b5e17438b..b68dc1f2f 100644
--- a/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs
+++ b/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs
@@ -35,7 +35,7 @@ public static partial class Directory
/// Size: is the total size of enumerated objects.
/// Error: is the total number of errors encountered during enumeration.
///
- /// A dictionary mapping the keys mentioned above to their respective aggregated values.
+ /// Returns a dictionary mapping the keys mentioned above to their respective aggregated values.
/// Directory: is an object which has attribute without one.
///
///
@@ -58,7 +58,7 @@ public static Dictionary GetProperties(string path)
/// Size: is the total size of enumerated objects.
/// Error: is the total number of errors encountered during enumeration.
///
- /// A dictionary mapping the keys mentioned above to their respective aggregated values.
+ /// Returns a dictionary mapping the keys mentioned above to their respective aggregated values.
/// Directory: is an object which has attribute without one.
///
///
@@ -82,7 +82,7 @@ public static Dictionary GetProperties(string path, PathFormat pat
/// Size: is the total size of enumerated objects.
/// Error: is the total number of errors encountered during enumeration.
///
- /// A dictionary mapping the keys mentioned above to their respective aggregated values.
+ /// Returns a dictionary mapping the keys mentioned above to their respective aggregated values.
/// Directory: is an object which has attribute without one.
///
///
@@ -106,7 +106,7 @@ public static Dictionary GetProperties(string path, DirectoryEnume
/// Size: is the total size of enumerated objects.
/// Error: is the total number of errors encountered during enumeration.
///
- /// A dictionary mapping the keys mentioned above to their respective aggregated values.
+ /// Returns a dictionary mapping the keys mentioned above to their respective aggregated values.
/// Directory: is an object which has attribute without one.
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.DisableCompression.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.DisableCompression.cs
index 0e47ace95..af5f3a460 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.DisableCompression.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.DisableCompression.cs
@@ -20,6 +20,7 @@
*/
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -33,7 +34,7 @@ public sealed partial class DirectoryInfo
[SecurityCritical]
public void DisableCompression()
{
- Device.ToggleCompressionCore(Transaction, true, LongFullName, false, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(Transaction, true, LongFullName, false, PathFormat.LongFullPath);
}
}
}
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.EnableCompression.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.EnableCompression.cs
index 867e116ab..14b018e65 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.EnableCompression.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Compression/DirectoryInfo.EnableCompression.cs
@@ -20,6 +20,7 @@
*/
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -33,7 +34,7 @@ public sealed partial class DirectoryInfo
[SecurityCritical]
public void EnableCompression()
{
- Device.ToggleCompressionCore(Transaction, true, LongFullName, true, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(Transaction, true, LongFullName, true, PathFormat.LongFullPath);
}
}
}
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo CopyToMoveTo/DirectoryInfo.MoveTo.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo CopyToMoveTo/DirectoryInfo.MoveTo.cs
index 80c82ca75..6ad9a38c0 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo CopyToMoveTo/DirectoryInfo.MoveTo.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo CopyToMoveTo/DirectoryInfo.MoveTo.cs
@@ -67,7 +67,7 @@ public void MoveTo(string destinationPath)
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
/// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
///
- /// A new instance if the directory was completely moved.
+ /// Returns a new instance if the directory was completely moved.
///
///
///
@@ -100,7 +100,7 @@ public DirectoryInfo MoveTo(string destinationPath, PathFormat pathFormat)
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
/// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
///
- /// A new instance if the directory was completely moved.
+ /// Returns a new instance if the directory was completely moved.
///
///
///
@@ -133,7 +133,7 @@ public DirectoryInfo MoveTo(string destinationPath, MoveOptions moveOptions)
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
/// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
///
- /// A new instance if the directory was completely moved.
+ /// Returns a new instance if the directory was completely moved.
///
///
///
@@ -169,7 +169,7 @@ public DirectoryInfo MoveTo(string destinationPath, MoveOptions moveOptions, Pat
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
/// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
///
- /// A class with details of the Move action.
+ /// Returns a class with details of the Move action.
///
///
///
@@ -210,7 +210,7 @@ public CopyMoveResult MoveTo(string destinationPath, MoveOptions moveOptions, Co
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
/// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior.
///
- /// A class with details of the Move action.
+ /// Returns a class with details of the Move action.
///
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.CreateJunction.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.CreateJunction.cs
index 8388cce7f..03baf384d 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.CreateJunction.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.CreateJunction.cs
@@ -29,14 +29,10 @@ public sealed partial class DirectoryInfo
{
/// [AlphaFS] Converts the instance into a directory junction instance (similar to CMD command: "MKLINK /J").
///
- ///
- /// The directory must be empty and reside on a local volume.
- ///
- ///
- ///
- /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
- /// and a junction can link directories located on different local volumes on the same computer.
- /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
+ /// The directory must be empty and reside on a local volume.
+ /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
+ /// and a junction can link directories located on different local volumes on the same computer.
+ /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
///
///
///
@@ -57,14 +53,10 @@ public void CreateJunction(string junctionPath)
/// [AlphaFS] Converts the instance into a directory junction instance (similar to CMD command: "MKLINK /J").
///
- ///
- /// The directory must be empty and reside on a local volume.
- ///
- ///
- ///
- /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
- /// and a junction can link directories located on different local volumes on the same computer.
- /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
+ /// The directory must be empty and reside on a local volume.
+ /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
+ /// and a junction can link directories located on different local volumes on the same computer.
+ /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
///
///
///
@@ -86,14 +78,10 @@ public void CreateJunction(string junctionPath, PathFormat pathFormat)
/// [AlphaFS] Converts the instance into a directory junction instance (similar to CMD command: "MKLINK /J").
///
- ///
- /// The directory must be empty and reside on a local volume.
- ///
- ///
- ///
- /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
- /// and a junction can link directories located on different local volumes on the same computer.
- /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
+ /// The directory must be empty and reside on a local volume.
+ /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
+ /// and a junction can link directories located on different local volumes on the same computer.
+ /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
///
///
///
@@ -115,14 +103,10 @@ public void CreateJunction(string junctionPath, bool overwrite)
/// [AlphaFS] Converts the instance into a directory junction instance (similar to CMD command: "MKLINK /J").
///
- ///
- /// The directory must be empty and reside on a local volume.
- ///
- ///
- ///
- /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
- /// and a junction can link directories located on different local volumes on the same computer.
- /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
+ /// The directory must be empty and reside on a local volume.
+ /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
+ /// and a junction can link directories located on different local volumes on the same computer.
+ /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
///
///
///
@@ -145,14 +129,10 @@ public void CreateJunction(string junctionPath, bool overwrite, PathFormat pathF
/// [AlphaFS] Converts the instance into a directory junction instance (similar to CMD command: "MKLINK /J").
///
- ///
- /// The directory must be empty and reside on a local volume.
- ///
- ///
- ///
- /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
- /// and a junction can link directories located on different local volumes on the same computer.
- /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
+ /// The directory must be empty and reside on a local volume.
+ /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
+ /// and a junction can link directories located on different local volumes on the same computer.
+ /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
///
///
///
@@ -175,14 +155,10 @@ public void CreateJunction(string junctionPath, bool overwrite, bool copyTargetT
/// [AlphaFS] Converts the instance into a directory junction instance (similar to CMD command: "MKLINK /J").
///
- ///
- /// The directory must be empty and reside on a local volume.
- ///
- ///
- ///
- /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
- /// and a junction can link directories located on different local volumes on the same computer.
- /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
+ /// The directory must be empty and reside on a local volume.
+ /// MSDN: A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories,
+ /// and a junction can link directories located on different local volumes on the same computer.
+ /// Otherwise, junctions operate identically to hard links. Junctions are implemented through reparse points.
///
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.DeleteJunction.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.DeleteJunction.cs
index b9f8dcffb..5d3c55b4b 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.DeleteJunction.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo Junctions, Links/DirectoryInfo.DeleteJunction.cs
@@ -28,11 +28,7 @@ namespace Alphaleonis.Win32.Filesystem
public sealed partial class DirectoryInfo
{
/// [AlphaFS] Removes the directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
@@ -50,11 +46,7 @@ public void DeleteJunction()
/// [AlphaFS] Removes the directory junction.
- ///
- ///
- /// Only the directory junction is removed, not the target.
- ///
- /// A instance referencing the junction point.
+ /// Only the directory junction is removed, not the target.
///
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs
index a9954d7ec..8b4e4408f 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs
@@ -26,8 +26,8 @@ namespace Alphaleonis.Win32.Filesystem
{
public sealed partial class DirectoryInfo
{
- /// [AlphaFS] Returns an enumerable collection of instances for the directory.
- /// An enumerable collection of instances for the directory.
+ /// [AlphaFS] Returns an collection of instances for the directory.
+ /// Returns an collection of instances for the directory.
[SecurityCritical]
public IEnumerable EnumerateAlternateDataStreams()
{
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs
index 4550f8fac..295888c73 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs
@@ -30,8 +30,8 @@ public sealed partial class DirectoryInfo
{
#region .NET
- /// Returns an enumerable collection of directory information in the current directory.
- /// An enumerable collection of directories in the current directory.
+ /// Returns an collection of directory information in the current directory.
+ /// Returns an collection of directories in the current directory.
///
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs
index e81a9dacd..70758a26f 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs
@@ -31,8 +31,8 @@ public sealed partial class DirectoryInfo
{
#region .NET
- /// Returns an enumerable collection of file system information in the current directory.
- /// An enumerable collection of file system information in the current directory.
+ /// Returns an collection of file system information in the current directory.
+ /// Returns an collection of file system information in the current directory.
///
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs
index 4e090a1fd..f6a650527 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs
@@ -30,8 +30,8 @@ public sealed partial class DirectoryInfo
{
#region .NET
- /// Returns an enumerable collection of file information in the current directory.
- /// An enumerable collection of the files in the current directory.
+ /// Returns an collection of file information in the current directory.
+ /// Returns an collection of the files in the current directory.
///
///
///
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs
index d9b1ed2c2..2ad5a1ea1 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs
@@ -31,7 +31,7 @@ public sealed partial class DirectoryInfo
#region .NET
/// Returns the subdirectories of the current directory.
- /// An array of objects.
+ /// Returns an array of objects.
/// If there are no subdirectories, this method returns an empty array. This method is not recursive.
///
/// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
@@ -52,7 +52,7 @@ public DirectoryInfo[] GetDirectories()
/// Returns an array of directories in the current matching the given search criteria.
- /// An array of type matching .
+ /// Returns an array of type matching .
///
/// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
/// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array.
@@ -77,7 +77,7 @@ public DirectoryInfo[] GetDirectories(string searchPattern)
/// Returns an array of directories in the current matching the given search criteria and using a value to determine whether to search subdirectories.
- /// An array of type matching .
+ /// Returns an array of type matching .
/// If there are no subdirectories, or no subdirectories match the searchPattern parameter, this method returns an empty array.
///
/// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileIdInfo.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileIdInfo.cs
index 93c39af11..22f545237 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileIdInfo.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileIdInfo.cs
@@ -27,7 +27,7 @@ namespace Alphaleonis.Win32.Filesystem
public sealed partial class DirectoryInfo
{
/// [AlphaFS] Gets the unique identifier for the directory. The identifier is composed of a 64-bit volume serial number and 128-bit file system entry identifier.
- /// A instance containing the requested information.
+ /// Returns a instance containing the requested information.
/// Directory IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the file ID for a directory can change over time.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs
index 527abb4c8..34c283f89 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs
@@ -32,7 +32,7 @@ public sealed partial class DirectoryInfo
#region .NET
/// Returns an array of strongly typed entries representing all the files and subdirectories in a directory.
- /// An array of strongly typed entries.
+ /// Returns an array of strongly typed entries.
///
/// For subdirectories, the objects returned by this method can be cast to the derived class .
/// Use the value returned by the property to determine whether the represents a file or a directory.
@@ -62,7 +62,7 @@ public FileSystemInfo[] GetFileSystemInfos()
/// This parameter can contain a combination of valid literal path and wildcard
/// ( and ) characters, but does not support regular expressions.
///
- /// An array of strongly typed entries.
+ /// Returns an array of strongly typed entries.
///
/// For subdirectories, the objects returned by this method can be cast to the derived class .
/// Use the value returned by the property to determine whether the represents a file or a directory.
@@ -96,7 +96,7 @@ public FileSystemInfo[] GetFileSystemInfos(string searchPattern)
/// One of the enumeration values that specifies whether the
/// should include only the current directory or should include all subdirectories.
///
- /// An array of strongly typed entries.
+ /// Returns an array of strongly typed entries.
///
/// For subdirectories, the objects returned by this method can be cast to the derived class .
/// Use the value returned by the property to determine whether the represents a file or a directory.
diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs
index ea45fbe46..58ace0dca 100644
--- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs
+++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs
@@ -31,7 +31,7 @@ public sealed partial class DirectoryInfo
#region .NET
/// Returns a file list from the current directory.
- /// An array of type .
+ /// Returns an array of type .
/// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
/// If there are no files in the , this method returns an empty array.
///
@@ -58,7 +58,7 @@ public FileInfo[] GetFiles()
/// This parameter can contain a combination of valid literal path and wildcard
/// ( and ) characters, but does not support regular expressions.
///
- /// An array of type .
+ /// Returns an array of type .
/// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
/// If there are no files in the , this method returns an empty array.
///
@@ -89,7 +89,7 @@ public FileInfo[] GetFiles(string searchPattern)
/// One of the enumeration values that specifies whether the
/// should include only the current directory or should include all subdirectories.
///
- /// An array of type .
+ /// Returns an array of type .
/// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required.
/// If there are no files in the , this method returns an empty array.
///
diff --git a/AlphaFS/Device/DiskSpaceInfo.cs b/AlphaFS/Filesystem/DiskSpaceInfo.cs
similarity index 85%
rename from AlphaFS/Device/DiskSpaceInfo.cs
rename to AlphaFS/Filesystem/DiskSpaceInfo.cs
index 177a0f6df..41155a8af 100644
--- a/AlphaFS/Device/DiskSpaceInfo.cs
+++ b/AlphaFS/Filesystem/DiskSpaceInfo.cs
@@ -35,46 +35,58 @@ namespace Alphaleonis.Win32.Filesystem
[SecurityCritical]
public sealed class DiskSpaceInfo
{
+ #region Fields
+
+ [NonSerialized] private CultureInfo _cultureInfo;
[NonSerialized] private readonly bool _initGetClusterInfo = true;
[NonSerialized] private readonly bool _initGetSpaceInfo = true;
- [NonSerialized] private readonly CultureInfo _cultureInfo = CultureInfo.CurrentCulture;
[NonSerialized] private readonly bool _continueOnAccessError;
+ #endregion // Private Fields
+
+
+ #region Constructors
/// Initializes a DiskSpaceInfo instance.
- /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share
/// This is a Lazyloading object; call to populate all properties first before accessing.
+ /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")]
[SecurityCritical]
- public DiskSpaceInfo(string drivePath)
+ public DiskSpaceInfo(string driveName)
{
- if (Utils.IsNullOrWhiteSpace(drivePath))
- throw new ArgumentNullException("drivePath");
+ if (null == driveName)
+ throw new ArgumentNullException("driveName");
+
+ if (driveName.Trim().Length == 0)
+ throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "driveName");
+
+ driveName = driveName.Length == 1 ? driveName + Path.VolumeSeparatorChar : Path.GetPathRoot(driveName, false);
- drivePath = drivePath.Length == 1 ? drivePath + Path.VolumeSeparatorChar : Path.GetPathRoot(drivePath, false);
+ if (Utils.IsNullOrWhiteSpace(driveName))
+ throw new ArgumentException(Resources.InvalidDriveLetterArgument, "driveName");
- if (Utils.IsNullOrWhiteSpace(drivePath))
- throw new ArgumentException(Resources.InvalidDriveLetterArgument, "drivePath");
+
+ _cultureInfo = CultureInfo.CurrentCulture;
// MSDN:
// If this parameter is a UNC name, it must include a trailing backslash (for example, "\\MyServer\MyShare\").
- // Furthermore, a drive specification must have a trailing backslash (for example, "C:\").
+ // Furthermore, a drive specification must have a trailing backslash (for example, C:\).
// The calling application must have FILE_LIST_DIRECTORY access rights for this directory.
- DriveName = Path.AddTrailingDirectorySeparator(drivePath, false);
+ DriveName = Path.AddTrailingDirectorySeparator(driveName, false);
}
-
+
/// Initializes a DiskSpaceInfo instance.
- /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share
+ /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share
/// null gets both size- and disk cluster information. true Get only disk cluster information, false Get only size information.
/// Refreshes the state of the object.
/// true suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
[SecurityCritical]
- public DiskSpaceInfo(string drivePath, bool? spaceInfoType, bool refresh, bool continueOnException) : this(drivePath)
+ public DiskSpaceInfo(string driveName, bool? spaceInfoType, bool refresh, bool continueOnException) : this(driveName)
{
- if (spaceInfoType == null)
+ if (null == spaceInfoType)
{
_initGetSpaceInfo = true;
_initGetClusterInfo = true;
@@ -92,6 +104,8 @@ public DiskSpaceInfo(string drivePath, bool? spaceInfoType, bool refresh, bool c
Refresh();
}
+ #endregion // Constructors
+
/// Indicates the amount of available free space on a drive, formatted as percentage.
public string AvailableFreeSpacePercent
@@ -118,8 +132,7 @@ public long ClusterSize
/// Gets the name of a drive.
- /// The name of the drive.
- /// This property is the name assigned to the drive, such as C:\ or E:\
+ /// This property is the name assigned to the drive, such as: C:\ or D:\
public string DriveName { get; private set; }
@@ -184,6 +197,9 @@ public void Refresh()
{
Reset();
+ _cultureInfo = CultureInfo.CurrentCulture;
+
+
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
{
int lastError;
@@ -195,7 +211,7 @@ public void Refresh()
{
long freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes;
- var success = NativeMethods.GetDiskFreeSpaceEx(DriveName, out freeBytesAvailable, out totalNumberOfBytes, out totalNumberOfFreeBytes);
+ var success = Device.NativeMethods.GetDiskFreeSpaceEx(DriveName, out freeBytesAvailable, out totalNumberOfBytes, out totalNumberOfFreeBytes);
lastError = Marshal.GetLastWin32Error();
@@ -216,7 +232,7 @@ public void Refresh()
int sectorsPerCluster, bytesPerSector, numberOfFreeClusters;
uint totalNumberOfClusters;
- var success = NativeMethods.GetDiskFreeSpace(DriveName, out sectorsPerCluster, out bytesPerSector, out numberOfFreeClusters, out totalNumberOfClusters);
+ var success = Device.NativeMethods.GetDiskFreeSpace(DriveName, out sectorsPerCluster, out bytesPerSector, out numberOfFreeClusters, out totalNumberOfClusters);
lastError = Marshal.GetLastWin32Error();
@@ -255,7 +271,7 @@ private void Reset()
/// Returns the drive name.
- /// A string that represents this object.
+ /// Returns a string that represents this object.
public override string ToString()
{
return DriveName;
diff --git a/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs b/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs
index 16ffb9fb3..aab6c884b 100644
--- a/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs
+++ b/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs
@@ -23,6 +23,7 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
namespace Alphaleonis.Win32.Filesystem
@@ -31,7 +32,7 @@ namespace Alphaleonis.Win32.Filesystem
/// Both ERROR_ALREADY_EXISTS and ERROR_FILE_EXISTS can cause this Exception.
///
[Serializable]
- public class AlreadyExistsException : System.IO.IOException
+ public class AlreadyExistsException : IOException
{
private static readonly int ErrorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_ALREADY_EXISTS);
private static readonly string ErrorText = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_ALREADY_EXISTS, new Win32Exception((int) Win32Errors.ERROR_ALREADY_EXISTS).Message.Trim().TrimEnd('.').Trim());
diff --git a/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs b/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs
index 686bb9b52..182468d12 100644
--- a/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs
+++ b/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs
@@ -23,13 +23,14 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
namespace Alphaleonis.Win32.Filesystem
{
/// [AlphaFS] The requested operation could not be completed because the device is not ready.
[Serializable]
- public class DeviceNotReadyException : System.IO.IOException
+ public class DeviceNotReadyException : IOException
{
private static readonly int ErrorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_NOT_READY);
private static readonly string ErrorText = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_NOT_READY, new Win32Exception((int) Win32Errors.ERROR_NOT_READY).Message.Trim().TrimEnd('.').Trim());
diff --git a/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs b/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs
index c94546afa..fdb071840 100644
--- a/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs
+++ b/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs
@@ -23,13 +23,14 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
namespace Alphaleonis.Win32.Filesystem
{
/// [AlphaFS] The operation could not be completed because the directory is not empty.
[Serializable]
- public class DirectoryNotEmptyException : System.IO.IOException
+ public class DirectoryNotEmptyException : IOException
{
private static readonly int ErrorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_DIR_NOT_EMPTY);
private static readonly string ErrorText = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_DIR_NOT_EMPTY, new Win32Exception((int) Win32Errors.ERROR_DIR_NOT_EMPTY).Message.Trim().TrimEnd('.').Trim());
diff --git a/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs b/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs
index 18da64069..ef3dac739 100644
--- a/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs
+++ b/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs
@@ -22,13 +22,14 @@
using System;
using System.ComponentModel;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
namespace Alphaleonis.Win32.Filesystem
{
/// [AlphaFS] The file or directory was not a reparse point.
[Serializable]
- public class NotAReparsePointException : System.IO.IOException
+ public class NotAReparsePointException : IOException
{
private static readonly int ErrorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_NOT_A_REPARSE_POINT);
private static readonly string ErrorText = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_NOT_A_REPARSE_POINT, new Win32Exception((int) Win32Errors.ERROR_NOT_A_REPARSE_POINT).Message.Trim().TrimEnd('.').Trim());
diff --git a/AlphaFS/Filesystem/Exceptions/NotSameDeviceException.cs b/AlphaFS/Filesystem/Exceptions/NotSameDeviceException.cs
index 3f9aa437f..b96ac4b2e 100644
--- a/AlphaFS/Filesystem/Exceptions/NotSameDeviceException.cs
+++ b/AlphaFS/Filesystem/Exceptions/NotSameDeviceException.cs
@@ -23,13 +23,14 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
namespace Alphaleonis.Win32.Filesystem
{
/// [AlphaFS] The exception that is thrown when an attempt perform an operation across difference devices when this is not supported.
[Serializable]
- public class NotSameDeviceException : System.IO.IOException
+ public class NotSameDeviceException : IOException
{
private static readonly int ErrorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_NOT_SAME_DEVICE);
private static readonly string ErrorText = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_NOT_SAME_DEVICE, new Win32Exception((int)Win32Errors.ERROR_NOT_SAME_DEVICE).Message.Trim().TrimEnd('.').Trim());
diff --git a/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs b/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs
index 04e2ff2b4..7f540d3ed 100644
--- a/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs
+++ b/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs
@@ -22,13 +22,14 @@
using System;
using System.ComponentModel;
using System.Globalization;
+using System.IO;
using System.Runtime.Serialization;
namespace Alphaleonis.Win32.Filesystem
{
/// [AlphaFS] The function attempted to use a name that is reserved for use by another transaction.
[Serializable]
- public class UnrecognizedReparsePointException : System.IO.IOException
+ public class UnrecognizedReparsePointException : IOException
{
private static readonly int ErrorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_INVALID_REPARSE_DATA);
private static readonly string ErrorText = string.Format(CultureInfo.InvariantCulture, "({0}) {1}", Win32Errors.ERROR_INVALID_REPARSE_DATA, new Win32Exception((int) Win32Errors.ERROR_INVALID_REPARSE_DATA).Message.Trim().TrimEnd('.').Trim());
diff --git a/AlphaFS/Filesystem/File Class/File Compression/File.Compress.cs b/AlphaFS/Filesystem/File Class/File Compression/File.Compress.cs
index 87486dca4..af85c3164 100644
--- a/AlphaFS/Filesystem/File Class/File Compression/File.Compress.cs
+++ b/AlphaFS/Filesystem/File Class/File Compression/File.Compress.cs
@@ -30,7 +30,7 @@ public static partial class File
[SecurityCritical]
public static void Compress(string path)
{
- Device.ToggleCompressionCore(null, false, path, true, PathFormat.RelativePath);
+ Device.FilesystemHelper.ToggleCompressionCore(null, false, path, true, PathFormat.RelativePath);
}
@@ -40,7 +40,7 @@ public static void Compress(string path)
[SecurityCritical]
public static void Compress(string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(null, false, path, true, pathFormat);
+ Device.FilesystemHelper.ToggleCompressionCore(null, false, path, true, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/File Class/File Compression/File.CompressTransacted.cs b/AlphaFS/Filesystem/File Class/File Compression/File.CompressTransacted.cs
index a9d9dbe64..03a04a9e1 100644
--- a/AlphaFS/Filesystem/File Class/File Compression/File.CompressTransacted.cs
+++ b/AlphaFS/Filesystem/File Class/File Compression/File.CompressTransacted.cs
@@ -20,6 +20,7 @@
*/
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -31,7 +32,7 @@ public static partial class File
[SecurityCritical]
public static void CompressTransacted(KernelTransaction transaction, string path)
{
- Device.ToggleCompressionCore(transaction, false, path, true, PathFormat.RelativePath);
+ FilesystemHelper.ToggleCompressionCore(transaction, false, path, true, PathFormat.RelativePath);
}
@@ -42,7 +43,7 @@ public static void CompressTransacted(KernelTransaction transaction, string path
[SecurityCritical]
public static void CompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(transaction, false, path, true, pathFormat);
+ FilesystemHelper.ToggleCompressionCore(transaction, false, path, true, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/File Class/File Compression/File.Decompress.cs b/AlphaFS/Filesystem/File Class/File Compression/File.Decompress.cs
index 2cd02b3d4..3e64b1dbb 100644
--- a/AlphaFS/Filesystem/File Class/File Compression/File.Decompress.cs
+++ b/AlphaFS/Filesystem/File Class/File Compression/File.Decompress.cs
@@ -30,7 +30,7 @@ public static partial class File
[SecurityCritical]
public static void Decompress(string path)
{
- Device.ToggleCompressionCore(null, false, path, false, PathFormat.RelativePath);
+ Device.FilesystemHelper.ToggleCompressionCore(null, false, path, false, PathFormat.RelativePath);
}
@@ -40,7 +40,7 @@ public static void Decompress(string path)
[SecurityCritical]
public static void Decompress(string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(null, false, path, false, pathFormat);
+ Device.FilesystemHelper.ToggleCompressionCore(null, false, path, false, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/File Class/File Compression/File.DecompressTransacted.cs b/AlphaFS/Filesystem/File Class/File Compression/File.DecompressTransacted.cs
index bbc261852..f86dcaa18 100644
--- a/AlphaFS/Filesystem/File Class/File Compression/File.DecompressTransacted.cs
+++ b/AlphaFS/Filesystem/File Class/File Compression/File.DecompressTransacted.cs
@@ -20,6 +20,7 @@
*/
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -31,7 +32,7 @@ public static partial class File
[SecurityCritical]
public static void DecompressTransacted(KernelTransaction transaction, string path)
{
- Device.ToggleCompressionCore(transaction, false, path, false, PathFormat.RelativePath);
+ FilesystemHelper.ToggleCompressionCore(transaction, false, path, false, PathFormat.RelativePath);
}
@@ -42,7 +43,7 @@ public static void DecompressTransacted(KernelTransaction transaction, string pa
[SecurityCritical]
public static void DecompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
{
- Device.ToggleCompressionCore(transaction, false, path, false, pathFormat);
+ FilesystemHelper.ToggleCompressionCore(transaction, false, path, false, pathFormat);
}
}
}
diff --git a/AlphaFS/Filesystem/File Class/File Core Methods/File.EnumerateHardLinksCore.cs b/AlphaFS/Filesystem/File Class/File Core Methods/File.EnumerateHardLinksCore.cs
index eb65f103d..c13190d40 100644
--- a/AlphaFS/Filesystem/File Class/File Core Methods/File.EnumerateHardLinksCore.cs
+++ b/AlphaFS/Filesystem/File Class/File Core Methods/File.EnumerateHardLinksCore.cs
@@ -61,7 +61,7 @@ internal static IEnumerable EnumerateHardLinksCore(KernelTransaction tra
{
var lastError = Marshal.GetLastWin32Error();
- if (!NativeMethods.IsValidHandle(safeHandle, false))
+ if (!Utils.IsValidHandle(safeHandle, false))
{
switch ((uint) lastError)
{
diff --git a/AlphaFS/Filesystem/File Class/File Core Methods/File.GetLinkTargetInfoCore.cs b/AlphaFS/Filesystem/File Class/File Core Methods/File.GetLinkTargetInfoCore.cs
index 89c419d38..9122cc6dd 100644
--- a/AlphaFS/Filesystem/File Class/File Core Methods/File.GetLinkTargetInfoCore.cs
+++ b/AlphaFS/Filesystem/File Class/File Core Methods/File.GetLinkTargetInfoCore.cs
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -54,7 +55,7 @@ internal static LinkTargetInfo GetLinkTargetInfoCore(KernelTransaction transacti
using (var safeHandle = CreateFileCore(transaction, false, reparsePath, eAttributes, null, FileMode.Open, 0, FileShare.ReadWrite, pathFormat != PathFormat.LongFullPath, continueOnException, pathFormat))
- return null != safeHandle ? Device.GetLinkTargetInfo(safeHandle, reparsePath) : null;
+ return null != safeHandle ? FilesystemHelper.GetLinkTargetInfo(safeHandle, reparsePath) : null;
}
}
}
diff --git a/AlphaFS/Filesystem/File Class/File Junctions, Links/File.CreateSymbolicLink.cs b/AlphaFS/Filesystem/File Class/File Junctions, Links/File.CreateSymbolicLink.cs
index 74fe40e12..7d7fe2826 100644
--- a/AlphaFS/Filesystem/File Class/File Junctions, Links/File.CreateSymbolicLink.cs
+++ b/AlphaFS/Filesystem/File Class/File Junctions, Links/File.CreateSymbolicLink.cs
@@ -31,7 +31,7 @@ public static partial class File
#region Obsolete
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK") to a file.
- /// See to run this method in an elevated state.
+ /// See to run this method from an elevated state.
///
///
/// The operating system is older than Windows Vista.
@@ -48,7 +48,7 @@ public static void CreateSymbolicLink(string symlinkFileName, string targetFileN
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK") to a file.
- /// See to run this method in an elevated state.
+ /// See to run this method from an elevated state.
///
///
/// The operating system is older than Windows Vista.
@@ -66,7 +66,7 @@ public static void CreateSymbolicLink(string symlinkFileName, string targetFileN
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK") to a file as a transacted operation.
- /// See to run this method in an elevated state.
+ /// See to run this method from an elevated state.
///
///
/// The operating system is older than Windows Vista.
@@ -84,7 +84,7 @@ public static void CreateSymbolicLinkTransacted(KernelTransaction transaction, s
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK") to a file as a transacted operation.
- /// See to run this method in an elevated state.
+ /// See to run this method from an elevated state.
///
///
/// The operating system is older than Windows Vista.
@@ -105,13 +105,12 @@ public static void CreateSymbolicLinkTransacted(KernelTransaction transaction, s
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK") to a file.
- ///
///
- /// Symbolic links can point to a non-existent target.
- /// When creating a symbolic link, the operating system does not check to see if the target exists.
- /// Symbolic links are reparse points.
- /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
- /// See to run this method in an elevated state.
+ /// Symbolic links can point to a non-existent target.
+ /// When creating a symbolic link, the operating system does not check to see if the target exists.
+ /// Symbolic links are reparse points.
+ /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
+ /// See to run this method from an elevated state.
///
///
///
@@ -128,13 +127,12 @@ public static void CreateSymbolicLink(string symlinkFileName, string targetFileN
/// [AlphaFS] Creates a symbolic link (similar to CMD command: "MKLINK") to a file.
- ///
///
- /// Symbolic links can point to a non-existent target.
- /// When creating a symbolic link, the operating system does not check to see if the target exists.
- /// Symbolic links are reparse points.
- /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
- /// See to run this method in an elevated state.
+ /// Symbolic links can point to a non-existent target.
+ /// When creating a symbolic link, the operating system does not check to see if the target exists.
+ /// Symbolic links are reparse points.
+ /// There is a maximum of 31 reparse points (and therefore symbolic links) allowed in a particular path.
+ /// See to run this method from an elevated state.
///
///
///
diff --git a/AlphaFS/Filesystem/File Class/File.AppendText.cs b/AlphaFS/Filesystem/File Class/File.AppendText.cs
index f68248493..68d40c63b 100644
--- a/AlphaFS/Filesystem/File Class/File.AppendText.cs
+++ b/AlphaFS/Filesystem/File Class/File.AppendText.cs
@@ -31,7 +31,7 @@ public static partial class File
#region .NET
/// Creates a that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
- /// A stream writer that appends UTF-8 encoded text to the specified file or to a new file.
+ /// Returns a stream writer that appends UTF-8 encoded text to the specified file or to a new file.
/// path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
/// path is null.
/// The specified path is invalid (for example, the directory doesn�t exist or it is on an unmapped drive).
@@ -48,7 +48,7 @@ public static StreamWriter AppendText(string path)
/// [AlphaFS] Creates a that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
- /// A stream writer that appends UTF-8 encoded text to the specified file or to a new file.
+ /// Returns a stream writer that appends UTF-8 encoded text to the specified file or to a new file.
/// path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
/// path is null.
/// The specified path is invalid (for example, the directory doesn�t exist or it is on an unmapped drive).
@@ -64,7 +64,7 @@ public static StreamWriter AppendText(string path, PathFormat pathFormat)
/// [AlphaFS] Creates a that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
- /// A stream writer that appends UTF-8 encoded text to the specified file or to a new file.
+ /// Returns a stream writer that appends UTF-8 encoded text to the specified file or to a new file.
/// path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
/// path is null.
/// The specified path is invalid (for example, the directory doesn�t exist or it is on an unmapped drive).
@@ -81,7 +81,7 @@ public static StreamWriter AppendText(string path, Encoding encoding, PathFormat
/// [AlphaFS] Creates a that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
- /// A stream writer that appends UTF-8 encoded text to the specified file or to a new file.
+ /// Returns a stream writer that appends UTF-8 encoded text to the specified file or to a new file.
/// path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
/// path is null.
/// The specified path is invalid (for example, the directory doesn�t exist or it is on an unmapped drive).
diff --git a/AlphaFS/Filesystem/File Class/File.CreateText.cs b/AlphaFS/Filesystem/File Class/File.CreateText.cs
index a3e7a542f..72546370d 100644
--- a/AlphaFS/Filesystem/File Class/File.CreateText.cs
+++ b/AlphaFS/Filesystem/File Class/File.CreateText.cs
@@ -20,9 +20,9 @@
*/
using System.Diagnostics.CodeAnalysis;
+using System.IO;
using System.Security;
using System.Text;
-using StreamWriter = System.IO.StreamWriter;
namespace Alphaleonis.Win32.Filesystem
{
@@ -32,7 +32,7 @@ public static partial class File
/// Creates or opens a file for writing UTF-8 encoded text.
/// The file to be opened for writing.
- /// A StreamWriter that writes to the specified file using UTF-8 encoding.
+ /// Returns a StreamWriter that writes to the specified file using UTF-8 encoding.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
public static StreamWriter CreateText(string path)
@@ -46,7 +46,7 @@ public static StreamWriter CreateText(string path)
/// [AlphaFS] Creates or opens a file for writing UTF-8 encoded text.
/// The file to be opened for writing.
/// Indicates the format of the path parameter(s).
- /// A StreamWriter that writes to the specified file using UTF-8 encoding.
+ /// Returns a StreamWriter that writes to the specified file using UTF-8 encoding.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
public static StreamWriter CreateText(string path, PathFormat pathFormat)
@@ -71,7 +71,7 @@ public static StreamWriter CreateText(string path, Encoding encoding)
/// The file to be opened for writing.
/// The encoding that is applied to the contents of the file.
/// Indicates the format of the path parameter(s).
- /// A StreamWriter that writes to the specified file using UTF-8 encoding.
+ /// Returns a StreamWriter that writes to the specified file using UTF-8 encoding.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
public static StreamWriter CreateText(string path, Encoding encoding, PathFormat pathFormat)
diff --git a/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs
index 14a2f1c47..cc7284ccb 100644
--- a/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs
+++ b/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs
@@ -28,7 +28,7 @@ public static partial class File
{
/// [AlphaFS] Enumerates all altername datastreams of the specified file.
/// The path to the file to enumerate streams of.
- /// An enumeration of instances.
+ /// Returns an enumeration of instances.
[SecurityCritical]
public static IEnumerable EnumerateAlternateDataStreams(string path)
{
diff --git a/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs b/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs
index 148556b34..2b5e69066 100644
--- a/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs
+++ b/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs
@@ -31,7 +31,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class File
{
/// Gets a object that encapsulates the access control list (ACL) entries for a specified file.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
@@ -72,7 +72,7 @@ public static FileSecurity GetAccessControl(string path, AccessControlSections i
/// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
@@ -87,7 +87,7 @@ public static FileSecurity GetAccessControl(string path, AccessControlSections i
/// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file handle.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
@@ -100,7 +100,7 @@ public static FileSecurity GetAccessControl(SafeFileHandle handle)
/// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file handle.
- /// A object that encapsulates the access control rules for the file described by the parameter.
+ /// Returns a object that encapsulates the access control rules for the file described by the parameter.
///
///
///
diff --git a/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandle.cs b/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandle.cs
index d2ecc950f..b3556b077 100644
--- a/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandle.cs
+++ b/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandle.cs
@@ -28,7 +28,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class File
{
/// [AlphaFS] Retrieves file information for the specified file.
- /// A object containing the requested information.
+ /// Returns a object containing the requested information.
/// File IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the file ID for a file can change over time.
/// The path to the file.
[SecurityCritical]
@@ -39,7 +39,7 @@ public static ByHandleFileInfo GetFileInfoByHandle(string path)
/// [AlphaFS] Retrieves file information for the specified file.
- /// A object containing the requested information.
+ /// Returns a object containing the requested information.
/// File IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the file ID for a file can change over time.
/// The path to the file.
/// Indicates the format of the path parameter(s).
@@ -51,13 +51,13 @@ public static ByHandleFileInfo GetFileInfoByHandle(string path, PathFormat pathF
/// [AlphaFS] Retrieves file information for the specified .
- /// A object containing the requested information.
- /// A object containing the requested information.
+ /// Returns a object containing the requested information.
+ /// Returns a object containing the requested information.
/// A connected to the open file or directory from which to retrieve the information.
[SecurityCritical]
public static ByHandleFileInfo GetFileInfoByHandle(SafeFileHandle handle)
{
- NativeMethods.IsValidHandle(handle);
+ Utils.IsValidHandle(handle);
NativeMethods.BY_HANDLE_FILE_INFORMATION info;
diff --git a/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs b/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs
index 8d1c03dfa..d0bbbc279 100644
--- a/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs
+++ b/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs
@@ -30,7 +30,7 @@ public static partial class File
/// [AlphaFS] Opens the specified file for reading purposes bypassing security attributes.
/// The file path to open.
/// Indicates the format of the path parameter(s).
- /// A on the specified path, having the read-only mode and sharing options.
+ /// Returns a on the specified path, having the read-only mode and sharing options.
[SecurityCritical]
public static FileStream OpenBackupRead(string path, PathFormat pathFormat)
{
@@ -40,7 +40,7 @@ public static FileStream OpenBackupRead(string path, PathFormat pathFormat)
/// [AlphaFS] Opens the specified file for reading purposes bypassing security attributes. This method is simpler to use then BackupFileStream to read only file's data stream.
/// The file path to open.
- /// A on the specified path, having the read-only mode and sharing options.
+ /// Returns a on the specified path, having the read-only mode and sharing options.
[SecurityCritical]
public static FileStream OpenBackupRead(string path)
{
diff --git a/AlphaFS/Filesystem/File Class/File.OpenRead.cs b/AlphaFS/Filesystem/File Class/File.OpenRead.cs
index c726e0448..8d6deeb71 100644
--- a/AlphaFS/Filesystem/File Class/File.OpenRead.cs
+++ b/AlphaFS/Filesystem/File Class/File.OpenRead.cs
@@ -21,7 +21,6 @@
using System.IO;
using System.Security;
-using FileStream = System.IO.FileStream;
namespace Alphaleonis.Win32.Filesystem
{
@@ -31,7 +30,7 @@ public static partial class File
/// Opens an existing file for reading.
/// The file to be opened for reading.
- /// A read-only on the specified path.
+ /// Returns a read-only on the specified path.
///
/// This method is equivalent to the (string, FileMode, FileAccess, FileShare) constructor overload with a
/// value of Open, a value of Read and a value of Read.
@@ -48,7 +47,7 @@ public static FileStream OpenRead(string path)
/// [AlphaFS] Opens an existing file for reading.
/// The file to be opened for reading.
/// Indicates the format of the path parameter(s).
- /// A read-only on the specified path.
+ /// Returns a read-only on the specified path.
///
/// This method is equivalent to the (string, FileMode, FileAccess, FileShare) constructor overload with a
/// value of Open, a value of Read and a value of Read.
diff --git a/AlphaFS/Filesystem/File Class/File.OpenText.cs b/AlphaFS/Filesystem/File Class/File.OpenText.cs
index 483e0a2e0..1a1b224de 100644
--- a/AlphaFS/Filesystem/File Class/File.OpenText.cs
+++ b/AlphaFS/Filesystem/File Class/File.OpenText.cs
@@ -32,7 +32,7 @@ public static partial class File
/// Opens an existing UTF-8 encoded text file for reading.
/// The file to be opened for reading.
- /// A on the specified path.
+ /// Returns a on the specified path.
/// This method is equivalent to the (String) constructor overload.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
@@ -47,7 +47,7 @@ public static StreamReader OpenText(string path)
/// [AlphaFS] Opens an existing UTF-8 encoded text file for reading.
/// The file to be opened for reading.
/// Indicates the format of the path parameter(s).
- /// A on the specified path.
+ /// Returns a on the specified path.
/// This method is equivalent to the (String) constructor overload.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
@@ -61,7 +61,7 @@ public static StreamReader OpenText(string path, PathFormat pathFormat)
/// The file to be opened for reading.
/// The applied to the contents of the file.
/// Indicates the format of the path parameter(s).
- /// A on the specified path.
+ /// Returns a on the specified path.
/// This method is equivalent to the (String) constructor overload.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
@@ -74,7 +74,7 @@ public static StreamReader OpenText(string path, Encoding encoding, PathFormat p
/// [AlphaFS] Opens an existing encoded text file for reading.
/// The file to be opened for reading.
/// The applied to the contents of the file.
- /// A on the specified path.
+ /// Returns a on the specified path.
/// This method is equivalent to the (String) constructor overload.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/File Class/File.OpenWrite.cs b/AlphaFS/Filesystem/File Class/File.OpenWrite.cs
index 1a57040f4..7ba11de26 100644
--- a/AlphaFS/Filesystem/File Class/File.OpenWrite.cs
+++ b/AlphaFS/Filesystem/File Class/File.OpenWrite.cs
@@ -30,7 +30,7 @@ public static partial class File
/// Opens an existing file or creates a new file for writing.
/// The file to be opened for writing.
- /// An unshared object on the specified path with access.
+ /// Returns an unshared object on the specified path with access.
/// This method is equivalent to the (String, FileMode, FileAccess, FileShare) constructor overload with file mode set to OpenOrCreate, the access set to Write, and the share mode set to None.
[SecurityCritical]
public static FileStream OpenWrite(string path)
@@ -44,7 +44,7 @@ public static FileStream OpenWrite(string path)
/// [AlphaFS] Opens an existing file or creates a new file for writing.
/// The file to be opened for writing.
/// Indicates the format of the path parameter(s).
- /// An unshared object on the specified path with access.
+ /// Returns an unshared object on the specified path with access.
/// This method is equivalent to the (String, FileMode, FileAccess, FileShare) constructor overload with file mode set to OpenOrCreate, the access set to Write, and the share mode set to None.
[SecurityCritical]
public static FileStream OpenWrite(string path, PathFormat pathFormat)
diff --git a/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs b/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs
index 5e853dbe3..5f3a3626a 100644
--- a/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs
+++ b/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs
@@ -28,8 +28,8 @@ public static partial class File
#region .NET
/// Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
+ /// Returns a byte array containing the contents of the file.
/// The file to open for reading.
- /// A byte array containing the contents of the file.
[SecurityCritical]
public static byte[] ReadAllBytes(string path)
{
@@ -40,9 +40,9 @@ public static byte[] ReadAllBytes(string path)
/// [AlphaFS] Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
+ /// Returns a byte array containing the contents of the file.
/// The file to open for reading.
/// Indicates the format of the path parameter(s).
- /// A byte array containing the contents of the file.
[SecurityCritical]
public static byte[] ReadAllBytes(string path, PathFormat pathFormat)
{
diff --git a/AlphaFS/Filesystem/File Class/File.cs b/AlphaFS/Filesystem/File Class/File.cs
index bebb71128..63cd51732 100644
--- a/AlphaFS/Filesystem/File Class/File.cs
+++ b/AlphaFS/Filesystem/File Class/File.cs
@@ -19,6 +19,7 @@
* THE SOFTWARE.
*/
+
namespace Alphaleonis.Win32.Filesystem
{
/// Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of FileStream objects.
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Compress.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Compress.cs
index 9aac40328..e63eb1818 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Compress.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Compress.cs
@@ -20,6 +20,7 @@
*/
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -29,7 +30,7 @@ partial class FileInfo
[SecurityCritical]
public void Compress()
{
- Device.ToggleCompressionCore(Transaction, false, LongFullName, true, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(Transaction, false, LongFullName, true, PathFormat.LongFullPath);
}
}
}
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Decompress.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Decompress.cs
index 11c4ee59a..9087e933e 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Decompress.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo Compression/FileInfo.Decompress.cs
@@ -20,6 +20,7 @@
*/
using System.Security;
+using Alphaleonis.Win32.Device;
namespace Alphaleonis.Win32.Filesystem
{
@@ -29,7 +30,7 @@ partial class FileInfo
[SecurityCritical]
public void Decompress()
{
- Device.ToggleCompressionCore(Transaction, false, LongFullName, false, PathFormat.LongFullPath);
+ FilesystemHelper.ToggleCompressionCore(Transaction, false, LongFullName, false, PathFormat.LongFullPath);
}
}
}
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo CopyToMoveTo/FileInfo.CopyTo.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo CopyToMoveTo/FileInfo.CopyTo.cs
index aae3bea4a..5c6db15c8 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo CopyToMoveTo/FileInfo.CopyTo.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo CopyToMoveTo/FileInfo.CopyTo.cs
@@ -30,7 +30,7 @@ partial class FileInfo
#region .NET
/// Copies an existing file to a new file, disallowing the overwriting of an existing file.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Use this method to prevent overwriting of an existing file by default.
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
@@ -58,7 +58,7 @@ public FileInfo CopyTo(string destinationPath)
/// Copies an existing file to a new file, allowing the overwriting of an existing file.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Use this method to allow or prevent overwriting of an existing file.
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
@@ -89,7 +89,7 @@ public FileInfo CopyTo(string destinationPath, bool overwrite)
/// [AlphaFS] Copies an existing file to a new file, disallowing the overwriting of an existing file.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Use this method to prevent overwriting of an existing file by default.
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
@@ -118,7 +118,7 @@ public FileInfo CopyTo(string destinationPath, PathFormat pathFormat)
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Use this method to allow or prevent overwriting of an existing file.
/// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method.
@@ -148,7 +148,7 @@ public FileInfo CopyTo(string destinationPath, bool overwrite, PathFormat pathFo
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Option is recommended for very large file transfers.
/// Use this method to allow or prevent overwriting of an existing file.
@@ -178,7 +178,7 @@ public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions)
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Option is recommended for very large file transfers.
/// Use this method to allow or prevent overwriting of an existing file.
@@ -209,7 +209,7 @@ public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, PathForm
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Option is recommended for very large file transfers.
/// Use this method to allow or prevent overwriting of an existing file.
@@ -225,7 +225,7 @@ public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, PathForm
///
/// The name of the new file to copy to.
/// that specify how the file is to be copied.
- /// true if original Timestamps must be preserved, false otherwise.
+ /// true if original Timestamps must be preserved; otherwise, false.
[SecurityCritical]
public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool preserveDates)
{
@@ -240,7 +240,7 @@ public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool pre
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A new instance with a fully qualified path.
+ /// Returns a new instance with a fully qualified path.
///
/// Option is recommended for very large file transfers.
/// Use this method to allow or prevent overwriting of an existing file.
@@ -256,7 +256,7 @@ public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool pre
///
/// The name of the new file to copy to.
/// that specify how the file is to be copied.
- /// true if original Timestamps must be preserved, false otherwise.
+ /// true if original Timestamps must be preserved; otherwise, false.
/// Indicates the format of the path parameter(s).
[SecurityCritical]
public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool preserveDates, PathFormat pathFormat)
@@ -272,7 +272,7 @@ public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool pre
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A class with details of the Copy action.
+ /// Returns a class with details of the Copy action.
/// and the possibility of notifying the application of its progress through a callback function.
///
/// Option is recommended for very large file transfers.
@@ -305,7 +305,7 @@ public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, Co
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A class with details of the Copy action.
+ /// Returns a class with details of the Copy action.
///
/// Option is recommended for very large file transfers.
/// Use this method to allow or prevent overwriting of an existing file.
@@ -338,7 +338,7 @@ public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, Co
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A class with details of the Copy action.
+ /// Returns a class with details of the Copy action.
/// and the possibility of notifying the application of its progress through a callback function.
///
/// Option is recommended for very large file transfers.
@@ -355,7 +355,7 @@ public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, Co
///
/// The name of the new file to copy to.
/// that specify how the file is to be copied.
- /// true if original Timestamps must be preserved, false otherwise.
+ /// true if original Timestamps must be preserved; otherwise, false.
/// A callback function that is called each time another portion of the file has been copied. This parameter can be null.
/// The argument to be passed to the callback function. This parameter can be null.
[SecurityCritical]
@@ -372,7 +372,7 @@ public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, bo
/// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified.
- /// A class with details of the Copy action.
+ /// Returns a class with details of the Copy action.
/// and the possibility of notifying the application of its progress through a callback function.
///
/// Option is recommended for very large file transfers.
@@ -389,7 +389,7 @@ public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, bo
///
/// The name of the new file to copy to.
/// that specify how the file is to be copied.
- /// true if original Timestamps must be preserved, false otherwise.
+ /// true if original Timestamps must be preserved; otherwise, false.
/// A callback function that is called each time another portion of the file has been copied. This parameter can be null.
/// The argument to be passed to the callback function. This parameter can be null.
/// Indicates the format of the path parameter(s).
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs
index d5afef79c..7b0abd34f 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs
@@ -40,7 +40,7 @@ public StreamWriter AppendText()
/// Creates a that appends text to the file represented by this instance of the .
/// The character to use.
- /// A new
+ /// Returns a new
[SecurityCritical]
public StreamWriter AppendText(Encoding encoding)
{
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs
index d97eb04db..282782871 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs
@@ -29,7 +29,7 @@ partial class FileInfo
#region .NET
/// Creates a file.
- /// A new file.
+ /// Returns A new file.
[SecurityCritical]
public FileStream Create()
{
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs
index 1c4252233..51c6b82d1 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs
@@ -30,7 +30,7 @@ partial class FileInfo
#region .NET
/// Creates a instance that writes a new text file.
- /// A new
+ /// Returns a new
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
public StreamWriter CreateText()
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs
index fa69440a9..e1d360582 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs
@@ -26,8 +26,8 @@ namespace Alphaleonis.Win32.Filesystem
{
partial class FileInfo
{
- /// [AlphaFS] Returns an enumerable collection of instances for the file.
- /// An enumerable collection of instances for the file.
+ /// [AlphaFS] Returns an collection of instances for the file.
+ /// Returns an collection of instances for the file.
[SecurityCritical]
public IEnumerable EnumerateAlternateDataStreams()
{
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetFileIdInfo.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetFileIdInfo.cs
index 7d2c35e34..b8305d17e 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetFileIdInfo.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetFileIdInfo.cs
@@ -27,7 +27,7 @@ namespace Alphaleonis.Win32.Filesystem
partial class FileInfo
{
/// [AlphaFS] Gets the unique identifier for the file. The identifier is composed of a 64-bit volume serial number and 128-bit file system entry identifier.
- /// A instance containing the requested information.
+ /// Returns a instance containing the requested information.
/// File IDs are not guaranteed to be unique over time, because file systems are free to reuse them. In some cases, the file ID for a file can change over time.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs
index 99170fd59..f5906c869 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs
@@ -30,7 +30,7 @@ partial class FileInfo
#region .NET
/// Opens a file in the specified mode.
- /// A file opened in the specified mode, with read/write access and unshared.
+ /// Returns a file opened in the specified mode, with read/write access and unshared.
/// A constant specifying the mode (for example, Open or Append) in which to open the file.
[SecurityCritical]
public FileStream Open(FileMode mode)
@@ -40,7 +40,7 @@ public FileStream Open(FileMode mode)
/// Opens a file in the specified mode with read, write, or read/write access.
- /// A object opened in the specified mode and access, and unshared.
+ /// Returns a object opened in the specified mode and access, and unshared.
/// A constant specifying the mode (for example, Open or Append) in which to open the file.
/// A constant specifying whether to open the file with Read, Write, or ReadWrite file access.
[SecurityCritical]
@@ -51,7 +51,7 @@ public FileStream Open(FileMode mode, FileAccess access)
/// Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.
- /// A object opened with the specified mode, access, and sharing options.
+ /// Returns a object opened with the specified mode, access, and sharing options.
/// A constant specifying the mode (for example, Open or Append) in which to open the file.
/// A constant specifying whether to open the file with Read, Write, or ReadWrite file access.
/// A constant specifying the type of access other objects have to this file.
@@ -65,7 +65,7 @@ public FileStream Open(FileMode mode, FileAccess access, FileShare share)
/// [AlphaFS] Opens a file in the specified mode with read, write, or read/write access.
- /// A object opened in the specified mode and access, and unshared.
+ /// Returns a object opened in the specified mode and access, and unshared.
/// A constant specifying the mode (for example, Open or Append) in which to open the file.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options.
[SecurityCritical]
@@ -76,7 +76,7 @@ public FileStream Open(FileMode mode, FileSystemRights rights)
/// [AlphaFS] Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.
- /// A object opened with the specified mode, access, and sharing options.
+ /// Returns a object opened with the specified mode, access, and sharing options.
/// A constant specifying the mode (for example, Open or Append) in which to open the file.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options.
/// A constant specifying the type of access other objects have to this file.
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs
index 50067f701..901b825a9 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs
@@ -27,7 +27,7 @@ namespace Alphaleonis.Win32.Filesystem
partial class FileInfo
{
/// Creates a read-only .
- /// A new read-only object.
+ /// Returns a new read-only object.
/// This method returns a read-only object with the mode set to Read.
[SecurityCritical]
public FileStream OpenRead()
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs
index 6db3e1d44..3807fce38 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs
@@ -29,7 +29,7 @@ namespace Alphaleonis.Win32.Filesystem
partial class FileInfo
{
/// Creates a with NativeMethods.DefaultFileEncoding encoding that reads from an existing text file.
- /// A new with NativeMethods.DefaultFileEncoding encoding.
+ /// Returns a new with NativeMethods.DefaultFileEncoding encoding.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
public StreamReader OpenText()
@@ -39,7 +39,7 @@ public StreamReader OpenText()
/// [AlphaFS] Creates a with that reads from an existing text file.
- /// A new with the specified .
+ /// Returns a new with the specified .
/// The applied to the contents of the file.
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs
index becfbe275..4c3e0175b 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs
@@ -29,7 +29,7 @@ partial class FileInfo
#region .NET
/// Creates a write-only .
- /// A write-only unshared object for a new or existing file.
+ /// Returns a write-only unshared object for a new or existing file.
[SecurityCritical]
public FileStream OpenWrite()
{
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs
index 260dc3aae..05cc43b73 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs
@@ -28,7 +28,7 @@ partial class FileInfo
#region .NET
/// Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file.
- /// A object that encapsulates information about the file described by the parameter.
+ /// Returns a object that encapsulates information about the file described by the parameter.
///
/// The Replace method replaces the contents of a specified file with the contents of the file described by the current
/// object. It also creates a backup of the file that was replaced. Finally, it returns a new
@@ -45,7 +45,7 @@ public FileInfo Replace(string destinationFileName, string destinationBackupFile
/// Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.
- /// A object that encapsulates information about the file described by the parameter.
+ /// Returns a object that encapsulates information about the file described by the parameter.
///
/// The Replace method replaces the contents of a specified file with the contents of the file described by the current
/// object. It also creates a backup of the file that was replaced. Finally, it returns a new
@@ -65,7 +65,7 @@ public FileInfo Replace(string destinationFileName, string destinationBackupFile
/// [AlphaFS] Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.
- /// A object that encapsulates information about the file described by the parameter.
+ /// Returns a object that encapsulates information about the file described by the parameter.
///
/// The Replace method replaces the contents of a specified file with the contents of the file described by the current
/// object. It also creates a backup of the file that was replaced. Finally, it returns a new
@@ -83,7 +83,7 @@ public FileInfo Replace(string destinationFileName, string destinationBackupFile
/// [AlphaFS] Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors.
- /// A object that encapsulates information about the file described by the parameter.
+ /// Returns a object that encapsulates information about the file described by the parameter.
///
/// The Replace method replaces the contents of a specified file with the contents of the file described by the current
/// object. It also creates a backup of the file that was replaced. Finally, it returns a new
diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs
index 6dd6e5203..43ade7887 100644
--- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs
+++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs
@@ -33,8 +33,7 @@ public sealed partial class FileInfo : FileSystemInfo
{
#region Fields
- [NonSerialized]
- private string _name;
+ [NonSerialized] private string _name;
#endregion // Fields
diff --git a/AlphaFS/Filesystem/FileSystemEntryInfo.cs b/AlphaFS/Filesystem/FileSystemEntryInfo.cs
index 2ece6ec75..f762c83c5 100644
--- a/AlphaFS/Filesystem/FileSystemEntryInfo.cs
+++ b/AlphaFS/Filesystem/FileSystemEntryInfo.cs
@@ -101,7 +101,7 @@ public string FileName
/// The instance file size.
public long FileSize
{
- get { return NativeMethods.ToLong(Win32FindData.nFileSizeHigh, Win32FindData.nFileSizeLow); }
+ get { return Utils.ToLong(Win32FindData.nFileSizeHigh, Win32FindData.nFileSizeLow); }
}
diff --git a/AlphaFS/Filesystem/FileSystemInfo.cs b/AlphaFS/Filesystem/FileSystemInfo.cs
index fd9e23235..050f3f2f9 100644
--- a/AlphaFS/Filesystem/FileSystemInfo.cs
+++ b/AlphaFS/Filesystem/FileSystemInfo.cs
@@ -433,7 +433,7 @@ public void Refresh()
/// ToString is the major formatting method in the .NET Framework. It converts an object to its string representation so that it is
/// suitable for display.
///
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
// "Alphaleonis.Win32.Filesystem.FileSystemInfo"
@@ -585,7 +585,7 @@ internal static SafeFindFileHandle FindFirstFileNative(KernelTransaction transac
lastError = Marshal.GetLastWin32Error();
- if (!NativeMethods.IsValidHandle(safeHandle, false))
+ if (!Utils.IsValidHandle(safeHandle, false))
safeHandle = null;
diff --git a/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs b/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs
index 447eda5cc..fb26ba870 100644
--- a/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs
+++ b/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs
@@ -28,7 +28,6 @@
using System.Runtime.InteropServices;
using System.Security;
using System.Text.RegularExpressions;
-
#if !NET35
using System.Threading;
#endif
@@ -424,7 +423,7 @@ private void VerifyInstanceType(NativeMethods.WIN32_FIND_DATA win32FindData)
/// Gets an enumerator that returns all of the file system objects that match both the wildcards that are in any of the directories to be searched and the custom predicate.
- /// An instance: FileSystemEntryInfo, DirectoryInfo, FileInfo or string (full path).
+ /// Returns an instance: FileSystemEntryInfo, DirectoryInfo, FileInfo or string (full path).
[SecurityCritical]
public IEnumerable Enumerate()
{
@@ -456,7 +455,7 @@ public IEnumerable Enumerate()
// Removes the object at the beginning of your Queue.
- // The algorithmic complexity of this is O(1). It doesn't loop over elements.
+ // The algorithmic complexity of this is O(1). It does not loop over elements.
var pathLp = dirs.Dequeue();
@@ -572,7 +571,7 @@ public T Get()
{
if (null == handle)
{
- // InputPath might be a logical drive such as: "C:\", "D:\".
+ // InputPath might be a logical drive such as: C:\, "D:\".
var attrs = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA();
diff --git a/AlphaFS/Filesystem/KernelTransaction.cs b/AlphaFS/Filesystem/KernelTransaction.cs
index ece18c617..264c55743 100644
--- a/AlphaFS/Filesystem/KernelTransaction.cs
+++ b/AlphaFS/Filesystem/KernelTransaction.cs
@@ -87,7 +87,7 @@ public KernelTransaction(ObjectSecurity securityDescriptor, int timeout, string
_hTrans = NativeMethods.CreateTransaction(securityAttributes, IntPtr.Zero, 0, 0, 0, timeout, description);
int lastError = Marshal.GetLastWin32Error();
- NativeMethods.IsValidHandle(_hTrans, lastError);
+ Utils.IsValidHandle(_hTrans, lastError);
}
}
@@ -151,7 +151,7 @@ public SafeHandle SafeHandle
#region IDisposable Members
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- [SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)]
+ [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]
public void Dispose()
{
_hTrans.Close();
diff --git a/AlphaFS/Filesystem/Link Stream/BackupFileStream.cs b/AlphaFS/Filesystem/Link Stream/BackupFileStream.cs
index 7f87b7d56..dadc8f005 100644
--- a/AlphaFS/Filesystem/Link Stream/BackupFileStream.cs
+++ b/AlphaFS/Filesystem/Link Stream/BackupFileStream.cs
@@ -19,8 +19,6 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Security;
-using Microsoft.Win32.SafeHandles;
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
@@ -29,6 +27,8 @@
using System.Security;
using System.Security.AccessControl;
using System.Text;
+using Alphaleonis.Win32.Security;
+using Microsoft.Win32.SafeHandles;
using SecurityNativeMethods = Alphaleonis.Win32.Security.NativeMethods;
namespace Alphaleonis.Win32.Filesystem
@@ -185,7 +185,7 @@ public BackupFileStream(KernelTransaction transaction, string path, FileMode mod
[SecurityCritical]
public BackupFileStream(SafeFileHandle handle, FileSystemRights access)
{
- NativeMethods.IsValidHandle(handle);
+ Utils.IsValidHandle(handle);
SafeFileHandle = handle;
@@ -239,7 +239,7 @@ public override void SetLength(long value)
/// Gets a value indicating whether the current stream supports reading.
- /// true if the stream supports reading, false otherwise.
+ /// true if the stream supports reading; otherwise, false.
public override bool CanRead
{
get { return _canRead; }
@@ -253,7 +253,7 @@ public override bool CanSeek
}
/// Gets a value indicating whether the current stream supports writing.
- /// true if the stream supports writing, false otherwise.
+ /// true if the stream supports writing; otherwise, false.
public override bool CanWrite
{
get { return _canWrite; }
@@ -404,7 +404,7 @@ public void Write(byte[] buffer, int offset, int count, bool processSecurity)
uint bytesWritten;
- var success = NativeMethods.BackupWrite(SafeFileHandle, safeBuffer, (uint)safeBuffer.Capacity, out bytesWritten, false, processSecurity, ref _context);
+ var success = NativeMethods.BackupWrite(SafeFileHandle, safeBuffer, (uint) safeBuffer.Capacity, out bytesWritten, false, processSecurity, ref _context);
var lastError = Marshal.GetLastWin32Error();
if (!success)
@@ -440,7 +440,7 @@ public long Skip(long bytes)
{
uint lowSought, highSought;
- var success = NativeMethods.BackupSeek(SafeFileHandle, NativeMethods.GetLowOrderDword(bytes), NativeMethods.GetHighOrderDword(bytes), out lowSought, out highSought, ref _context);
+ var success = NativeMethods.BackupSeek(SafeFileHandle, Utils.GetLowOrderDword(bytes), Utils.GetHighOrderDword(bytes), out lowSought, out highSought, ref _context);
var lastError = Marshal.GetLastWin32Error();
if (!success && lastError != Win32Errors.ERROR_SEEK)
@@ -449,7 +449,7 @@ public long Skip(long bytes)
NativeError.ThrowException(lastError);
}
- return NativeMethods.ToLong(highSought, lowSought);
+ return Utils.ToLong(highSought, lowSought);
}
@@ -528,7 +528,7 @@ public void Lock(long position, long length)
throw new ArgumentOutOfRangeException("length", length, Resources.Negative_Lock_Length);
- var success = NativeMethods.LockFile(SafeFileHandle, NativeMethods.GetLowOrderDword(position), NativeMethods.GetHighOrderDword(position), NativeMethods.GetLowOrderDword(length), NativeMethods.GetHighOrderDword(length));
+ var success = NativeMethods.LockFile(SafeFileHandle, Utils.GetLowOrderDword(position), Utils.GetHighOrderDword(position), Utils.GetLowOrderDword(length), Utils.GetHighOrderDword(length));
var lastError = Marshal.GetLastWin32Error();
if (!success)
@@ -552,7 +552,7 @@ public void Unlock(long position, long length)
throw new ArgumentOutOfRangeException("length", length, Resources.Negative_Lock_Length);
- var success = NativeMethods.UnlockFile(SafeFileHandle, NativeMethods.GetLowOrderDword(position), NativeMethods.GetHighOrderDword(position), NativeMethods.GetLowOrderDword(length), NativeMethods.GetHighOrderDword(length));
+ var success = NativeMethods.UnlockFile(SafeFileHandle, Utils.GetLowOrderDword(position), Utils.GetHighOrderDword(position), Utils.GetLowOrderDword(length), Utils.GetHighOrderDword(length));
var lastError = Marshal.GetLastWin32Error();
if (!success)
@@ -590,7 +590,7 @@ public BackupStreamInfo ReadStreamInfo()
throw new IOException(Resources.Read_Incomplete_Header);
- var streamID = hBuf.PtrToStructure(0);
+ var streamID = hBuf.PtrToStructure();
var nameLength = (uint) Math.Min(streamID.dwStreamNameSize, hBuf.Capacity);
@@ -627,7 +627,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
// If one of the constructors previously threw an exception,
- // than the object hasn't been initialized properly and call from finalize will fail.
+ // than the object has not been initialized properly and call from finalize will fail.
if (null != SafeFileHandle && !SafeFileHandle.IsInvalid)
{
diff --git a/AlphaFS/Filesystem/Link Stream/BackupStreamInfo.cs b/AlphaFS/Filesystem/Link Stream/BackupStreamInfo.cs
index 12a758499..d3900d8e0 100644
--- a/AlphaFS/Filesystem/Link Stream/BackupStreamInfo.cs
+++ b/AlphaFS/Filesystem/Link Stream/BackupStreamInfo.cs
@@ -43,9 +43,9 @@ public sealed class BackupStreamInfo
internal BackupStreamInfo(NativeMethods.WIN32_STREAM_ID streamId, string name)
{
_streamName = name;
- _streamSize = (long)streamId.Size;
- _streamAttribute = (StreamAttribute)streamId.dwStreamAttribute;
- _streamId = (StreamId)streamId.dwStreamId;
+ _streamSize = (long) streamId.Size;
+ _streamAttribute = (StreamAttribute) streamId.dwStreamAttribute;
+ _streamId = (StreamId) streamId.dwStreamId;
}
#endregion // Constructor
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs
index 9ac31d85c..eea7abee6 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs
@@ -19,11 +19,11 @@
* THE SOFTWARE.
*/
-using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
+using Microsoft.Win32.SafeHandles;
namespace Alphaleonis.Win32.Filesystem
{
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs
index 8590b00e9..16cf400f2 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs
@@ -69,30 +69,5 @@ internal static partial class NativeMethods
/// Invalid FileAttributes = -1
internal const FileAttributes InvalidFileAttributes = (FileAttributes) (-1);
-
-
-
-
- /// MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384
- internal const int MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384;
-
- /// REPARSE_DATA_BUFFER_HEADER_SIZE = 8
- internal const int REPARSE_DATA_BUFFER_HEADER_SIZE = 8;
-
-
- private const int DeviceIoControlMethodBuffered = 0;
- private const int DeviceIoControlFileDeviceFileSystem = 9;
-
- // Command to compression state of a file or directory on a volume whose file system supports per-file and per-directory compression.
- internal const int FSCTL_SET_COMPRESSION = (DeviceIoControlFileDeviceFileSystem << 16) | (16 << 2) | DeviceIoControlMethodBuffered | (int) (FileAccess.Read | FileAccess.Write) << 14;
-
- // Command to set the reparse point data block.
- internal const int FSCTL_SET_REPARSE_POINT = (DeviceIoControlFileDeviceFileSystem << 16) | (41 << 2) | DeviceIoControlMethodBuffered | (0 << 14);
-
- /// Command to delete the reparse point data base.
- internal const int FSCTL_DELETE_REPARSE_POINT = (DeviceIoControlFileDeviceFileSystem << 16) | (43 << 2) | DeviceIoControlMethodBuffered | (0 << 14);
-
- /// Command to get the reparse point data block.
- internal const int FSCTL_GET_REPARSE_POINT = (DeviceIoControlFileDeviceFileSystem << 16) | (42 << 2) | DeviceIoControlMethodBuffered | (0 << 14);
}
}
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs
index 0e9c10fe5..a373d7204 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
@@ -17,7 +17,7 @@ internal partial class NativeMethods
/// [out] The address of a context block that must be presented in subsequent calls to
/// ReadEncryptedFileRaw, WriteEncryptedFileRaw, or CloseEncryptedFileRaw.
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("Advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode, EntryPoint = "OpenEncryptedFileRawW"), SuppressUnmanagedCodeSecurity]
+ [DllImport("advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode, EntryPoint = "OpenEncryptedFileRawW"), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.U4)]
internal static extern uint OpenEncryptedFileRaw([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, EncryptedFileRawMode ulFlags, out SafeEncryptedFileRawHandle pvContext);
@@ -27,7 +27,7 @@ internal partial class NativeMethods
/// Minimum supported server: Windows Server 2003 [desktop apps only]
/// A pointer to a system-defined context block. The OpenEncryptedFileRaw function returns the context block.
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("Advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [DllImport("advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
internal static extern void CloseEncryptedFileRaw(IntPtr pvContext);
@@ -37,7 +37,7 @@ internal partial class NativeMethods
/// Minimum supported client: Windows XP Professional [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule"), SuppressUnmanagedCodeSecurity]
- [DllImport("Advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [DllImport("advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.U4)]
internal static extern uint ReadEncryptedFileRaw([MarshalAs(UnmanagedType.FunctionPtr)] EncryptedFileRawExportCallback pfExportCallback, IntPtr pvCallbackContext, SafeEncryptedFileRawHandle pvContext);
@@ -48,7 +48,7 @@ internal partial class NativeMethods
/// Minimum supported client: Windows XP Professional [desktop apps only]
/// Minimum supported server: Windows Server 2003 [desktop apps only]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("Advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [DllImport("advapi32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.U4)]
internal static extern uint WriteEncryptedFileRaw([MarshalAs(UnmanagedType.FunctionPtr)] EncryptedFileRawImportCallback pfExportCallback, IntPtr pvCallbackContext, SafeEncryptedFileRawHandle pvContext);
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.ErrorMode.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.ErrorMode.cs
new file mode 100644
index 000000000..f068b1afb
--- /dev/null
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.ErrorMode.cs
@@ -0,0 +1,60 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace Alphaleonis.Win32.Filesystem
+{
+ internal static partial class NativeMethods
+ {
+ /// Controls whether the system will handle the specified types of serious errors or whether the process will handle them.
+ ///
+ /// Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error-
+ /// mode attributes. Doing so can lead to inconsistent error handling.
+ ///
+ /// Minimum supported client: Windows XP [desktop apps only].
+ /// Minimum supported server: Windows Server 2003 [desktop apps only].
+ /// The mode.
+ /// The return value is the previous state of the error-mode bit attributes.
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.U4)]
+ private static extern ErrorMode SetErrorMode(ErrorMode uMode);
+
+
+ /// Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them.
+ ///
+ /// Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error-
+ /// mode attributes. Doing so can lead to inconsistent error handling.
+ ///
+ /// Minimum supported client: Windows 7 [desktop apps only].
+ /// Minimum supported server: Windows Server 2008 R2 [desktop apps only].
+ /// The new mode.
+ /// [out] The old mode.
+ /// The return value is the previous state of the error-mode bit attributes.
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool SetThreadErrorMode(ErrorMode dwNewMode, [MarshalAs(UnmanagedType.U4)] out ErrorMode lpOldMode);
+ }
+}
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs
index d40deb0b7..69287afb1 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs
@@ -18,15 +18,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Security;
-using Microsoft.Win32.SafeHandles;
+
using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.AccessControl;
using System.Text;
+using Alphaleonis.Win32.Security;
+using Microsoft.Win32.SafeHandles;
namespace Alphaleonis.Win32.Filesystem
{
@@ -99,6 +101,7 @@ internal static partial class NativeMethods
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateFileW"), SuppressUnmanagedCodeSecurity]
internal static extern SafeFileHandle CreateFile([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] FileSystemRights dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] FileShare dwShareMode, [MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] ExtendedFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
+
///
/// Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical
/// disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe.
@@ -336,7 +339,7 @@ internal static partial class NativeMethods
internal static extern SafeFindFileHandle FindFirstFileTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, FIND_FIRST_EX_FLAGS dwAdditionalFlags, SafeHandle hTransaction);
///
- /// Creates an enumeration of all the hard links to the specified file. The FindFirstFileNameW function returns a handle to the
+ /// Returns an collection of all the hard links to the specified file. The FindFirstFileNameW function returns a handle to the
/// enumeration that can be used on subsequent calls to the FindNextFileNameW function.
///
/// Minimum supported client: Windows Vista [desktop apps only].
@@ -351,7 +354,7 @@ internal static partial class NativeMethods
internal static extern SafeFindFileHandle FindFirstFileNameW([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] uint dwFlags, [MarshalAs(UnmanagedType.U4)] out uint stringLength, StringBuilder linkName);
///
- /// Creates an enumeration of all the hard links to the specified file as a transacted operation. The function returns a handle to the
+ /// Returns an collection of all the hard links to the specified file as a transacted operation. The function returns a handle to the
/// enumeration that can be used on subsequent calls to the FindNextFileNameW function.
///
/// Minimum supported client: Windows Vista [desktop apps only].
@@ -655,7 +658,7 @@ internal static partial class NativeMethods
/// An application-defined callback function used with the CopyFileEx, MoveFileTransacted, and MoveFileWithProgress functions.
/// It is called when a portion of a copy or move operation is completed.
/// The LPPROGRESS_ROUTINE type defines a pointer to this callback function.
- /// NativeCopyMoveProgressRoutine (NativeCopyMoveProgressRoutine) is a placeholder for the application-defined function name.
+ /// NativeCopyMoveProgressRoutine is a placeholder for the application-defined function name.
///
[SuppressUnmanagedCodeSecurity]
internal delegate CopyMoveProgressResult NativeCopyMoveProgressRoutine([MarshalAs(UnmanagedType.I8)] long totalFileSize, [MarshalAs(UnmanagedType.I8)] long totalBytesTransferred, [MarshalAs(UnmanagedType.I8)] long streamSize, [MarshalAs(UnmanagedType.I8)] long streamBytesTransferred, [MarshalAs(UnmanagedType.U4)] uint dwStreamNumber, [MarshalAs(UnmanagedType.U4)] CopyMoveProgressCallbackReason dwCallbackReason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData);
@@ -746,7 +749,7 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool UnmapViewOfFile(SafeLocalMemoryBufferHandle lpBaseAddress);
-
+
/// Enumerates the first stream with a ::$DATA stream type in the specified file or directory.
///
/// If the function succeeds, the return value is a search handle that can be used in subsequent calls to the function.
@@ -883,7 +886,7 @@ internal struct RM_PROCESS_INFO
[DllImport("rstrtmgr.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.I4)]
internal static extern int RmStartSession([MarshalAs(UnmanagedType.U4)] out uint pSessionHandle, [MarshalAs(UnmanagedType.I4)] int dwSessionFlags, [MarshalAs(UnmanagedType.LPWStr)] string strSessionKey);
-
+
#endregion // Restart Manager
}
}
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs
index 2ec5a6cf2..4814c5a63 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs
@@ -18,6 +18,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs
index 74e935537..87cfff112 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs
@@ -18,6 +18,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs
index 38e1889a3..0449649c5 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs
@@ -18,6 +18,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs
index 910b78ce5..36a571d02 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs
@@ -69,7 +69,7 @@ internal interface IQueryAssociations
/// Searches for and retrieves a file or protocol association-related string from the registry.
- /// A standard COM error value, including the following: S_OK, E_POINTER, S_FALSE
+ /// Returns a standard COM error value, including the following: S_OK, E_POINTER, S_FALSE
/// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only]
/// Minimum supported server: Windows 2000 Server [desktop apps only]
void GetString(Shell32.AssociationAttributes flags, Shell32.AssociationString str, [MarshalAs(UnmanagedType.LPWStr)] string pwszExtra, StringBuilder pwszOut, [MarshalAs(UnmanagedType.I4)] out int pcchOut);
diff --git a/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs b/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs
index 1c88aa5aa..10c4143f9 100644
--- a/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs
+++ b/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs
@@ -159,39 +159,6 @@ internal static void CloseSafeHandle(SafeHandle handle)
{
if (null != handle && !handle.IsClosed)
handle.Close();
-
- handle = null;
}
-
-
- /// Controls whether the system will handle the specified types of serious errors or whether the process will handle them.
- ///
- /// Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error-
- /// mode attributes. Doing so can lead to inconsistent error handling.
- ///
- /// Minimum supported client: Windows XP [desktop apps only].
- /// Minimum supported server: Windows Server 2003 [desktop apps only].
- /// The mode.
- /// The return value is the previous state of the error-mode bit attributes.
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.U4)]
- private static extern ErrorMode SetErrorMode(ErrorMode uMode);
-
-
- /// Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them.
- ///
- /// Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error-
- /// mode attributes. Doing so can lead to inconsistent error handling.
- ///
- /// Minimum supported client: Windows 7 [desktop apps only].
- /// Minimum supported server: Windows Server 2008 R2 [desktop apps only].
- /// The new mode.
- /// [out] The old mode.
- /// The return value is the previous state of the error-mode bit attributes.
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool SetThreadErrorMode(ErrorMode dwNewMode, [MarshalAs(UnmanagedType.U4)] out ErrorMode lpOldMode);
}
}
diff --git a/AlphaFS/Filesystem/Native Other/FILETIME.cs b/AlphaFS/Filesystem/Native Other/FILETIME.cs
index e4a53ddb4..dc47c13e2 100644
--- a/AlphaFS/Filesystem/Native Other/FILETIME.cs
+++ b/AlphaFS/Filesystem/Native Other/FILETIME.cs
@@ -22,6 +22,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
+
namespace Alphaleonis.Win32.Filesystem
{
internal static partial class NativeMethods
@@ -38,6 +39,7 @@ internal struct FILETIME
#endregion // Fields
+
#region Methods
/// Converts a value to long.
@@ -50,11 +52,12 @@ public static implicit operator long(FILETIME ft)
[SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "long")]
public long ToLong()
{
- return NativeMethods.ToLong(dwHighDateTime, dwLowDateTime);
+ return Utils.ToLong(dwHighDateTime, dwLowDateTime);
}
#endregion
+
#region Equality
#region Equals
@@ -77,7 +80,7 @@ public override bool Equals(object obj)
#region GetHashCode
/// Serves as a hash function for a particular type.
- /// A hash code for the current Object.
+ /// Returns a hash code for the current Object.
public override int GetHashCode()
{
unchecked
diff --git a/AlphaFS/Filesystem/Native Other/FILE_INFO_BY_HANDLE_CLASS.cs b/AlphaFS/Filesystem/Native Other/FILE_INFO_BY_HANDLE_CLASS.cs
index f6dd82139..3e61bc103 100644
--- a/AlphaFS/Filesystem/Native Other/FILE_INFO_BY_HANDLE_CLASS.cs
+++ b/AlphaFS/Filesystem/Native Other/FILE_INFO_BY_HANDLE_CLASS.cs
@@ -132,7 +132,7 @@ internal enum FILE_INFO_BY_HANDLE_CLASS
/// This value is not supported before Windows 8 and Windows Server 2012
///
///
- FILE_ID_INFO = 18,
+ FILE_ID_INFO = 18
///// Files in the specified directory should be retrieved. Used for directory handles. Use only when calling GetFileInformationByHandleEx.
diff --git a/AlphaFS/Filesystem/Link Stream/LinkTargetInfo.cs b/AlphaFS/Filesystem/Native Other/LinkTargetInfo.cs
similarity index 100%
rename from AlphaFS/Filesystem/Link Stream/LinkTargetInfo.cs
rename to AlphaFS/Filesystem/Native Other/LinkTargetInfo.cs
diff --git a/AlphaFS/Filesystem/Native Other/MountPointReparseBuffer.cs b/AlphaFS/Filesystem/Native Other/MountPointReparseBuffer.cs
index 836b79774..d1b1ac6a5 100644
--- a/AlphaFS/Filesystem/Native Other/MountPointReparseBuffer.cs
+++ b/AlphaFS/Filesystem/Native Other/MountPointReparseBuffer.cs
@@ -29,19 +29,20 @@ internal static partial class NativeMethods
internal struct MountPointReparseBuffer
{
/// Offset, in bytes, of the substitute name string in the PathBuffer array.
- public ushort SubstituteNameOffset;
+ [MarshalAs(UnmanagedType.U2)] public ushort SubstituteNameOffset;
/// Length, in bytes, of the substitute name string. If this string is null-terminated, SubstituteNameLength does not include space for the null character.
- public ushort SubstituteNameLength;
+ [MarshalAs(UnmanagedType.U2)] public ushort SubstituteNameLength;
/// Offset, in bytes, of the print name string in the PathBuffer array.
- public ushort PrintNameOffset;
+ [MarshalAs(UnmanagedType.U2)] public ushort PrintNameOffset;
/// Length, in bytes, of the print name string. If this string is null-terminated, PrintNameLength does not include space for the null character.
- public ushort PrintNameLength;
+ [MarshalAs(UnmanagedType.U2)] public ushort PrintNameLength;
/// A buffer containing the unicode-encoded path string. The path string contains the substitute name string and print name string.
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] data;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
+ public readonly byte[] data;
}
}
}
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/ReparsePointTag.cs b/AlphaFS/Filesystem/Native Other/ReparsePointTag.cs
similarity index 100%
rename from AlphaFS/Filesystem/Structures, Enumerations/ReparsePointTag.cs
rename to AlphaFS/Filesystem/Native Other/ReparsePointTag.cs
diff --git a/AlphaFS/Filesystem/Native Other/SymbolicLinkReparseBuffer.cs b/AlphaFS/Filesystem/Native Other/SymbolicLinkReparseBuffer.cs
index da9eff09a..3e82686b6 100644
--- a/AlphaFS/Filesystem/Native Other/SymbolicLinkReparseBuffer.cs
+++ b/AlphaFS/Filesystem/Native Other/SymbolicLinkReparseBuffer.cs
@@ -28,12 +28,23 @@ internal static partial class NativeMethods
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct SymbolicLinkReparseBuffer
{
- public ushort SubstituteNameOffset;
- public ushort SubstituteNameLength;
- public ushort PrintNameOffset;
- public ushort PrintNameLength;
- public SymbolicLinkType Flags;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] data;
+ /// Offset, in bytes, of the substitute name string in the PathBuffer array.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort SubstituteNameOffset;
+
+ /// Length, in bytes, of the substitute name string. If this string is null-terminated, SubstituteNameLength does not include space for the null character.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort SubstituteNameLength;
+
+ /// Offset, in bytes, of the print name string in the PathBuffer array.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort PrintNameOffset;
+
+ /// Length, in bytes, of the print name string. If this string is null-terminated, PrintNameLength does not include space for the null character.
+ [MarshalAs(UnmanagedType.U2)] public readonly ushort PrintNameLength;
+
+ [MarshalAs(UnmanagedType.U4)] public readonly SymbolicLinkType Flags;
+
+ /// A buffer containing the unicode-encoded path string. The path string contains the substitute name string and print name string.
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
+ public readonly byte[] data;
}
}
}
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/SymbolicLinkTarget.cs b/AlphaFS/Filesystem/Native Other/SymbolicLinkTarget.cs
similarity index 100%
rename from AlphaFS/Filesystem/Structures, Enumerations/SymbolicLinkTarget.cs
rename to AlphaFS/Filesystem/Native Other/SymbolicLinkTarget.cs
diff --git a/AlphaFS/Filesystem/Link Stream/SymbolicLinkTargetInfo.cs b/AlphaFS/Filesystem/Native Other/SymbolicLinkTargetInfo.cs
similarity index 100%
rename from AlphaFS/Filesystem/Link Stream/SymbolicLinkTargetInfo.cs
rename to AlphaFS/Filesystem/Native Other/SymbolicLinkTargetInfo.cs
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/SymbolicLinkType.cs b/AlphaFS/Filesystem/Native Other/SymbolicLinkType.cs
similarity index 100%
rename from AlphaFS/Filesystem/Structures, Enumerations/SymbolicLinkType.cs
rename to AlphaFS/Filesystem/Native Other/SymbolicLinkType.cs
diff --git a/AlphaFS/Filesystem/Native Other/WIN32_FILE_ATTRIBUTE_DATA.cs b/AlphaFS/Filesystem/Native Other/WIN32_FILE_ATTRIBUTE_DATA.cs
index d70e5b1b6..d74d84221 100644
--- a/AlphaFS/Filesystem/Native Other/WIN32_FILE_ATTRIBUTE_DATA.cs
+++ b/AlphaFS/Filesystem/Native Other/WIN32_FILE_ATTRIBUTE_DATA.cs
@@ -79,7 +79,7 @@ public WIN32_FILE_ATTRIBUTE_DATA(WIN32_FIND_DATA findData)
/// The file size.
public long FileSize
{
- get { return ToLong(nFileSizeHigh, nFileSizeLow); }
+ get { return Utils.ToLong(nFileSizeHigh, nFileSizeLow); }
}
}
}
diff --git a/AlphaFS/Filesystem/Path Class/Path Core Methods/Path.GetFinalPathNameByHandleCore.cs b/AlphaFS/Filesystem/Path Class/Path Core Methods/Path.GetFinalPathNameByHandleCore.cs
index 341bc2c31..8a56d1423 100644
--- a/AlphaFS/Filesystem/Path Class/Path Core Methods/Path.GetFinalPathNameByHandleCore.cs
+++ b/AlphaFS/Filesystem/Path Class/Path Core Methods/Path.GetFinalPathNameByHandleCore.cs
@@ -130,7 +130,7 @@ internal static string GetFinalPathNameByHandleCore(SafeFileHandle handle, Final
if (!Utils.IsNullOrWhiteSpace(file))
{
- foreach (var drive in Directory.EnumerateLogicalDrivesCore(false, false)
+ foreach (var drive in DriveInfo.GetDrives(false, false)
.Select(drv => drv.Name).Where(drv => driveLetter.Equals(RemoveTrailingDirectorySeparator(drv), StringComparison.OrdinalIgnoreCase)))
@@ -159,7 +159,7 @@ private static string DosDeviceToDosPath(string dosDevice, string deviceReplacem
return string.Empty;
- foreach (var drive in Directory.EnumerateLogicalDrivesCore(false, false).Select(drv => drv.Name))
+ foreach (var drive in DriveInfo.GetDrives(false, false).Select(drv => drv.Name))
{
try
{
diff --git a/AlphaFS/Filesystem/Path Class/Path.AddTrailingDirectorySeparator.cs b/AlphaFS/Filesystem/Path Class/Path.AddTrailingDirectorySeparator.cs
index dc5aef03d..3376dedd1 100644
--- a/AlphaFS/Filesystem/Path Class/Path.AddTrailingDirectorySeparator.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.AddTrailingDirectorySeparator.cs
@@ -26,7 +26,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Path
{
/// [AlphaFS] Adds a trailing character to the string, when absent.
- /// A text string with a trailing character. The function returns null when is null.
+ /// Returns a text string with a trailing character. The function returns null when is null.
/// A text string to which the trailing is to be added, when absent.
[SecurityCritical]
public static string AddTrailingDirectorySeparator(string path)
@@ -36,7 +36,7 @@ public static string AddTrailingDirectorySeparator(string path)
/// [AlphaFS] Adds a trailing or character to the string, when absent.
- /// A text string with a trailing or character. The function returns null when is null.
+ /// Returns a text string with a trailing or character. The function returns null when is null.
/// A text string to which the trailing or is to be added, when absent.
/// If true the character will be added instead.
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Path Class/Path.Constants.cs b/AlphaFS/Filesystem/Path Class/Path.Constants.cs
index aefda4adc..652409765 100644
--- a/AlphaFS/Filesystem/Path Class/Path.Constants.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.Constants.cs
@@ -19,7 +19,6 @@
* THE SOFTWARE.
*/
-using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
@@ -101,13 +100,13 @@ public static partial class Path
public static readonly string WildcardQuestion = WildcardQuestionChar.ToString(CultureInfo.InvariantCulture);
- /// [AlphaFS] Win32 File Namespace. The "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system.
+ /// [AlphaFS] Win32 File Namespace. The "\\?\" (non-normalized) prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system.
public static readonly string LongPathPrefix = string.Format(CultureInfo.InvariantCulture, "{0}{0}{1}{0}", DirectorySeparatorChar, WildcardQuestion);
- /// [AlphaFS] Win32 Device Namespace. The "\\.\"prefix is how to access physical disks and volumes, without going through the file system, if the API supports this type of access.
+ /// [AlphaFS] Win32 Device Namespace. The "\\.\" (normalized) prefix is how to access physical disks and volumes, without going through the file system, if the API supports this type of access.
public static readonly string LogicalDrivePrefix = string.Format(CultureInfo.InvariantCulture, "{0}{0}.{0}", DirectorySeparatorChar);
- /// [AlphaFS] PhysicalDrivePrefix = "\\.\PhysicalDrive" Provides standard physical drive prefix.
+ /// [AlphaFS] PhysicalDrivePrefix = "\\.\PhysicalDrive" Provides standard physical disk prefix.
public static readonly string PhysicalDrivePrefix = string.Format(CultureInfo.InvariantCulture, "{0}PhysicalDrive", LogicalDrivePrefix);
@@ -128,12 +127,10 @@ public static partial class Path
/// [AlphaFS] DosDeviceLanmanPrefix = "\Device\LanmanRedirector\" Provides a MS-Dos Lanman Redirector Path UNC prefix to a network share.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lanman")]
- [Obsolete("Unused")]
public static readonly string DosDeviceLanmanPrefix = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", DevicePrefix, "LanmanRedirector", DirectorySeparatorChar);
/// [AlphaFS] DosDeviceMupPrefix = "\Device\Mup\" Provides a MS-Dos Mup Redirector Path UNC prefix to a network share.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mup")]
- [Obsolete("Unused")]
public static readonly string DosDeviceMupPrefix = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", DevicePrefix, "Mup", DirectorySeparatorChar);
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs b/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs
index 455ab43a2..0d62db0a3 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs
@@ -35,7 +35,7 @@ public static partial class Path
/// It also calculates the address of the file name portion of the full path and file name.
///
/// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.
- /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as \\.\PhysicalDrive0.
+ /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as \\.\PhysicalDrive0
///
/// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and
/// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process,
@@ -64,7 +64,7 @@ public static string GetFullPath(string path)
/// It also calculates the address of the file name portion of the full path and file name.
///
/// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.
- /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as \\.\PhysicalDrive0.
+ /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as \\.\PhysicalDrive0
///
/// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and
/// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process,
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetInvalidFileNameChars.cs b/AlphaFS/Filesystem/Path Class/Path.GetInvalidFileNameChars.cs
index db5f6add5..730a7e9b1 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetInvalidFileNameChars.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetInvalidFileNameChars.cs
@@ -28,7 +28,7 @@ public static partial class Path
#region .NET
/// Gets an array containing the characters that are not allowed in file names.
- /// An array containing the characters that are not allowed in file names.
+ /// Returns an array containing the characters that are not allowed in file names.
[SecurityCritical]
public static char[] GetInvalidFileNameChars()
{
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetInvalidPathChars.cs b/AlphaFS/Filesystem/Path Class/Path.GetInvalidPathChars.cs
index b1fa3e002..24dc592bf 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetInvalidPathChars.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetInvalidPathChars.cs
@@ -28,7 +28,7 @@ public static partial class Path
#region .NET
/// Gets an array containing the characters that are not allowed in path names.
- /// An array containing the characters that are not allowed in path names.
+ /// Returns an array containing the characters that are not allowed in path names.
[SecurityCritical]
public static char[] GetInvalidPathChars()
{
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetLongPath.cs b/AlphaFS/Filesystem/Path Class/Path.GetLongPath.cs
index e7f4b3004..7b3b0a62b 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetLongPath.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetLongPath.cs
@@ -27,7 +27,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Path
{
/// [AlphaFS] Makes an extended long path from the specified by prefixing .
- /// The prefixed with a , the minimum required full path is: "C:\".
+ /// The prefixed with a , the minimum required full path is: C:\.
/// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.
///
///
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetPathRoot.cs b/AlphaFS/Filesystem/Path Class/Path.GetPathRoot.cs
index dda08f503..dcad7a1cb 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetPathRoot.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetPathRoot.cs
@@ -30,7 +30,7 @@ public static partial class Path
/// Gets the root directory information of the specified path.
///
- /// Returns the root directory of , such as "C:\",
+ /// Returns the root directory of , such as C:\,
/// or null if is null,
/// or an empty string if does not contain root directory information.
///
@@ -47,7 +47,7 @@ public static string GetPathRoot(string path)
/// [AlphaFS] Gets the root directory information of the specified path.
///
- /// Returns the root directory of , such as "C:\",
+ /// Returns the root directory of , such as C:\,
/// or null if is null,
/// or an empty string if does not contain root directory information.
///
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetRandomFileName.cs b/AlphaFS/Filesystem/Path Class/Path.GetRandomFileName.cs
index b8b7f6706..ab7ee78bd 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetRandomFileName.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetRandomFileName.cs
@@ -29,7 +29,7 @@ public static partial class Path
#region .NET
/// Returns a random folder name or file name.
- /// A random folder name or file name.
+ /// Returns a random folder name or file name.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[SecurityCritical]
public static string GetRandomFileName()
diff --git a/AlphaFS/Filesystem/Path Class/Path.GetShort83Path.cs b/AlphaFS/Filesystem/Path Class/Path.GetShort83Path.cs
index ce0649dd2..de7e86892 100644
--- a/AlphaFS/Filesystem/Path Class/Path.GetShort83Path.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.GetShort83Path.cs
@@ -27,7 +27,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Path
{
/// [AlphaFS] Retrieves the short path form of the specified path.
- /// A path that has the 8.3 path form.
+ /// Returns a path that has the 8.3 path form.
/// Will fail on NTFS volumes with disabled 8.3 name generation.
/// The path must actually exist to be able to get the short path name.
///
diff --git a/AlphaFS/Filesystem/Path Class/Path.IsLogicalDrive.cs b/AlphaFS/Filesystem/Path Class/Path.IsLogicalDrive.cs
index 488c5d9c9..8d9b05c7d 100644
--- a/AlphaFS/Filesystem/Path Class/Path.IsLogicalDrive.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.IsLogicalDrive.cs
@@ -25,8 +25,8 @@ namespace Alphaleonis.Win32.Filesystem
{
public static partial class Path
{
- /// [AlphaFS] Checks if is in a logical drive format, such as "C:", "D:".
- /// true when is in a logical drive format, such as "C:", "D:".
+ /// [AlphaFS] Checks if is in a logical drive format, such as C:, D:
+ /// true when is in a logical drive format, such as C:, D:
///
///
/// The absolute path to check.
@@ -36,8 +36,8 @@ public static bool IsLogicalDrive(string path)
}
- /// [AlphaFS] Checks if is in a logical drive format, such as "C:", "D:".
- /// true when is in a logical drive format, such as "C:", "D:".
+ /// [AlphaFS] Checks if is in a logical drive format, such as C:, D:
+ /// true when is in a logical drive format, such as C:, D:
///
///
/// The absolute path to check.
@@ -61,7 +61,7 @@ internal static bool IsLogicalDriveCore(string path, bool isRegularPath, PathFor
var c = regularPath.ToUpperInvariant()[0];
- // Don't use char.IsLetter() here as that can be misleading; The only valid drive letters are: A-Z.
+ // Do not use char.IsLetter() here as that can be misleading; The only valid drive letters are: A-Z.
return regularPath[1] == VolumeSeparatorChar && c >= 'A' && c <= 'Z';
}
diff --git a/AlphaFS/Filesystem/Path Class/Path.IsLongPath.cs b/AlphaFS/Filesystem/Path Class/Path.IsLongPath.cs
index e728f30f8..e8ac8d6de 100644
--- a/AlphaFS/Filesystem/Path Class/Path.IsLongPath.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.IsLongPath.cs
@@ -28,7 +28,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Path
{
/// [AlphaFS] Determines whether the specified path starts with a or .
- /// true if the specified path has a long path (UNC) prefix, false otherwise.
+ /// true if the specified path has a long path (UNC) prefix; otherwise, false.
/// The path to the file or directory.
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")]
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Path Class/Path.IsUncPath.cs b/AlphaFS/Filesystem/Path Class/Path.IsUncPath.cs
index 2bdf7ddce..b67989b2a 100644
--- a/AlphaFS/Filesystem/Path Class/Path.IsUncPath.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.IsUncPath.cs
@@ -26,7 +26,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Path
{
/// [AlphaFS] Determines if a path string is a valid Universal Naming Convention (UNC) path.
- /// true if the specified path is a Universal Naming Convention (UNC) path, false otherwise.
+ /// true if the specified path is a Universal Naming Convention (UNC) path; otherwise, false.
/// The path to check.
[SecurityCritical]
public static bool IsUncPath(string path)
@@ -36,7 +36,7 @@ public static bool IsUncPath(string path)
/// Determines if a path string is a valid Universal Naming Convention (UNC) path, optionally skip invalid path character check.
- /// true if the specified path is a Universal Naming Convention (UNC) path, false otherwise.
+ /// true if the specified path is a Universal Naming Convention (UNC) path; otherwise, false.
/// The path to check.
/// true will check for invalid path characters.
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Path Class/Path.LocalToUnc.cs b/AlphaFS/Filesystem/Path Class/Path.LocalToUnc.cs
index 99514bcd1..76d815015 100644
--- a/AlphaFS/Filesystem/Path Class/Path.LocalToUnc.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.LocalToUnc.cs
@@ -23,6 +23,7 @@
using System.IO;
using System.Net.NetworkInformation;
using System.Security;
+using Alphaleonis.Win32.Network;
namespace Alphaleonis.Win32.Filesystem
{
@@ -55,7 +56,7 @@ public static string LocalToUnc(string localPath, PathFormat pathFormat, GetFull
/// [AlphaFS] Converts a local path to a network share path.
- /// A Local path, e.g.: "C:\Windows" or "C:\Windows\" will be returned as: "\\localhost\C$\Windows".
+ /// A Local path, e.g.: C:\Windows or "C:\Windows\" will be returned as: "\\localhost\C$\Windows".
/// If a logical drive points to a network share path (mapped drive), the share path will be returned without a trailing character.
///
/// On successful conversion a UNC path is returned.
@@ -84,7 +85,7 @@ public static string LocalToUnc(string localPath)
///
///
///
- /// A local path, e.g.: "C:\Windows".
+ /// A local path, e.g.: C:\Windows.
/// Indicates the format of the path parameter.
[SecurityCritical]
public static string LocalToUnc(string localPath, PathFormat pathFormat)
@@ -94,7 +95,7 @@ public static string LocalToUnc(string localPath, PathFormat pathFormat)
/// [AlphaFS] Converts a local path to a network share path, optionally returning it as a long path format and the ability to add or remove a trailing backslash.
- /// A Local path, e.g.: "C:\Windows" or "C:\Windows\" will be returned as: "\\localhost\C$\Windows".
+ /// A Local path, e.g.: C:\Windows or "C:\Windows\" will be returned as: "\\localhost\C$\Windows".
/// If a logical drive points to a network share path (mapped drive), the share path will be returned without a trailing character.
///
/// On successful conversion a UNC path is returned.
@@ -104,7 +105,7 @@ public static string LocalToUnc(string localPath, PathFormat pathFormat)
///
///
///
- /// A local path, e.g.: "C:\Windows".
+ /// A local path, e.g.: C:\Windows.
/// Options for controlling the full path retrieval.
[SecurityCritical]
public static string LocalToUnc(string localPath, GetFullPathOptions fullPathOptions)
@@ -124,7 +125,7 @@ public static string LocalToUnc(string localPath, GetFullPathOptions fullPathOpt
///
///
///
- /// A local path, e.g.: "C:\Windows".
+ /// A local path, e.g.: C:\Windows.
/// Indicates the format of the path parameter.
/// Options for controlling the full path retrieval.
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Path Class/Path.RemoveTrailingDirectorySeparator.cs b/AlphaFS/Filesystem/Path Class/Path.RemoveTrailingDirectorySeparator.cs
index c13e9ecf7..3a8adaffd 100644
--- a/AlphaFS/Filesystem/Path Class/Path.RemoveTrailingDirectorySeparator.cs
+++ b/AlphaFS/Filesystem/Path Class/Path.RemoveTrailingDirectorySeparator.cs
@@ -26,7 +26,7 @@ namespace Alphaleonis.Win32.Filesystem
public static partial class Path
{
/// [AlphaFS] Removes the trailing character from the string, when present.
- /// A text string where the trailing character has been removed. The function returns null when is null.
+ /// Returns a text string where the trailing character has been removed. The function returns null when is null.
/// A text string from which the trailing is to be removed, when present.
[SecurityCritical]
public static string RemoveTrailingDirectorySeparator(string path)
@@ -36,7 +36,7 @@ public static string RemoveTrailingDirectorySeparator(string path)
/// [AlphaFS] Removes the trailing or character from the string, when present.
- /// A text string where the trailing or character has been removed. The function returns null when is null.
+ /// Returns a text string where the trailing or character has been removed. The function returns null when is null.
/// A text string from which the trailing or is to be removed, when present.
/// If true the trailing character will be removed instead.
[SecurityCritical]
diff --git a/AlphaFS/Filesystem/Shell32.cs b/AlphaFS/Filesystem/Shell32.cs
index dd04d16ec..1f6af25bb 100644
--- a/AlphaFS/Filesystem/Shell32.cs
+++ b/AlphaFS/Filesystem/Shell32.cs
@@ -530,7 +530,7 @@ public static string GetFileFriendlyDocName(string path)
/// Icon size or . Can also be combined
/// with and others.
///
- /// An handle to the Shell icon that represents the file, or IntPtr.Zero on failure.
+ /// Returns an handle to the Shell icon that represents the file, or IntPtr.Zero on failure.
[SecurityCritical]
public static IntPtr GetFileIcon(string filePath, FileAttributes iconAttributes)
{
@@ -565,7 +565,7 @@ public static FileInfo GetFileInfo(string filePath, System.IO.FileAttributes att
/// Retrieves an instance of containing information about the specified file.
/// A path to the file.
- /// A class instance.
+ /// Returns a class instance.
[SecurityCritical]
public static Shell32Info GetShell32Info(string path)
{
@@ -575,7 +575,7 @@ public static Shell32Info GetShell32Info(string path)
/// Retrieves an instance of containing information about the specified file.
/// A path to the file.
/// Indicates the format of the path parameter(s).
- /// A class instance.
+ /// Returns a class instance.
[SecurityCritical]
public static Shell32Info GetShell32Info(string path, PathFormat pathFormat)
{
@@ -620,7 +620,7 @@ internal static string PathCreateFromUrl(string urlPath)
var lastError = NativeMethods.PathCreateFromUrl(urlPath, buffer, ref bufferSize, 0);
- // Don't throw exception, but return string.Empty;
+ // Do not throw exception, but return string.Empty;
return lastError == Win32Errors.S_OK ? buffer.ToString() : string.Empty;
}
@@ -636,7 +636,7 @@ internal static string PathCreateFromUrl(string urlPath)
internal static string PathCreateFromUrlAlloc(string urlPath)
{
if (!NativeMethods.IsAtLeastWindowsVista)
- throw new PlatformNotSupportedException(new Win32Exception((int)Win32Errors.ERROR_OLD_WIN_VERSION).Message);
+ throw new PlatformNotSupportedException(new Win32Exception((int) Win32Errors.ERROR_OLD_WIN_VERSION).Message);
if (urlPath == null)
@@ -645,14 +645,14 @@ internal static string PathCreateFromUrlAlloc(string urlPath)
StringBuilder buffer;
var lastError = NativeMethods.PathCreateFromUrlAlloc(urlPath, out buffer, 0);
- // Don't throw exception, but return string.Empty;
+ // Do not throw exception, but return string.Empty;
return lastError == Win32Errors.S_OK ? buffer.ToString() : string.Empty;
}
/// Determines whether a path to a file system object such as a file or folder is valid.
/// The full path of maximum length the maximum path length to the object to verify.
- /// true if the file exists; false otherwise
+ /// true if the file exists; otherwise, false
[SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "lastError")]
[SecurityCritical]
public static bool PathFileExists(string path)
@@ -668,9 +668,9 @@ public static bool PathFileExists(string path)
/// The URL.
///
///
- /// For all but one of the URL types, UrlIs returns true if the URL is the specified type, or false otherwise.
+ /// For all but one of the URL types, UrlIs returns true if the URL is the specified type, or otherwise, false.
/// If UrlIs is set to , UrlIs will attempt to determine the URL scheme.
- /// If the function is able to determine a scheme, it returns true, or false otherwise.
+ /// If the function is able to determine a scheme, it returns true, or otherwise, false.
///
[SecurityCritical]
internal static bool UrlIs(string url, UrlType urlType)
@@ -699,7 +699,7 @@ internal static string UrlCreateFromPath(string path)
var lastError = NativeMethods.UrlCreateFromPath(pathRp, buffer, ref bufferSize, 0);
- // Don't throw exception, but return null;
+ // Do not throw exception, but return null;
var url = buffer.ToString();
if (Utils.IsNullOrWhiteSpace(url))
url = string.Empty;
@@ -710,7 +710,7 @@ internal static string UrlCreateFromPath(string path)
/// Tests a URL to determine if it is a file URL.
/// The URL.
- /// true if the URL is a file URL, or false otherwise.
+ /// true if the URL is a file URL, or otherwise, false.
[SecurityCritical]
internal static bool UrlIsFileUrl(string url)
{
@@ -720,7 +720,7 @@ internal static bool UrlIsFileUrl(string url)
/// Returns whether a URL is a URL that browsers typically do not include in navigation history.
/// The URL.
- /// true if the URL is a URL that is not included in navigation history, or false otherwise.
+ /// true if the URL is a URL that is not included in navigation history, or otherwise, false.
[SecurityCritical]
internal static bool UrlIsNoHistory(string url)
{
@@ -730,7 +730,7 @@ internal static bool UrlIsNoHistory(string url)
/// Returns whether a URL is opaque.
/// The URL.
- /// true if the URL is opaque, or false otherwise.
+ /// true if the URL is opaque, or otherwise, false.
[SecurityCritical]
internal static bool UrlIsOpaque(string url)
{
@@ -747,7 +747,7 @@ internal static bool UrlIsOpaque(string url)
/// The associated file- or protocol-related string from the registry or string.Empty if no association can be found.
///
[SecurityCritical]
- private static string GetFileAssociationCore(string path, AssociationAttributes attributes, AssociationString associationType)
+ internal static string GetFileAssociationCore(string path, AssociationAttributes attributes, AssociationString associationType)
{
if (Utils.IsNullOrWhiteSpace(path))
throw new ArgumentNullException("path");
diff --git a/AlphaFS/Filesystem/Shell32Info.cs b/AlphaFS/Filesystem/Shell32Info.cs
index b5e58fca7..be72f1c6d 100644
--- a/AlphaFS/Filesystem/Shell32Info.cs
+++ b/AlphaFS/Filesystem/Shell32Info.cs
@@ -67,7 +67,7 @@ public Shell32Info(string fileName, PathFormat pathFormat)
/// Gets an handle to the Shell icon that represents the file.
/// Icon size or . Can also be combined with and others.
- /// An handle to the Shell icon that represents the file.
+ /// Returns an handle to the Shell icon that represents the file.
/// Caller is responsible for destroying this handle with DestroyIcon() when no longer needed.
[SecurityCritical]
public IntPtr GetIcon(Shell32.FileAttributes iconAttributes)
@@ -155,7 +155,7 @@ public void Refresh()
/// Returns the path as a string.
- /// The path.
+ /// The path.
public override string ToString()
{
return FullPath;
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/DirectoryEnumerationFilters.cs b/AlphaFS/Filesystem/Structures, Enumerations/DirectoryEnumerationFilters.cs
index 9eff38505..8ddbc1175 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/DirectoryEnumerationFilters.cs
+++ b/AlphaFS/Filesystem/Structures, Enumerations/DirectoryEnumerationFilters.cs
@@ -20,7 +20,6 @@
*/
using System;
-
#if !NET35
using System.Threading;
#endif
@@ -32,7 +31,7 @@ namespace Alphaleonis.Win32.Filesystem
/// The error code.
/// The error message.
/// The faulty path being processed.
- /// false otherwise, in which case the caller will throw the corresponding exception.
+ /// otherwise, false, in which case the caller will throw the corresponding exception.
public delegate bool ErrorHandler(int errorCode, string errorMessage, string pathProcessed);
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/ExtendedFileAttributes.cs b/AlphaFS/Filesystem/Structures, Enumerations/ExtendedFileAttributes.cs
index 1297e3edd..6ec5a9693 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/ExtendedFileAttributes.cs
+++ b/AlphaFS/Filesystem/Structures, Enumerations/ExtendedFileAttributes.cs
@@ -28,7 +28,7 @@ namespace Alphaleonis.Win32.Filesystem
/// Specifies how the operating system should open a file.
[SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags")]
[Flags]
- public enum ExtendedFileAttributes
+ public enum ExtendedFileAttributes
{
/// If you pass , the set of attributes is unspecified. explicitly sets no attributes.
None = 0,
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/FileIdInfo.cs b/AlphaFS/Filesystem/Structures, Enumerations/FileIdInfo.cs
index 991db9ff6..970fa7cfa 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/FileIdInfo.cs
+++ b/AlphaFS/Filesystem/Structures, Enumerations/FileIdInfo.cs
@@ -44,7 +44,7 @@ internal FileIdInfo(NativeMethods.BY_HANDLE_FILE_INFORMATION fibh)
_volumeSerialNumber = fibh.dwVolumeSerialNumber;
_fileIdHighPart = 0;
- _fileIdLowPart = NativeMethods.ToLong(fibh.nFileIndexHigh, fibh.nFileIndexLow);
+ _fileIdLowPart = Utils.ToLong(fibh.nFileIndexHigh, fibh.nFileIndexLow);
}
@@ -73,13 +73,13 @@ private static void ArrayToLong(byte[] fileId, int startIndex, int count, out lo
value = 0;
for (var i = 0; i < count; i++)
- value |= (long) fileId[startIndex + i] << (8 * i);
+ value |= (long)fileId[startIndex + i] << (8 * i);
}
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// An object to compare with this instance.
- /// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes in the sort order. Zero This instance occurs in the same position in the sort order as . Greater than zero This instance follows in the sort order.
+ /// Returns a value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes in the sort order. Zero This instance occurs in the same position in the sort order as . Greater than zero This instance follows in the sort order.
public int CompareTo(object obj)
{
if (null == obj)
@@ -88,13 +88,13 @@ public int CompareTo(object obj)
if (!(obj is FileIdInfo))
throw new ArgumentException("Object must be of type FileIdInfo");
- return CompareTo((FileIdInfo) obj);
+ return CompareTo((FileIdInfo)obj);
}
/// Compares the current object with another object of the same type.
/// An object to compare with this object.
- /// A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the parameter.Zero This object is equal to . Greater than zero This object is greater than .
+ /// Returns a value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the parameter.Zero This object is equal to . Greater than zero This object is greater than .
public int CompareTo(FileIdInfo other)
{
return _volumeSerialNumber != other._volumeSerialNumber
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/FinalPathFormats.cs b/AlphaFS/Filesystem/Structures, Enumerations/FinalPathFormats.cs
index f9c2ffb6c..f8b96d958 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/FinalPathFormats.cs
+++ b/AlphaFS/Filesystem/Structures, Enumerations/FinalPathFormats.cs
@@ -30,7 +30,7 @@ public enum FinalPathFormats
/// (FileNameNormalized / VolumeNameDos) Return the normalized drive name. This is the default.
None = 0,
- /// Return the path with a volume GUID path instead of the drive name.
+ /// Return the path with a volume path instead of the drive name.
VolumeNameGuid = 1,
/// Return the path with the volume device path.
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/MoveOptions.cs b/AlphaFS/Filesystem/Structures, Enumerations/MoveOptions.cs
index c7197631a..8111ee033 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/MoveOptions.cs
+++ b/AlphaFS/Filesystem/Structures, Enumerations/MoveOptions.cs
@@ -42,7 +42,7 @@ public enum MoveOptions
/// MOVE_FILE_COPY_ALLOWED
/// If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.
- /// This value cannot be used with .
+ /// This value cannot be used with .
///
CopyAllowed = NativeMethods.MOVE_FILE_FLAGS.MOVE_FILE_COPY_ALLOWED,
@@ -56,7 +56,7 @@ public enum MoveOptions
/// Consequently, this parameter enables the function to delete paging files from previous startups.
/// This value can only be used if the process is in the context of a user who belongs to the administrators group or the LocalSystem account.
///
- /// This value cannot be used with .
+ /// This value cannot be used with .
///
DelayUntilReboot = NativeMethods.MOVE_FILE_FLAGS.MOVE_FILE_DELAY_UNTIL_REBOOT,
@@ -67,7 +67,7 @@ public enum MoveOptions
/// Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns.
/// The flush occurs at the end of the copy operation.
///
- /// This value has no effect if is set.
+ /// This value has no effect if is set.
///
WriteThrough = NativeMethods.MOVE_FILE_FLAGS.MOVE_FILE_WRITE_THROUGH,
diff --git a/AlphaFS/Filesystem/Structures, Enumerations/PathFormat.cs b/AlphaFS/Filesystem/Structures, Enumerations/PathFormat.cs
index 7c6c837e2..afe11a7ae 100644
--- a/AlphaFS/Filesystem/Structures, Enumerations/PathFormat.cs
+++ b/AlphaFS/Filesystem/Structures, Enumerations/PathFormat.cs
@@ -23,12 +23,12 @@ namespace Alphaleonis.Win32.Filesystem
{
/// Indicates the format of a path passed to a method.
///
- /// At some point in code you know the full path of file system objects, e.g.: "C:\Windows".
+ /// At some point in code you know the full path of file system objects, e.g.: C:\Windows.
/// For example, Directory.EnumerateFileSystemEntries() will return all files and directories from a given path.
/// Most likely, some processing will happen on the results of the enum. The file or directory may be passed
/// on to another function. Whenever a file path is required, some performance can be gained.
///
- /// A path like: "C:\Windows" or "\\server\share" is considered a full path for a directory because it is rooted and has a drive/unc path.
+ /// A path like: C:\Windows or "\\server\share" is considered a full path for a directory because it is rooted and has a drive/unc path.
/// If the method supports it, and will skip GetFullPath()
/// calls for path resolving of the object, while also avoiding path validation and checks.
/// Using (default) will always call GetFullPath() and perform path validation and checks.
@@ -46,7 +46,7 @@ public enum PathFormat
/// The path is a full path in either normal or extended length (UNICODE) format.
/// Internally it will be converted to an extended length (UNICODE) path.
/// Using this option has a very slight performance advantage compared to using .
- /// Example full path: "C:\Windows" or "\\server\share".
+ /// Example full path: C:\Windows or "\\server\share".
///
FullPath,
diff --git a/AlphaFS/GlobalSuppressions.cs b/AlphaFS/GlobalSuppressions.cs
index f7f497c5e..e31894ab3 100644
--- a/AlphaFS/GlobalSuppressions.cs
+++ b/AlphaFS/GlobalSuppressions.cs
@@ -27,18 +27,25 @@
// Error List, point to "Suppress Message(s)", and click
// "In Project Suppression File".
// You do not need to add suppressions to this file manually.
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Network")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Security")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Alphaleonis.Win32.Security")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Filesystem", Scope = "namespace", Target = "Alphaleonis.Win32.Filesystem")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Filesystem")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.AlreadyExistsException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.DirectoryNotEmptyException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.DirectoryReadOnlyException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.FileReadOnlyException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.NotAReparsePointException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.DeviceNotReadyException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.UnrecognizedReparsePointException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.NotSameDeviceException.#.cctor()")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "Dir", Scope = "resource", Target = "Alphaleonis.Win32.Resources.resources")]
+
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Network")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Security")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Alphaleonis.Win32.Security")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Filesystem", Scope = "namespace", Target = "Alphaleonis.Win32.Filesystem")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Filesystem")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.AlreadyExistsException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.DirectoryNotEmptyException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.DirectoryReadOnlyException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.FileReadOnlyException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.NotAReparsePointException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.DeviceNotReadyException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.UnrecognizedReparsePointException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Scope = "member", Target = "Alphaleonis.Win32.Filesystem.NotSameDeviceException.#.cctor()")]
+[assembly: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "Dir", Scope = "resource", Target = "Alphaleonis.Win32.Resources.resources")]
+
+[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Alphaleonis", Scope = "namespace", Target = "Alphaleonis.Win32.Device")]
+[assembly: SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "Name", Scope = "type", Target = "Alphaleonis.Win32.Device.NativeMethods+PARTITION_INFORMATION_EX")]
+[assembly: SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", MessageId = "Name", Scope = "type", Target = "Alphaleonis.Win32.Device.NativeMethods+PARTITION_INFORMATION_GPT")]
diff --git a/AlphaFS/NativeError.cs b/AlphaFS/NativeError.cs
index 2b00db7aa..51dd6d98f 100644
--- a/AlphaFS/NativeError.cs
+++ b/AlphaFS/NativeError.cs
@@ -23,9 +23,11 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using System.IO;
using System.Runtime.InteropServices;
using System.Security.Policy;
using Alphaleonis.Win32.Filesystem;
+using Path = Alphaleonis.Win32.Filesystem.Path;
namespace Alphaleonis.Win32
{
@@ -78,6 +80,15 @@ public static void ThrowException(uint errorCode, string readPath, string writeP
if (null != writePath)
writePath = Path.GetCleanExceptionPath(writePath);
+
+ if (errorCode == Win32Errors.ERROR_PATH_NOT_FOUND || errorCode == Win32Errors.ERROR_FILE_NOT_FOUND)
+ {
+ if (null != readPath && readPath.StartsWith(Path.PhysicalDrivePrefix, StringComparison.OrdinalIgnoreCase))
+
+ errorCode = Win32Errors.ERROR_NOT_READY;
+ }
+
+
var errorMessage = string.Format(CultureInfo.InvariantCulture, "({0}) {1}.", errorCode, new Win32Exception((int) errorCode).Message.Trim().TrimEnd('.').Trim());
@@ -95,7 +106,7 @@ public static void ThrowException(uint errorCode, string readPath, string writeP
switch (errorCode)
{
case Win32Errors.ERROR_INVALID_DRIVE:
- throw new System.IO.DriveNotFoundException(errorMessage);
+ throw new DriveNotFoundException(errorMessage);
case Win32Errors.ERROR_OPERATION_ABORTED:
@@ -103,11 +114,11 @@ public static void ThrowException(uint errorCode, string readPath, string writeP
case Win32Errors.ERROR_FILE_NOT_FOUND:
- throw new System.IO.FileNotFoundException(errorMessage);
+ throw new FileNotFoundException(errorMessage);
case Win32Errors.ERROR_PATH_NOT_FOUND:
- throw new System.IO.DirectoryNotFoundException(errorMessage);
+ throw new DirectoryNotFoundException(errorMessage);
case Win32Errors.ERROR_BAD_RECOVERY_POLICY:
@@ -174,8 +185,8 @@ public static void ThrowException(uint errorCode, string readPath, string writeP
throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "{0} {1}", Resources.Exception_From_Successful_Operation, errorMessage));
default:
- // We don't have a specific exception to generate for this error.
- throw new System.IO.IOException(errorMessage, Win32Errors.GetHrFromWin32Error(errorCode));
+ // We do not have a specific exception to generate for this error.
+ throw new IOException(errorMessage, Win32Errors.GetHrFromWin32Error(errorCode));
}
}
}
diff --git a/AlphaFS/Network/DfsInfo.cs b/AlphaFS/Network/DfsInfo.cs
index 517e37999..da0f6289b 100644
--- a/AlphaFS/Network/DfsInfo.cs
+++ b/AlphaFS/Network/DfsInfo.cs
@@ -19,11 +19,11 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Filesystem;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
+using Alphaleonis.Win32.Filesystem;
namespace Alphaleonis.Win32.Network
{
@@ -69,7 +69,7 @@ internal DfsInfo(NativeMethods.DFS_INFO_9 structure)
#region Methods
/// Returns the Universal Naming Convention (UNC) path of the DFS root or link.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return EntryPath;
diff --git a/AlphaFS/Network/DfsStorageInfo.cs b/AlphaFS/Network/DfsStorageInfo.cs
index a9a16e83b..67cdd4028 100644
--- a/AlphaFS/Network/DfsStorageInfo.cs
+++ b/AlphaFS/Network/DfsStorageInfo.cs
@@ -54,7 +54,7 @@ internal DfsStorageInfo(NativeMethods.DFS_STORAGE_INFO_1 structure)
#region Methods
/// The share name of the DFS root target or link target.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return ShareName;
diff --git a/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsLinks.cs b/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsLinks.cs
index 696904872..19c8c1314 100644
--- a/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsLinks.cs
+++ b/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsLinks.cs
@@ -31,7 +31,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Enumerates the DFS Links from a DFS namespace.
- /// of DFS namespaces.
+ /// Returns of DFS namespaces.
///
///
/// The operating system is older than Windows Vista.
diff --git a/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsRoot.cs b/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsRoot.cs
index 652f0475b..c99dff3a2 100644
--- a/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsRoot.cs
+++ b/AlphaFS/Network/Host Class/Host.DFS.EnumerateDfsRoot.cs
@@ -33,7 +33,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Enumerates the DFS namespaces from the local host.
- /// of DFS Root namespaces from the local host.
+ /// Returns an collection of DFS Root namespaces from the local host.
///
/// The operating system is older than Windows Vista.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")]
@@ -45,7 +45,7 @@ public static IEnumerable EnumerateDfsRoot()
/// Enumerates the DFS namespaces from a host.
- /// of DFS Root namespaces from a host.
+ /// Returns an collection of DFS Root namespaces from a host.
///
/// The operating system is older than Windows Vista.
/// The DNS or NetBIOS name of a host.
@@ -61,7 +61,7 @@ public static IEnumerable EnumerateDfsRoot(string host, bool continueOnE
/// Enumerates the DFS namespaces from a host.
- /// of DFS Root namespaces from a host.
+ /// Returns an collection of DFS Root namespaces from a host.
///
///
/// The operating system is older than Windows Vista.
diff --git a/AlphaFS/Network/Host Class/Host.DFS.EnumerateDomainDfsRoot.cs b/AlphaFS/Network/Host Class/Host.DFS.EnumerateDomainDfsRoot.cs
index 7fd53a43d..f0bb487ae 100644
--- a/AlphaFS/Network/Host Class/Host.DFS.EnumerateDomainDfsRoot.cs
+++ b/AlphaFS/Network/Host Class/Host.DFS.EnumerateDomainDfsRoot.cs
@@ -34,7 +34,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Enumerates the DFS namespaces from the domain.
- /// of DFS Root namespaces from the domain.
+ /// Returns an collection of DFS Root namespaces from the domain.
///
/// The operating system is older than Windows Vista.
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")]
@@ -46,7 +46,7 @@ public static IEnumerable EnumerateDomainDfsRoot()
/// Enumerates the DFS namespaces from a domain.
- /// of DFS Root namespaces from a domain.
+ /// Returns an collection of DFS Root namespaces from a domain.
///
/// The operating system is older than Windows Vista.
/// A domain name.
@@ -62,7 +62,7 @@ public static IEnumerable EnumerateDomainDfsRoot(string domain, bool con
/// Enumerates the DFS namespaces from a domain.
- /// of DFS Root namespaces from a domain.
+ /// Returns an collection of DFS Root namespaces from a domain.
///
///
/// The operating system is older than Windows Vista.
diff --git a/AlphaFS/Network/Host Class/Host.DFS.GetDfsClientInfo.cs b/AlphaFS/Network/Host Class/Host.DFS.GetDfsClientInfo.cs
index f9993fbaa..9c23f64a2 100644
--- a/AlphaFS/Network/Host Class/Host.DFS.GetDfsClientInfo.cs
+++ b/AlphaFS/Network/Host Class/Host.DFS.GetDfsClientInfo.cs
@@ -29,7 +29,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Gets information about a DFS root or link from the cache maintained by the DFS client.
- /// A instance.
+ /// Returns a instance.
///
/// The operating system is older than Windows Vista.
/// The Universal Naming Convention (UNC) path of a DFS root or link.
@@ -43,7 +43,7 @@ public static DfsInfo GetDfsClientInfo(string dfsName)
/// Gets information about a DFS root or link from the cache maintained by the DFS client.
- /// A instance.
+ /// Returns a instance.
///
/// The operating system is older than Windows Vista.
/// The Universal Naming Convention (UNC) path of a DFS root or link.
diff --git a/AlphaFS/Network/Host Class/Host.DFS.GetDfsInfo.cs b/AlphaFS/Network/Host Class/Host.DFS.GetDfsInfo.cs
index 863aa991a..de17e60f3 100644
--- a/AlphaFS/Network/Host Class/Host.DFS.GetDfsInfo.cs
+++ b/AlphaFS/Network/Host Class/Host.DFS.GetDfsInfo.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Gets information about a specified DFS root or link in a DFS namespace.
- /// A instance.
+ /// Returns a instance.
///
/// The operating system is older than Windows Vista.
/// The Universal Naming Convention (UNC) path of a DFS root or link.
@@ -46,7 +46,7 @@ public static DfsInfo GetDfsInfo(string dfsName)
/// Retrieves information about a specified DFS root or link in a DFS namespace.
- /// A instance.
+ /// Returns a instance.
///
///
/// The operating system is older than Windows Vista.
@@ -86,7 +86,7 @@ internal static DfsInfo GetDfsInfoCore(bool getFromClient, string dfsName, strin
var lastError = getFromClient ? NativeMethods.NetDfsGetClientInfo(dfsName, serverName, shareName, 9, out safeBuffer) : NativeMethods.NetDfsGetInfo(dfsName, null, null, 9, out safeBuffer);
if (lastError == Win32Errors.NERR_Success)
- return new DfsInfo(safeBuffer.PtrToStructure(0));
+ return new DfsInfo(safeBuffer.PtrToStructure());
throw new NetworkInformationException((int)lastError);
}
diff --git a/AlphaFS/Network/Host Class/Host.EnumerateNetworkConnections.cs b/AlphaFS/Network/Host Class/Host.EnumerateNetworkConnections.cs
index 8fd10358c..560bca880 100644
--- a/AlphaFS/Network/Host Class/Host.EnumerateNetworkConnections.cs
+++ b/AlphaFS/Network/Host Class/Host.EnumerateNetworkConnections.cs
@@ -27,8 +27,8 @@ namespace Alphaleonis.Win32.Network
{
public static partial class Host
{
- /// [AlphaFS] Returns an enumerable collection of defined network connections on the local host.
- /// An collection of defined network connections on the local host.
+ /// [AlphaFS] Returns an collection of defined network connections on the local host.
+ /// Returns an collection of defined network connections on the local host.
[SecurityCritical]
public static IEnumerable EnumerateNetworkConnections()
{
@@ -38,9 +38,9 @@ public static IEnumerable EnumerateNetworkConnections()
- /// [AlphaFS] Returns an enumerable collection of defined network connections on the local host.
+ /// [AlphaFS] Returns an collection of defined network connections on the local host.
/// A that specifies the network connection ID.
- /// An collection of network connection ID's on the local host.
+ /// Returns an collection of network connection ID's on the local host.
[SecurityCritical]
internal static IEnumerable EnumerateNetworkConnectionsCore(Guid? networkConnectionID)
{
diff --git a/AlphaFS/Network/Host Class/Host.EnumerateNetworks.cs b/AlphaFS/Network/Host Class/Host.EnumerateNetworks.cs
index d7c6b3dce..17b19171c 100644
--- a/AlphaFS/Network/Host Class/Host.EnumerateNetworks.cs
+++ b/AlphaFS/Network/Host Class/Host.EnumerateNetworks.cs
@@ -27,8 +27,8 @@ namespace Alphaleonis.Win32.Network
{
public static partial class Host
{
- /// [AlphaFS] Returns an enumerable collection of networks available on the local host.
- /// An collection of connected and disconnected networks on the local host.
+ /// [AlphaFS] Returns an collection of networks available on the local host.
+ /// Returns an collection of connected and disconnected networks on the local host.
[SecurityCritical]
public static IEnumerable EnumerateNetworks()
{
@@ -36,8 +36,8 @@ public static IEnumerable EnumerateNetworks()
}
- /// [AlphaFS] Returns an enumerable collection of networks available on the local host.
- /// An collection of networks on the local host, as specified by .
+ /// [AlphaFS] Returns an collection of networks available on the local host.
+ /// Returns an collection of networks on the local host, as specified by .
/// The that specify the connectivity level of the returned instances.
[SecurityCritical]
public static IEnumerable EnumerateNetworks(NetworkConnectivityLevels networkConnectivityLevels)
@@ -48,8 +48,8 @@ public static IEnumerable EnumerateNetworks(NetworkConnectivityLeve
- /// [AlphaFS] Returns an enumerable collection of networks available on the local host.
- /// An collection of networks on the local host, as specified by .
+ /// [AlphaFS] Returns an collection of networks available on the local host.
+ /// Returns an collection of networks on the local host, as specified by .
/// The that defines a network.
/// The that specify the connectivity level of the returned instances.
[SecurityCritical]
diff --git a/AlphaFS/Network/Host Class/Host.GetNetwork.cs b/AlphaFS/Network/Host Class/Host.GetNetwork.cs
index a35641794..84f271fd9 100644
--- a/AlphaFS/Network/Host Class/Host.GetNetwork.cs
+++ b/AlphaFS/Network/Host Class/Host.GetNetwork.cs
@@ -29,7 +29,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// [AlphaFS] Rretrieves a network based on a supplied network ID from the local host.
- /// A instance from the local host, as specified by .
+ /// Returns a instance from the local host, as specified by .
/// The that defines a network.
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID")]
[SecurityCritical]
diff --git a/AlphaFS/Network/Host Class/Host.GetNetworkConnection.cs b/AlphaFS/Network/Host Class/Host.GetNetworkConnection.cs
index c3fbcaf2d..5dea02ede 100644
--- a/AlphaFS/Network/Host Class/Host.GetNetworkConnection.cs
+++ b/AlphaFS/Network/Host Class/Host.GetNetworkConnection.cs
@@ -30,7 +30,7 @@ public static partial class Host
{
/// [AlphaFS] Retrieves a network based on a specified network connection ID.
/// A that specifies the network connection ID.
- /// A instance that represents the network connection ID.
+ /// Returns a instance that represents the network connection ID.
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID")]
[SecurityCritical]
public static NetworkConnectionInfo GetNetworkConnection(Guid networkConnectionID)
diff --git a/AlphaFS/Network/Host Class/Host.GetUncName.cs b/AlphaFS/Network/Host Class/Host.GetUncName.cs
index a0f41b17c..a953169db 100644
--- a/AlphaFS/Network/Host Class/Host.GetUncName.cs
+++ b/AlphaFS/Network/Host Class/Host.GetUncName.cs
@@ -23,15 +23,15 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Security;
-using Path = Alphaleonis.Win32.Filesystem.Path;
+using Alphaleonis.Win32.Filesystem;
namespace Alphaleonis.Win32.Network
{
/// Provides static methods to retrieve network resource information from a local- or remote host.
public static partial class Host
{
- /// Return the host name in UNC format, for example: \\hostname
- /// The unc name.
+ /// Return the local host name in UNC format, for example: \\hostname
+ /// The UNC host name.
[SecurityCritical]
public static string GetUncName()
{
@@ -40,13 +40,13 @@ public static string GetUncName()
/// Return the host name in UNC format, for example: \\hostname
- /// Name of the computer.
+ /// The name of the local or remote Computer.
/// The unc name.
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
[SecurityCritical]
- public static string GetUncName(string computerName)
+ public static string GetUncName(string hostName)
{
- return Utils.IsNullOrWhiteSpace(computerName) ? GetUncName() : (computerName.StartsWith(Path.UncPrefix, StringComparison.Ordinal) ? computerName.Trim() : Path.UncPrefix + computerName.Trim());
+ return Utils.IsNullOrWhiteSpace(hostName) ? GetUncName() : (hostName.StartsWith(Path.UncPrefix, StringComparison.Ordinal) ? hostName.Trim() : Path.UncPrefix + hostName.Trim());
}
}
}
diff --git a/AlphaFS/Network/Host Class/Host.SMB.EnumerateDrives.cs b/AlphaFS/Network/Host Class/Host.SMB.EnumerateDrives.cs
index e7b24a2ac..fabe1a205 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.EnumerateDrives.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.EnumerateDrives.cs
@@ -19,20 +19,20 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Filesystem;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net.NetworkInformation;
using System.Security;
+using Alphaleonis.Win32.Filesystem;
namespace Alphaleonis.Win32.Network
{
public static partial class Host
{
/// Enumerates drives from the local host.
- /// drives from the local host.
+ /// Returns an collection of drives from the local host.
///
[SecurityCritical]
public static IEnumerable EnumerateDrives()
@@ -42,7 +42,7 @@ public static IEnumerable EnumerateDrives()
/// Enumerates local drives from the specified host.
- /// drives from the specified host.
+ /// Returns an collection of drives from the specified host.
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
[SecurityCritical]
@@ -57,7 +57,7 @@ public static IEnumerable EnumerateDrives(string host)
/// Enumerates local drives from the specified host.
- /// drives from the specified host.
+ /// Returns an collection of drives from the specified host.
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
///
@@ -78,7 +78,7 @@ public static IEnumerable EnumerateDrives(string host, bool continueO
/// Enumerates local drives from the specified host.
- /// drives from the specified host.
+ /// Returns an collection of drives from the specified host.
///
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
diff --git a/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenConnections.cs b/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenConnections.cs
index a5c896f90..5dcfab92a 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenConnections.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenConnections.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Enumerates open connections from the local host.
- /// connection information from the local host.
+ /// Returns an collection of connection information from the local host.
///
///
[SecurityCritical]
@@ -41,7 +41,7 @@ public static IEnumerable EnumerateOpenConnections()
/// Enumerates open connections from the specified host.
- /// connection information from the specified .
+ /// Returns an collection of connection information from the specified .
///
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
@@ -54,7 +54,7 @@ public static IEnumerable EnumerateOpenConnections(string ho
/// Enumerates open connections from the specified host.
- /// connection information from the specified .
+ /// Returns an collection of connection information from the specified .
///
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
@@ -73,7 +73,7 @@ public static IEnumerable EnumerateOpenConnections(string ho
/// Enumerates open connections from the specified host and .
- /// connection information from the specified .
+ /// Returns an collection of connection information from the specified .
///
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
diff --git a/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenResources.cs b/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenResources.cs
index cbc4e6186..e8e0d973e 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenResources.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.EnumerateOpenResources.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Enumerates open resources from the local host.
- /// open resources from the local host.
+ /// Returns open resources from the local host.
///
///
[SecurityCritical]
@@ -41,7 +41,7 @@ public static IEnumerable EnumerateOpenResources()
/// Enumerates open resources from the specified host.
- /// open resources from the specified .
+ /// Returns an collection of open resources from the specified .
///
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
@@ -65,7 +65,7 @@ public static IEnumerable EnumerateOpenResources(string host,
/// >Enumerates open resources from the specified host.
- /// open resources from the specified .
+ /// Returns an collection of open resources from the specified .
///
///
/// The DNS or NetBIOS name of the remote server. null refers to the local host.
diff --git a/AlphaFS/Network/Host Class/Host.SMB.EnumerateSessions.cs b/AlphaFS/Network/Host Class/Host.SMB.EnumerateSessions.cs
index 714bf5020..4c22ae8bd 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.EnumerateSessions.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.EnumerateSessions.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// [AlphaFS] Enumerates sessions established on the local host.
- /// An collection from the local host.
+ /// Returns an collection from the local host.
[SecurityCritical]
public static IEnumerable EnumerateSessions()
{
@@ -39,7 +39,7 @@ public static IEnumerable EnumerateSessions()
/// [AlphaFS] Enumerates sessions established on the specified .
- /// An collection from the specified .
+ /// Returns an collection from the specified .
/// The DNS or NetBIOS name of the specified host. If this parameter is null, the local Computer is used.
[SecurityCritical]
public static IEnumerable EnumerateSessions(string hostName)
@@ -49,7 +49,7 @@ public static IEnumerable EnumerateSessions(string hostName)
/// [AlphaFS] Enumerates sessions established on the specified .
- /// An collection from the specified .
+ /// Returns an collection from the specified .
/// The DNS or NetBIOS name of the specified host. If this parameter is null, the local Computer is used.
/// The name of the Computer session for which information is to be returned. If this parameter is null, information for all Computer sessions on the server is returned.
[SecurityCritical]
@@ -60,7 +60,7 @@ public static IEnumerable EnumerateSessions(string hostName, string
/// [AlphaFS] Enumerates sessions established on the specified .
- /// An collection from the specified .
+ /// Returns an collection from the specified .
/// The DNS or NetBIOS name of the specified host. If this parameter is null, the local Computer is used.
/// The name of the Computer session for which information is to be returned. If this parameter is null, information for all Computer sessions on the server is returned.
/// The name of the user for which information is to be returned. If this parameter is null, information for all users is returned.
@@ -74,7 +74,7 @@ public static IEnumerable EnumerateSessions(string hostName, string
/// [AlphaFS] Enumerates sessions established on the specified .
- /// An collection from the specified .
+ /// Returns an collection from the specified .
///
/// The DNS or NetBIOS name of the specified host. If this parameter is null, the local Computer is used.
/// The name of the Computer session for which information is to be returned. If this parameter is null, information for all Computer sessions on the server is returned.
diff --git a/AlphaFS/Network/Host Class/Host.SMB.EnumerateShares.cs b/AlphaFS/Network/Host Class/Host.SMB.EnumerateShares.cs
index be2bd8b96..507b53540 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.EnumerateShares.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.EnumerateShares.cs
@@ -30,19 +30,17 @@ namespace Alphaleonis.Win32.Network
{
public static partial class Host
{
- /// Enumerates Server Message Block (SMB) shares from the local host.
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+ /// Enumerates (hidden) Server Message Block (SMB) shares from the local host.
+ /// Returns an collection of shares from the specified host.
[SecurityCritical]
public static IEnumerable EnumerateShares()
{
return EnumerateSharesCore(null, ShareType.All, false);
}
-
- /// Enumerates Server Message Block (SMB) shares from the local host.
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+
+ /// Enumerates (hidden) Server Message Block (SMB) shares from the local host.
+ /// Returns an collection of shares from the specified host.
/// true suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
[SecurityCritical]
public static IEnumerable EnumerateShares(bool continueOnException)
@@ -50,10 +48,9 @@ public static IEnumerable EnumerateShares(bool continueOnException)
return EnumerateSharesCore(null, ShareType.All, continueOnException);
}
-
- /// Enumerates Server Message Block (SMB) shares from the local host.
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+
+ /// Enumerates (hidden) Server Message Block (SMB) shares from the local host.
+ /// Returns an collection of shares from the specified host.
/// The type of the shared resource to retrieve.
/// true suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
[SecurityCritical]
@@ -62,10 +59,9 @@ public static IEnumerable EnumerateShares(ShareType shareType, bool c
return EnumerateSharesCore(null, shareType, continueOnException);
}
-
- /// Enumerates Server Message Block (SMB) shares from the specified .
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+
+ /// Enumerates (hidden) Server Message Block (SMB) shares from the specified .
+ /// Returns an collection of shares from the specified host.
/// The DNS or NetBIOS name of the specified host.
[SecurityCritical]
public static IEnumerable EnumerateShares(string host)
@@ -73,10 +69,9 @@ public static IEnumerable EnumerateShares(string host)
return EnumerateSharesCore(host, ShareType.All, false);
}
-
- /// Enumerates Server Message Block (SMB) shares from the specified .
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+
+ /// Enumerates (hidden) Server Message Block (SMB) shares from the specified .
+ /// Returns an collection of shares from the specified host.
/// The DNS or NetBIOS name of the specified host.
/// true suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
[SecurityCritical]
@@ -85,10 +80,9 @@ public static IEnumerable EnumerateShares(string host, bool continueO
return EnumerateSharesCore(host, ShareType.All, continueOnException);
}
-
- /// Enumerates Server Message Block (SMB) shares from the specified .
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+
+ /// Enumerates (hidden) Server Message Block (SMB) shares from the specified .
+ /// Returns an collection of shares from the specified host.
/// The DNS or NetBIOS name of the specified host.
/// The type of the shared resource to retrieve.
/// true suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
@@ -101,9 +95,8 @@ public static IEnumerable EnumerateShares(string host, ShareType shar
- /// Enumerates Server Message Block (SMB) shares from a local or remote host.
- /// shares from the specified host.
- /// This method also enumerates hidden shares.
+ /// Enumerates (hidden) Server Message Block (SMB) shares from a local or remote host.
+ /// Returns an collection of shares from the specified host.
///
///
/// The DNS or NetBIOS name of the specified host.
diff --git a/AlphaFS/Network/Host Class/Host.SMB.GetHostShareFromPath.cs b/AlphaFS/Network/Host Class/Host.SMB.GetHostShareFromPath.cs
index cda42d177..809b2595b 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.GetHostShareFromPath.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.GetHostShareFromPath.cs
@@ -19,10 +19,10 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Filesystem;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Security;
+using Alphaleonis.Win32.Filesystem;
namespace Alphaleonis.Win32.Network
{
diff --git a/AlphaFS/Network/Host Class/Host.SMB.GetNetStatistics.cs b/AlphaFS/Network/Host Class/Host.SMB.GetNetStatistics.cs
index a1b6d1fd7..4b1ace1ec 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.GetNetStatistics.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.GetNetStatistics.cs
@@ -29,7 +29,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// [AlphaFS] Retrieves operating statistics for the Server service from the local host.
- /// A instance.
+ /// Returns a instance.
///
[SecurityCritical]
public static ServerStatisticsInfo GetServerStatistics()
@@ -39,7 +39,7 @@ public static ServerStatisticsInfo GetServerStatistics()
/// [AlphaFS] Retrieves operating statistics for the Server service from the specified host.
- /// A instance.
+ /// Returns a instance.
///
/// The DNS or NetBIOS name of the local or remote host to retrieve statistics from.
[SecurityCritical]
@@ -52,7 +52,7 @@ public static ServerStatisticsInfo GetServerStatistics(string hostName)
/// [AlphaFS] Retrieves operating statistics for the Workstation service from the local host.
- /// A instance.
+ /// Returns a instance.
///
[SecurityCritical]
public static WorkstationStatisticsInfo GetWorkstationStatistics()
@@ -62,7 +62,7 @@ public static WorkstationStatisticsInfo GetWorkstationStatistics()
/// [AlphaFS] Retrieves operating statistics for the Workstation service from the specified host.
- /// A instance.
+ /// Returns a instance.
///
/// The DNS or NetBIOS name of the local or remote host to retrieve statistics from.
[SecurityCritical]
@@ -75,7 +75,7 @@ public static WorkstationStatisticsInfo GetWorkstationStatistics(string hostName
/// [AlphaFS] Retrieves or operating statistics for the Server- or Workstation service from the specified host.
- /// A or instance, depending on the value.
+ /// Returns a or instance, depending on the value.
///
/// true returns information, false .
/// The DNS or NetBIOS name of the local or remote host to retrieve statistics from.
@@ -109,7 +109,7 @@ internal static T GetNetStatisticsNative(bool isServer, string hostName)
throw new NetworkInformationException((int) lastError);
- return safeBuffer.PtrToStructure(0);
+ return safeBuffer.PtrToStructure();
}
}
}
diff --git a/AlphaFS/Network/Host Class/Host.SMB.GetShareInfo.cs b/AlphaFS/Network/Host Class/Host.SMB.GetShareInfo.cs
index aca8c5f93..6e99dfac7 100644
--- a/AlphaFS/Network/Host Class/Host.SMB.GetShareInfo.cs
+++ b/AlphaFS/Network/Host Class/Host.SMB.GetShareInfo.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
public static partial class Host
{
/// Retrieves information about the Server Message Block (SMB) share as defined on the specified host.
- /// A class, or null on failure or when not available, and is true.
+ /// Returns a class, or null on failure or when not available, and is true.
/// The share in the format: \\host\share.
/// true to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
[SecurityCritical]
@@ -42,7 +42,7 @@ public static ShareInfo GetShareInfo(string uncPath, bool continueOnException)
/// Retrieves information about the Server Message Block (SMB) share as defined on the specified host.
- /// A class, or null on failure or when not available, and is true.
+ /// Returns a class, or null on failure or when not available, and is true.
/// One of the options.
/// The share in the format: \\host\share.
/// true to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
@@ -55,7 +55,7 @@ public static ShareInfo GetShareInfo(ShareInfoLevel shareLevel, string uncPath,
/// Retrieves information about the Server Message Block (SMB) share as defined on the specified host.
- /// A class, or null on failure or when not available, and is true.
+ /// Returns a class, or null on failure or when not available, and is true.
/// The DNS or NetBIOS name of the specified host.
/// The name of the Server Message Block (SMB) share.
/// true to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.
@@ -67,7 +67,7 @@ public static ShareInfo GetShareInfo(string host, string share, bool continueOnE
/// Retrieves information about the Server Message Block (SMB) share as defined on the specified host.
- /// A class, or null on failure or when not available, and is true.
+ /// Returns a class, or null on failure or when not available, and is true.
/// One of the options.
/// A string that specifies the DNS or NetBIOS name of the specified .
/// A string that specifies the name of the Server Message Block (SMB) share.
@@ -82,7 +82,7 @@ public static ShareInfo GetShareInfo(ShareInfoLevel shareLevel, string host, str
/// Gets the structure of a Server Message Block (SMB) share.
- /// A class, or null on failure or when not available, and is true.
+ /// Returns a class, or null on failure or when not available, and is true.
///
/// One of the options.
/// A string that specifies the DNS or NetBIOS name of the specified .
@@ -119,22 +119,22 @@ internal static ShareInfo GetShareInfoCore(ShareInfoLevel shareLevel, string hos
switch (shareLevel)
{
case ShareInfoLevel.Info1005:
- return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0))
+ return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure())
{
NetFullPath = Path.CombineCore(false, Path.UncPrefix + stripUnc, share)
};
case ShareInfoLevel.Info503:
- return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0));
+ return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure());
case ShareInfoLevel.Info2:
- return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0));
+ return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure());
case ShareInfoLevel.Info1:
- return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0));
+ return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure());
}
break;
diff --git a/AlphaFS/Network/Host Class/Host.WNet.DriveConnection.cs b/AlphaFS/Network/Host Class/Host.WNet.DriveConnection.cs
index 37c020c9b..6d9c959bf 100644
--- a/AlphaFS/Network/Host Class/Host.WNet.DriveConnection.cs
+++ b/AlphaFS/Network/Host Class/Host.WNet.DriveConnection.cs
@@ -138,7 +138,7 @@ private void Dispose(bool isDisposing)
/// Returns the last available drive letter used for this connection.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return LocalName;
diff --git a/AlphaFS/Network/Host Class/Host.cs b/AlphaFS/Network/Host Class/Host.cs
index fdcaa912d..d7af2e6a0 100644
--- a/AlphaFS/Network/Host Class/Host.cs
+++ b/AlphaFS/Network/Host Class/Host.cs
@@ -19,7 +19,6 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Filesystem;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -30,6 +29,7 @@
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
+using Alphaleonis.Win32.Filesystem;
using Path = Alphaleonis.Win32.Filesystem.Path;
namespace Alphaleonis.Win32.Network
@@ -280,7 +280,7 @@ internal static IEnumerable EnumerateNetworkObjectCoreThis method uses level to retrieve full REMOTE_NAME_INFO structure.
- /// A structure.
+ /// Returns a structure.
/// AlphaFS regards network drives created using SUBST.EXE as invalid.
///
///
@@ -311,7 +311,7 @@ internal static NativeMethods.REMOTE_NAME_INFO GetRemoteNameInfoCore(string path
lastError = NativeMethods.WNetGetUniversalName(path, 2, buffer, out bufferSize);
if (lastError == Win32Errors.NO_ERROR)
- return buffer.PtrToStructure(0);
+ return buffer.PtrToStructure();
}
} while (lastError == Win32Errors.ERROR_MORE_DATA);
diff --git a/AlphaFS/Network/NetworkListManager.cs b/AlphaFS/Network/Native Methods/NativeMethods.NetworkListManager.cs
similarity index 100%
rename from AlphaFS/Network/NetworkListManager.cs
rename to AlphaFS/Network/Native Methods/NativeMethods.NetworkListManager.cs
diff --git a/AlphaFS/Network/NetworkConnectionInfo.cs b/AlphaFS/Network/NetworkConnectionInfo.cs
index 14659bc1e..22a91363f 100644
--- a/AlphaFS/Network/NetworkConnectionInfo.cs
+++ b/AlphaFS/Network/NetworkConnectionInfo.cs
@@ -29,7 +29,7 @@ namespace Alphaleonis.Win32.Network
/// Represents a connection to a network.
public class NetworkConnectionInfo
{
- #region Private Fields
+ #region Fields
private readonly NativeMethods.INetworkConnection _networkConnection;
@@ -85,7 +85,7 @@ public bool IsConnectedToInternet
/// Retrieves an instance that represents the network associated with this connection. This value of this property is not cached.
- /// A instance.
+ /// Returns a instance.
public NetworkInfo NetworkInfo
{
get { return new NetworkInfo(_networkConnection.GetNetwork()); }
@@ -126,7 +126,7 @@ public NetworkInterface NetworkInterface
#region Methods
/// Returns storage device as: "VendorId ProductId DeviceType DeviceNumber:PartitionNumber".
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return null != NetworkInfo && null != NetworkInterface ? string.Format(CultureInfo.CurrentCulture, "{0} {1}", NetworkInfo.Name, NetworkInterface.Name) : GetType().Name;
@@ -152,7 +152,7 @@ public override bool Equals(object obj)
/// Serves as a hash function for a particular type.
- /// A hash code for the current Object.
+ /// Returns a hash code for the current Object.
public override int GetHashCode()
{
unchecked
diff --git a/AlphaFS/Network/NetworkInfo.cs b/AlphaFS/Network/NetworkInfo.cs
index 34964f52d..32e5fa30b 100644
--- a/AlphaFS/Network/NetworkInfo.cs
+++ b/AlphaFS/Network/NetworkInfo.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
[Serializable]
public class NetworkInfo : IEquatable
{
- #region Private Fields
+ #region Fields
[NonSerialized]
private readonly NativeMethods.INetwork _network;
@@ -186,7 +186,7 @@ public Guid NetworkId
#region Methods
/// Returns storage device as: "VendorId ProductId DeviceType DeviceNumber:PartitionNumber".
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
var description = !Utils.IsNullOrWhiteSpace(Description) && !Equals(Name, Description) ? " (" + Description + ")" : string.Empty;
diff --git a/AlphaFS/Network/OpenConnectionInfo.cs b/AlphaFS/Network/OpenConnectionInfo.cs
index bf9fc050a..b3d578f0e 100644
--- a/AlphaFS/Network/OpenConnectionInfo.cs
+++ b/AlphaFS/Network/OpenConnectionInfo.cs
@@ -30,7 +30,7 @@ namespace Alphaleonis.Win32.Network
[Serializable]
public sealed class OpenConnectionInfo
{
- #region Private Fields
+ #region Fields
private string _netName;
@@ -58,7 +58,7 @@ internal OpenConnectionInfo(string hostName, NativeMethods.CONNECTION_INFO_1 con
#region Methods
/// Returns the full path to the share.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return Id.ToString(CultureInfo.InvariantCulture);
@@ -72,7 +72,10 @@ public override string ToString()
/// The local or remote Host.
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[Obsolete("Use HostName")]
- public string Host { get; private set; }
+ public string Host
+ {
+ get { return HostName; }
+ }
/// The host name of this connection information.
public string HostName { get; private set; }
@@ -92,7 +95,10 @@ public override string ToString()
/// Specifies the number of seconds that the connection has been established.
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[Obsolete("Use ConnectedTime property.")]
- public long ConnectedSeconds { get; private set; }
+ public long ConnectedSeconds
+ {
+ get { return ConnectedTime.Seconds; }
+ }
/// Specifies duration that the connection has been established.
public TimeSpan ConnectedTime { get; private set; }
diff --git a/AlphaFS/Network/OpenResourceInfo.cs b/AlphaFS/Network/OpenResourceInfo.cs
index 235139868..70c7aec87 100644
--- a/AlphaFS/Network/OpenResourceInfo.cs
+++ b/AlphaFS/Network/OpenResourceInfo.cs
@@ -59,7 +59,7 @@ public void Close()
}
/// Returns the full path to the share.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return Id.ToString(CultureInfo.InvariantCulture);
@@ -73,7 +73,10 @@ public override string ToString()
/// The local or remote Host.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[Obsolete("Use HostName")]
- public string Host { get; private set; }
+ public string Host
+ {
+ get { return HostName; }
+ }
/// The host name of this resource information.
public string HostName { get; private set; }
diff --git a/AlphaFS/Network/ServerStatisticsInfo.cs b/AlphaFS/Network/ServerStatisticsInfo.cs
index 1102eebc0..59535bbb8 100644
--- a/AlphaFS/Network/ServerStatisticsInfo.cs
+++ b/AlphaFS/Network/ServerStatisticsInfo.cs
@@ -102,7 +102,7 @@ public int BufferRequestFailed
/// The number of server bytes received from the network.
public long BytesReceived
{
- get { return Filesystem.NativeMethods.ToLong(_serverStat.sts0_bytesrcvd_high, _serverStat.sts0_bytesrcvd_low); }
+ get { return Utils.ToLong(_serverStat.sts0_bytesrcvd_high, _serverStat.sts0_bytesrcvd_low); }
}
@@ -116,7 +116,7 @@ public string BytesReceivedUnitSize
/// The number of server bytes sent to the network.
public long BytesSent
{
- get { return Filesystem.NativeMethods.ToLong(_serverStat.sts0_bytessent_high, _serverStat.sts0_bytessent_low); }
+ get { return Utils.ToLong(_serverStat.sts0_bytessent_high, _serverStat.sts0_bytessent_low); }
}
@@ -215,7 +215,7 @@ public void Refresh()
/// Returns the local time when statistics collection started or when the statistics were last cleared.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return HostName;
diff --git a/AlphaFS/Network/SessionInfo.cs b/AlphaFS/Network/SessionInfo.cs
index 0163f98c1..afac16ade 100644
--- a/AlphaFS/Network/SessionInfo.cs
+++ b/AlphaFS/Network/SessionInfo.cs
@@ -28,7 +28,7 @@ namespace Alphaleonis.Win32.Network
[Serializable]
public sealed class SessionInfo
{
- #region Private Fields
+ #region Fields
private string _netName;
@@ -120,7 +120,7 @@ internal SessionInfo(string hostName, SessionInfoLevel sessionLevel, object stru
#region Methods
/// Returns the host name of this session information.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return HostName;
diff --git a/AlphaFS/Network/ShareInfo.cs b/AlphaFS/Network/ShareInfo.cs
index 5b5650a3a..91bd2f27f 100644
--- a/AlphaFS/Network/ShareInfo.cs
+++ b/AlphaFS/Network/ShareInfo.cs
@@ -19,9 +19,9 @@
* THE SOFTWARE.
*/
-using Alphaleonis.Win32.Filesystem;
using System;
using System.Globalization;
+using Alphaleonis.Win32.Filesystem;
namespace Alphaleonis.Win32.Network
{
@@ -119,7 +119,7 @@ internal ShareInfo(string host, ShareInfoLevel shareLevel, object shareInfo)
#region Methods
/// Returns the full path to the share.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return NetFullPath;
diff --git a/AlphaFS/Network/WorkstationStatisticsInfo.cs b/AlphaFS/Network/WorkstationStatisticsInfo.cs
index 4c0126dd1..6c493088c 100644
--- a/AlphaFS/Network/WorkstationStatisticsInfo.cs
+++ b/AlphaFS/Network/WorkstationStatisticsInfo.cs
@@ -454,7 +454,7 @@ public void Refresh()
/// Returns the local time when statistics collection started or when the statistics were last cleared.
- /// A string that represents this instance.
+ /// Returns a string that represents this instance.
public override string ToString()
{
return HostName;
diff --git a/AlphaFS/OperatingSystem/EnumOsName.cs b/AlphaFS/OperatingSystem/EnumOsName.cs
new file mode 100644
index 000000000..f39a3354c
--- /dev/null
+++ b/AlphaFS/OperatingSystem/EnumOsName.cs
@@ -0,0 +1,81 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32
+{
+ /// [AlphaFS] Static class providing access to information about the operating system under which the assembly is executing.
+ public static partial class OperatingSystem
+ {
+ /// [AlphaFS] A set of flags that describe the named Windows versions.
+ /// The values of the enumeration are ordered. A later released operating system version has a higher number, so comparisons between named versions are meaningful.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
+ public enum EnumOsName
+ {
+ /// A Windows version earlier than Windows 2000.
+ Earlier = -1,
+
+ /// Windows 2000 (Server or Professional).
+ Windows2000 = 0,
+
+ /// Windows XP.
+ WindowsXP = 1,
+
+ /// Windows Server 2003.
+ WindowsServer2003 = 2,
+
+ /// Windows Vista.
+ WindowsVista = 3,
+
+ /// Windows Server 2008.
+ WindowsServer2008 = 4,
+
+ /// Windows 7.
+ Windows7 = 5,
+
+ /// Windows Server 2008 R2.
+ WindowsServer2008R2 = 6,
+
+ /// Windows 8.
+ Windows8 = 7,
+
+ /// Windows Server 2012.
+ WindowsServer2012 = 8,
+
+ /// Windows 8.1.
+ Windows81 = 9,
+
+ /// Windows Server 2012 R2
+ WindowsServer2012R2 = 10,
+
+ /// Windows 10
+ Windows10 = 11,
+
+ /// Windows Server 2016
+ WindowsServer2016 = 12,
+
+ /// A later version of Windows than currently installed.
+ Later = 65535
+ }
+ }
+}
diff --git a/AlphaFS/OperatingSystem/EnumProcessorArchitecture.cs b/AlphaFS/OperatingSystem/EnumProcessorArchitecture.cs
new file mode 100644
index 000000000..e90612db6
--- /dev/null
+++ b/AlphaFS/OperatingSystem/EnumProcessorArchitecture.cs
@@ -0,0 +1,57 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System.Diagnostics.CodeAnalysis;
+
+namespace Alphaleonis.Win32
+{
+ /// [AlphaFS] Static class providing access to information about the operating system under which the assembly is executing.
+ public static partial class OperatingSystem
+ {
+ /// [AlphaFS] A set of flags to indicate the current processor architecture for which the operating system is targeted and running.
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pa")]
+ [SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")]
+ public enum EnumProcessorArchitecture
+ {
+ /// PROCESSOR_ARCHITECTURE_INTEL
+ /// The system is running a 32-bit version of Windows.
+ ///
+ X86 = 0,
+
+ /// PROCESSOR_ARCHITECTURE_IA64
+ /// The system is running on a Itanium processor.
+ ///
+ [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
+ [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
+ IA64 = 6,
+
+ /// PROCESSOR_ARCHITECTURE_AMD64
+ /// The system is running a 64-bit version of Windows.
+ ///
+ X64 = 9,
+
+ /// PROCESSOR_ARCHITECTURE_UNKNOWN
+ /// Unknown architecture.
+ ///
+ Unknown = 65535
+ }
+ }
+}
diff --git a/AlphaFS/OperatingSystem/IsAtLeast.cs b/AlphaFS/OperatingSystem/IsAtLeast.cs
new file mode 100644
index 000000000..e991a4c2b
--- /dev/null
+++ b/AlphaFS/OperatingSystem/IsAtLeast.cs
@@ -0,0 +1,45 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Alphaleonis.Win32
+{
+ /// [AlphaFS] Static class providing access to information about the operating system under which the assembly is executing.
+ public static partial class OperatingSystem
+ {
+ /// [AlphaFS] Determines whether the operating system is of the specified version or later.
+ /// true if the operating system is of the specified or later; otherwise, false.
+ /// The lowest version for which to return true.
+ public static bool IsAtLeast(EnumOsName version)
+ {
+ return VersionName >= version;
+ }
+
+
+ /// [AlphaFS] Determines whether the operating system is of the specified version or later, allowing specification of a minimum service pack that must be installed on the lowest version.
+ /// true if the operating system matches the specified with the specified service pack, or if the operating system is of a later version; otherwise, false.
+ /// The minimum required version.
+ /// The major version of the service pack that must be installed on the minimum required version to return true. This can be 0 to indicate that no service pack is required.
+ public static bool IsAtLeast(EnumOsName version, int servicePackVersion)
+ {
+ return IsAtLeast(version) && ServicePackVersion.Major >= servicePackVersion;
+ }
+ }
+}
diff --git a/AlphaFS/OperatingSystem/NativeMethods.OperatingSystem.cs b/AlphaFS/OperatingSystem/NativeMethods.OperatingSystem.cs
new file mode 100644
index 000000000..f1d163e69
--- /dev/null
+++ b/AlphaFS/OperatingSystem/NativeMethods.OperatingSystem.cs
@@ -0,0 +1,108 @@
+/* Copyright (C) 2008-2018 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace Alphaleonis.Win32
+{
+ /// [AlphaFS] Static class providing access to information about the operating system under which the assembly is executing.
+ public static partial class OperatingSystem
+ {
+ private static class NativeMethods
+ {
+ internal const short VER_NT_WORKSTATION = 1;
+ internal const short VER_NT_DOMAIN_CONTROLLER = 2;
+ internal const short VER_NT_SERVER = 3;
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct RTL_OSVERSIONINFOEXW
+ {
+ public int dwOSVersionInfoSize;
+ public readonly int dwMajorVersion;
+ public readonly int dwMinorVersion;
+ public readonly int dwBuildNumber;
+ public readonly int dwPlatformId;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
+ public readonly string szCSDVersion;
+ public readonly ushort wServicePackMajor;
+ public readonly ushort wServicePackMinor;
+ public readonly ushort wSuiteMask;
+ public readonly byte wProductType;
+ public readonly byte wReserved;
+ }
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct SYSTEM_INFO
+ {
+ public readonly EnumProcessorArchitecture wProcessorArchitecture;
+ public readonly ushort wReserved;
+ public readonly uint dwPageSize;
+ public readonly IntPtr lpMinimumApplicationAddress;
+ public readonly IntPtr lpMaximumApplicationAddress;
+ public readonly IntPtr dwActiveProcessorMask;
+ public readonly uint dwNumberOfProcessors;
+ public readonly uint dwProcessorType;
+ public readonly uint dwAllocationGranularity;
+ public readonly ushort wProcessorLevel;
+ public readonly ushort wProcessorRevision;
+ }
+
+
+ /// The RtlGetVersion routine returns version information about the currently running operating system.
+ /// RtlGetVersion returns STATUS_SUCCESS.
+ /// Available starting with Windows 2000.
+ [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("ntdll.dll", SetLastError = true, CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool RtlGetVersion([MarshalAs(UnmanagedType.Struct)] ref RTL_OSVERSIONINFOEXW lpVersionInformation);
+
+
+ /// Retrieves information about the current system to an application running under WOW64.
+ /// If the function is called from a 64-bit application, it is equivalent to the GetSystemInfo function.
+ ///
+ /// This function does not return a value.
+ /// To determine whether a Win32-based application is running under WOW64, call the function.
+ /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]
+ /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ internal static extern void GetNativeSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
+
+
+ /// Determines whether the specified process is running under WOW64.
+ ///
+ /// If the function succeeds, the return value is a nonzero value.
+ /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
+ ///
+ /// Minimum supported client: Windows Vista, Windows XP with SP2 [desktop apps only]
+ /// Minimum supported server: Windows Server 2008, Windows Server 2003 with SP1 [desktop apps only]
+ [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
+ [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool IsWow64Process([In] IntPtr hProcess, [Out, MarshalAs(UnmanagedType.Bool)] out bool lpSystemInfo);
+ }
+ }
+}
diff --git a/AlphaFS/OperatingSystem.cs b/AlphaFS/OperatingSystem/OperatingSystem.cs
similarity index 53%
rename from AlphaFS/OperatingSystem.cs
rename to AlphaFS/OperatingSystem/OperatingSystem.cs
index 958bb9a91..9786c7302 100644
--- a/AlphaFS/OperatingSystem.cs
+++ b/AlphaFS/OperatingSystem/OperatingSystem.cs
@@ -24,101 +24,27 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
-using System.Security;
namespace Alphaleonis.Win32
{
- /// Static class providing access to information about the operating system under which the assembly is executing.
- public static class OperatingSystem
+ /// [AlphaFS] Static class providing access to information about the operating system under which the assembly is executing.
+ public static partial class OperatingSystem
{
- /// A set of flags that describe the named Windows versions.
- /// The values of the enumeration are ordered. A later released operating system version has a higher number, so comparisons between named versions are meaningful.
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")]
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")]
- public enum EnumOsName
- {
- /// A Windows version earlier than Windows 2000.
- Earlier = -1,
-
- /// Windows 2000 (Server or Professional).
- Windows2000 = 0,
-
- /// Windows XP.
- WindowsXP = 1,
-
- /// Windows Server 2003.
- WindowsServer2003 = 2,
-
- /// Windows Vista.
- WindowsVista = 3,
-
- /// Windows Server 2008.
- WindowsServer2008 = 4,
-
- /// Windows 7.
- Windows7 = 5,
-
- /// Windows Server 2008 R2.
- WindowsServer2008R2 = 6,
-
- /// Windows 8.
- Windows8 = 7,
-
- /// Windows Server 2012.
- WindowsServer2012 = 8,
-
- /// Windows 8.1.
- Windows81 = 9,
-
- /// Windows Server 2012 R2
- WindowsServer2012R2 = 10,
-
- /// Windows 10
- Windows10 = 11,
-
- /// Windows Server 2016
- WindowsServer2016 = 12,
-
- /// A later version of Windows than currently installed.
- Later = 65535
- }
+ #region Fields
+ private static bool _isServer;
+ private static bool? _isWow64Process;
+ private static Version _osVersion;
+ private static EnumOsName _enumOsName = EnumOsName.Later;
+ private static EnumProcessorArchitecture _processorArchitecture;
+ private static Version _servicePackVersion;
- /// A set of flags to indicate the current processor architecture for which the operating system is targeted and running.
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pa")]
- [SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")]
- public enum EnumProcessorArchitecture
- {
- /// PROCESSOR_ARCHITECTURE_INTEL
- /// The system is running a 32-bit version of Windows.
- ///
- X86 = 0,
-
- /// PROCESSOR_ARCHITECTURE_IA64
- /// The system is running on a Itanium processor.
- ///
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")]
- [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")]
- IA64 = 6,
-
- /// PROCESSOR_ARCHITECTURE_AMD64
- /// The system is running a 64-bit version of Windows.
- ///
- X64 = 9,
-
- /// PROCESSOR_ARCHITECTURE_UNKNOWN
- /// Unknown architecture.
- ///
- Unknown = 65535
- }
+ #endregion // Private Fields
-
-
#region Properties
- private static bool _isServer;
- /// Gets a value indicating whether the operating system is a server operating system.
+ /// [AlphaFS] Gets a value indicating whether the operating system is a server operating system.
/// true if the current operating system is a server operating system; otherwise, false.
public static bool IsServer
{
@@ -131,9 +57,8 @@ public static bool IsServer
}
}
-
- private static bool? _isWow64Process;
- /// Gets a value indicating whether the current process is running under WOW64.
+
+ /// [AlphaFS] Gets a value indicating whether the current process is running under WOW64.
/// true if the current process is running under WOW64; otherwise, false.
public static bool IsWow64Process
{
@@ -159,8 +84,7 @@ public static bool IsWow64Process
}
- private static Version _osVersion;
- /// Gets the numeric version of the operating system.
+ /// [AlphaFS] Gets the numeric version of the operating system.
/// The numeric version of the operating system.
public static Version OSVersion
{
@@ -173,9 +97,8 @@ public static Version OSVersion
}
}
-
- private static EnumOsName _enumOsName = EnumOsName.Later;
- /// Gets the named version of the operating system.
+
+ /// [AlphaFS] Gets the named version of the operating system.
/// The named version of the operating system.
public static EnumOsName VersionName
{
@@ -188,9 +111,8 @@ public static EnumOsName VersionName
}
}
-
- private static EnumProcessorArchitecture _processorArchitecture;
- /// Gets the processor architecture for which the operating system is targeted.
+
+ /// [AlphaFS] Gets the processor architecture for which the operating system is targeted.
/// The processor architecture for which the operating system is targeted.
/// If running under WOW64 this will return a 32-bit processor. Use to determine if this is the case.
public static EnumProcessorArchitecture ProcessorArchitecture
@@ -204,9 +126,8 @@ public static EnumProcessorArchitecture ProcessorArchitecture
}
}
-
- private static Version _servicePackVersion;
- /// Gets the version of the service pack currently installed on the operating system.
+
+ /// [AlphaFS] Gets the version of the service pack currently installed on the operating system.
/// The version of the service pack currently installed on the operating system.
/// Only the and fields are used.
public static Version ServicePackVersion
@@ -221,32 +142,7 @@ public static Version ServicePackVersion
}
#endregion // Properties
-
-
- #region Methods
-
- /// Determines whether the operating system is of the specified version or later.
- /// true if the operating system is of the specified or later; otherwise, false.
- /// The lowest version for which to return true.
- public static bool IsAtLeast(EnumOsName version)
- {
- return VersionName >= version;
- }
-
- /// Determines whether the operating system is of the specified version or later, allowing specification of a minimum service pack that must be installed on the lowest version.
- /// true if the operating system matches the specified with the specified service pack, or if the operating system is of a later version; otherwise, false.
- /// The minimum required version.
- /// The major version of the service pack that must be installed on the minimum required version to return true. This can be 0 to indicate that no service pack is required.
- public static bool IsAtLeast(EnumOsName version, int servicePackVersion)
- {
- return IsAtLeast(version) && ServicePackVersion.Major >= servicePackVersion;
- }
-
- #endregion // Methods
-
-
- #region Private
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "RtlGetVersion")]
private static void UpdateData()
@@ -405,83 +301,5 @@ private static void UpdateData()
break;
}
}
-
-
- private static class NativeMethods
- {
- internal const short VER_NT_WORKSTATION = 1;
- internal const short VER_NT_DOMAIN_CONTROLLER = 2;
- internal const short VER_NT_SERVER = 3;
-
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- internal struct RTL_OSVERSIONINFOEXW
- {
- public int dwOSVersionInfoSize;
- public readonly int dwMajorVersion;
- public readonly int dwMinorVersion;
- public readonly int dwBuildNumber;
- public readonly int dwPlatformId;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- public readonly string szCSDVersion;
- public readonly ushort wServicePackMajor;
- public readonly ushort wServicePackMinor;
- public readonly ushort wSuiteMask;
- public readonly byte wProductType;
- public readonly byte wReserved;
- }
-
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- internal struct SYSTEM_INFO
- {
- public readonly EnumProcessorArchitecture wProcessorArchitecture;
- private readonly ushort wReserved;
- public readonly uint dwPageSize;
- public readonly IntPtr lpMinimumApplicationAddress;
- public readonly IntPtr lpMaximumApplicationAddress;
- public readonly IntPtr dwActiveProcessorMask;
- public readonly uint dwNumberOfProcessors;
- public readonly uint dwProcessorType;
- public readonly uint dwAllocationGranularity;
- public readonly ushort wProcessorLevel;
- public readonly ushort wProcessorRevision;
- }
-
-
- /// The RtlGetVersion routine returns version information about the currently running operating system.
- /// RtlGetVersion returns STATUS_SUCCESS.
- /// Available starting with Windows 2000.
- [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule"), DllImport("ntdll.dll", SetLastError = true, CharSet = CharSet.Unicode)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool RtlGetVersion([MarshalAs(UnmanagedType.Struct)] ref RTL_OSVERSIONINFOEXW lpVersionInformation);
-
-
- /// Retrieves information about the current system to an application running under WOW64.
- /// If the function is called from a 64-bit application, it is equivalent to the GetSystemInfo function.
- ///
- /// This function does not return a value.
- /// To determine whether a Win32-based application is running under WOW64, call the function.
- /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]
- /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- internal static extern void GetNativeSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
-
-
- /// Determines whether the specified process is running under WOW64.
- ///
- /// If the function succeeds, the return value is a nonzero value.
- /// If the function fails, the return value is zero. To get extended error information, call GetLastError.
- ///
- /// Minimum supported client: Windows Vista, Windows XP with SP2 [desktop apps only]
- /// Minimum supported server: Windows Server 2008, Windows Server 2003 with SP1 [desktop apps only]
- [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage"), SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
- [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool IsWow64Process([In] IntPtr hProcess, [Out, MarshalAs(UnmanagedType.Bool)] out bool lpSystemInfo);
- }
-
- #endregion // Private
}
}
diff --git a/AlphaFS/Resources.Designer.cs b/AlphaFS/Resources.Designer.cs
index 526c04dcc..5210b4e4a 100644
--- a/AlphaFS/Resources.Designer.cs
+++ b/AlphaFS/Resources.Designer.cs
@@ -60,6 +60,15 @@ internal Resources() {
}
}
+ ///
+ /// Looks up a localized string similar to Argument must be a drive letter from a-z, a volume GUID or device path..
+ ///
+ internal static string Argument_must_be_DriveLetter_or_VolumeGuid_or_DevicePath {
+ get {
+ return ResourceManager.GetString("Argument_must_be_DriveLetter_or_VolumeGuid_or_DevicePath", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Buffer is not large enough for the requested operation..
///
@@ -250,6 +259,24 @@ internal static string InvalidDriveLetterArgument {
}
}
+ ///
+ /// Looks up a localized string similar to Argument must be a drive letter: "C", "C:" or RootDir: "C:\".
+ ///
+ internal static string InvalidLogicalDriveArgument {
+ get {
+ return ResourceManager.GetString("InvalidLogicalDriveArgument", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Argument must be a drive letter: "C", "C:\" or Volume GUID..
+ ///
+ internal static string InvalidLogicalDriveVolumeArgument {
+ get {
+ return ResourceManager.GetString("InvalidLogicalDriveVolumeArgument", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to The target directory of the directory junction must be on the same local drive..
///
diff --git a/AlphaFS/Resources.resx b/AlphaFS/Resources.resx
index 2b2bdf3b3..3d6758dcc 100644
--- a/AlphaFS/Resources.resx
+++ b/AlphaFS/Resources.resx
@@ -1,4 +1,4 @@
-
+