diff --git a/Claunia.IO/ChangeLog b/Claunia.IO/ChangeLog index 603eaf0..ce78038 100644 --- a/Claunia.IO/ChangeLog +++ b/Claunia.IO/ChangeLog @@ -1,3 +1,9 @@ +2015-05-07 Natalia Portillo + + * Claunia.IO.csproj: + * Interop/Windows/Interop.Windows.Volumes.cs: + Added Kernel32's GetVolumeInformation. + 2015-05-04 Natalia Portillo * Claunia.IO.csproj: diff --git a/Claunia.IO/Claunia.IO.csproj b/Claunia.IO/Claunia.IO.csproj index 30e5959..64cddf7 100644 --- a/Claunia.IO/Claunia.IO.csproj +++ b/Claunia.IO/Claunia.IO.csproj @@ -74,6 +74,7 @@ + diff --git a/Claunia.IO/Interop/Windows/Interop.Windows.Volumes.cs b/Claunia.IO/Interop/Windows/Interop.Windows.Volumes.cs new file mode 100644 index 0000000..cadc8f7 --- /dev/null +++ b/Claunia.IO/Interop/Windows/Interop.Windows.Volumes.cs @@ -0,0 +1,160 @@ +// +// Interop.Windows.Volumes.cs +// +// Author: +// Natalia Portillo +// +// Copyright (c) 2015 © Claunia.com +// +// 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; +using System; +using System.Text; + +internal static partial class Interop +{ + internal static partial class Windows + { + [Flags] + public enum FileSystemFlags : uint + { + /// + /// The specified volume supports case-sensitive file names. + /// + FILE_CASE_SENSITIVE_SEARCH = 0x00000001, + /// + /// The specified volume supports preserved case of file names when it places a name on disk. + /// + FILE_CASE_PRESERVED_NAMES = 0x00000002, + /// + /// The specified volume supports Unicode in file names as they appear on disk. + /// + FILE_UNICODE_ON_DISK = 0x00000004, + /// + /// The specified volume preserves and enforces access control lists (ACL). + /// + FILE_PERSISTENT_ACLS = 0x00000008, + /// + /// The specified volume supports file-based compression. + /// + FILE_FILE_COMPRESSION = 0x00000010, + /// + /// The specified volume supports disk quotas. + /// + FILE_VOLUME_QUOTAS = 0x00000020, + /// + /// The specified volume supports sparse files. + /// + FILE_SUPPORTS_SPARSE_FILES = 0x00000040, + /// + /// The specified volume supports reparse points. + /// + FILE_SUPPORTS_REPARSE_POINTS = 0x00000080, + + /// + /// Undocumented + /// + FILE_SUPPORTS_REMOTE_STORAGE = 0x00000100, + /// + /// Undocumented + /// + FILE_SUPPORTS_LFN_APIS = 0x00000200, + + /// + /// The specified volume is a compressed volume, for example, a DoubleSpace volume. + /// + FILE_VOLUME_IS_COMPRESSED = 0x00008000, + /// + /// The specified volume supports object identifiers. + /// + FILE_SUPPORTS_OBJECT_IDS = 0x00010000, + /// + /// The specified volume supports the Encrypted File System (EFS). + /// + FILE_SUPPORTS_ENCRYPTION = 0x00020000, + /// + /// The specified volume supports named streams. + /// + FILE_NAMED_STREAMS = 0x00040000, + /// + /// The specified volume is read-only. + /// + FILE_READ_ONLY_VOLUME = 0x00080000, + /// + /// The specified volume supports a single sequential write. + /// + FILE_SEQUENTIAL_WRITE_ONCE = 0x00100000, + /// + /// The specified volume supports transactions. + /// + FILE_SUPPORTS_TRANSACTIONS = 0x00200000, + + /// + /// The specified volume supports hard links. + /// + FILE_SUPPORTS_HARD_LINKS = 0x00400000, + /// + /// The specified volume supports extended attributes. An extended attribute is a piece of application-specific metadata that an application can associate with a file and is not part of the file's data. + /// + FILE_SUPPORTS_EXTENDED_ATTRIBUTES = 0x00800000, + /// + /// The file system supports open by FileID. + /// + FILE_SUPPORTS_OPEN_BY_FILE_ID = 0x01000000, + /// + /// The specified volume supports update sequence number (USN) journals. + /// + FILE_SUPPORTS_USN_JOURNAL = 0x02000000, + + /// + /// Undocumented + /// + FILE_SUPPORTS_INTEGRITY_STREAMS = 0x04000000 + } + + const int MAX_PATH = 260; + + /// + /// Retrieves information about the file system and volume associated with the specified root directory. + /// + /// true, if all the requested information is retrieved, false otherwise. + /// A string that contains the root directory of the volume to be described. + /// If this parameter is null, the root of the current directory is used. A trailing backslash is required. + /// A pointer to a buffer that receives the name of a specified volume. + /// Length of , to a maxium of . + /// A variable that receives the volume serial number. + /// This parameter can be null if the serial number is not required. + /// A pointer to a variable that receives the maximum length, of a file name component that a specified file system supports. + /// A variable that receives flags associated with the specified file system. + /// A buffer that receives the name of the file system, for example, the FAT file system or the NTFS file system. + /// Length of , to a maxium of . + [DllImport(Libraries.Kernel32, CharSet = CharSet.Auto, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + extern static bool GetVolumeInformation( + string lpRootPathName, + StringBuilder lpVolumeNameBuffer, + int nVolumeNameSize, + out uint lpVolumeSerialNumber, + out uint lpMaximumComponentLength, + out FileSystemFlags lpFileSystemFlags, + StringBuilder lpFileSystemNameBuffer, + int nFileSystemNameSize); + } +} +