From 9944ab2481cfaf16fc1fc07ff9680ae7a54ecb1a Mon Sep 17 00:00:00 2001 From: Yomodo Date: Thu, 22 Jun 2017 12:02:22 +0200 Subject: [PATCH] Added COPY_FILE_OPTIONS and MOVE_FILE_OPTIONS native enums. --- AlphaFS/AlphaFS.csproj | 32 +++---- .../Filesystem/Enumerations/CopyOptions.cs | 20 +++-- .../Filesystem/Enumerations/MoveOptions.cs | 20 +++-- .../BY_HANDLE_FILE_INFORMATION.cs | 0 .../COPY_FILE_OPTIONS.cs | 70 ++++++++++++++++ .../FILETIME.cs | 0 .../FILE_BASIC_INFO.cs | 0 .../FILE_ID_BOTH_DIR_INFO.cs | 0 .../MOVE_FILE_OPTIONS.cs | 84 +++++++++++++++++++ .../MountPointReparseBuffer.cs | 0 .../REPARSE_DATA_BUFFER.cs | 0 .../ReparseDataBufferHeader.cs | 0 .../SP_DEVICE_INTERFACE_DATA.cs | 0 .../SP_DEVICE_INTERFACE_DETAIL_DATA.cs | 0 .../SP_DEVINFO_DATA.cs | 0 .../SymbolicLinkReparseBuffer.cs | 0 .../WIN32_FILE_ATTRIBUTE_DATA.cs | 0 .../WIN32_FIND_DATA.cs | 0 .../WIN32_FIND_STREAM_DATA.cs | 0 .../WIN32_STREAM_ID.cs | 0 20 files changed, 197 insertions(+), 29 deletions(-) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/BY_HANDLE_FILE_INFORMATION.cs (100%) create mode 100644 AlphaFS/Filesystem/Native Structures And Enumerations/COPY_FILE_OPTIONS.cs rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/FILETIME.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/FILE_BASIC_INFO.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/FILE_ID_BOTH_DIR_INFO.cs (100%) create mode 100644 AlphaFS/Filesystem/Native Structures And Enumerations/MOVE_FILE_OPTIONS.cs rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/MountPointReparseBuffer.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/REPARSE_DATA_BUFFER.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/ReparseDataBufferHeader.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/SP_DEVICE_INTERFACE_DATA.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/SP_DEVICE_INTERFACE_DETAIL_DATA.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/SP_DEVINFO_DATA.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/SymbolicLinkReparseBuffer.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/WIN32_FILE_ATTRIBUTE_DATA.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/WIN32_FIND_DATA.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/WIN32_FIND_STREAM_DATA.cs (100%) rename AlphaFS/Filesystem/{Native Structures => Native Structures And Enumerations}/WIN32_STREAM_ID.cs (100%) diff --git a/AlphaFS/AlphaFS.csproj b/AlphaFS/AlphaFS.csproj index 09b13de39..5aa2ba1d3 100644 --- a/AlphaFS/AlphaFS.csproj +++ b/AlphaFS/AlphaFS.csproj @@ -392,8 +392,11 @@ - - + + + + + @@ -410,24 +413,23 @@ - - + - - + + - - - - - - - - - + + + + + + + + + diff --git a/AlphaFS/Filesystem/Enumerations/CopyOptions.cs b/AlphaFS/Filesystem/Enumerations/CopyOptions.cs index 1f98c1f1b..79cc495b2 100644 --- a/AlphaFS/Filesystem/Enumerations/CopyOptions.cs +++ b/AlphaFS/Filesystem/Enumerations/CopyOptions.cs @@ -31,10 +31,12 @@ public enum CopyOptions /// No CopyOptions used, this allows overwriting the file. None = 0, + /// COPY_FILE_FAIL_IF_EXISTS /// The copy operation fails immediately if the target file already exists. /// - FailIfExists = 1, + FailIfExists = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_FAIL_IF_EXISTS, + /// COPY_FILE_RESTARTABLE /// @@ -44,26 +46,30 @@ public enum CopyOptions /// /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Restartable")] - Restartable = 2, + Restartable = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_RESTARTABLE, + /// COPY_FILE_OPEN_SOURCE_FOR_WRITE /// The file is copied and the original file is opened for write access. /// - OpenSourceForWrite = 4, + OpenSourceForWrite = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_OPEN_SOURCE_FOR_WRITE, + /// COPY_FILE_ALLOW_DECRYPTED_DESTINATION /// An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted. /// - AllowDecryptedDestination = 8, + AllowDecryptedDestination = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_ALLOW_DECRYPTED_DESTINATION, + /// COPY_FILE_COPY_SYMLINK /// If the source file is a symbolic link, the destination file is also a symbolic link pointing to the same file that the source symbolic link is pointing to. /// - CopySymbolicLink = 2048, + CopySymbolicLink = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_COPY_SYMLINK, + /// COPY_FILE_NO_BUFFERING /// The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers. /// - NoBuffering = 4096 + NoBuffering = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_NO_BUFFERING } -} \ No newline at end of file +} diff --git a/AlphaFS/Filesystem/Enumerations/MoveOptions.cs b/AlphaFS/Filesystem/Enumerations/MoveOptions.cs index 51165cb1c..af5fad60b 100644 --- a/AlphaFS/Filesystem/Enumerations/MoveOptions.cs +++ b/AlphaFS/Filesystem/Enumerations/MoveOptions.cs @@ -31,18 +31,21 @@ public enum MoveOptions /// No MoveOptions used, this fails when the file name already exists. None = 0, + /// MOVE_FILE_REPLACE_EXISTSING /// If the destination file name already exists, the function replaces its contents with the contents of the source file. /// This value cannot be used if lpNewFileName or lpExistingFileName names a directory. /// This value cannot be used if either source or destination names a directory. /// - ReplaceExisting = 1, + ReplaceExisting = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_REPLACE_EXISTSING, + /// 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 . /// - CopyAllowed = 2, + CopyAllowed = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_COPY_ALLOWED, + /// MOVE_FILE_DELAY_UNTIL_REBOOT /// @@ -55,7 +58,8 @@ public enum MoveOptions /// /// This value cannot be used with . /// - DelayUntilReboot = 4, + DelayUntilReboot = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_DELAY_UNTIL_REBOOT, + /// MOVE_FILE_WRITE_THROUGH /// The function does not return until the file has actually been moved on the disk. @@ -65,19 +69,21 @@ public enum MoveOptions /// /// This value has no effect if is set. /// - WriteThrough = 8, + WriteThrough = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_WRITE_THROUGH, + /// MOVE_FILE_CREATE_HARDLINK /// Reserved for future use. /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - CreateHardlink = 16, + CreateHardlink = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_CREATE_HARDLINK, + /// MOVE_FILE_FAIL_IF_NOT_TRACKABLE /// The function fails if the source file is a link source, but the file cannot be tracked after the move. /// This situation can occur if the destination is a volume formatted with the FAT file system. /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Trackable")] - FailIfNotTrackable = 32 + FailIfNotTrackable = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_FAIL_IF_NOT_TRACKABLE } -} \ No newline at end of file +} diff --git a/AlphaFS/Filesystem/Native Structures/BY_HANDLE_FILE_INFORMATION.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/BY_HANDLE_FILE_INFORMATION.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/BY_HANDLE_FILE_INFORMATION.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/BY_HANDLE_FILE_INFORMATION.cs diff --git a/AlphaFS/Filesystem/Native Structures And Enumerations/COPY_FILE_OPTIONS.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/COPY_FILE_OPTIONS.cs new file mode 100644 index 000000000..0da1299b2 --- /dev/null +++ b/AlphaFS/Filesystem/Native Structures And Enumerations/COPY_FILE_OPTIONS.cs @@ -0,0 +1,70 @@ +/* Copyright (C) 2008-2017 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.Filesystem +{ + internal static partial class NativeMethods + { + public enum COPY_FILE_OPTIONS + { + /// COPY_FILE_FAIL_IF_EXISTS + /// The copy operation fails immediately if the target file already exists. + /// + COPY_FILE_FAIL_IF_EXISTS = 1, + + + /// COPY_FILE_RESTARTABLE + /// + /// Progress of the copy is tracked in the target file in case the copy fails. The failed copy can be restarted at a later time by specifying the same values + /// forexisting file name and new file name as those used in the call that failed. This can significantly slow down the copy operation as the new file may be + /// flushed multiple times during the copy operation. + /// + /// + COPY_FILE_RESTARTABLE = 2, + + + /// COPY_FILE_OPEN_SOURCE_FOR_WRITE + /// The file is copied and the original file is opened for write access. + /// + COPY_FILE_OPEN_SOURCE_FOR_WRITE = 4, + + + /// COPY_FILE_ALLOW_DECRYPTED_DESTINATION + /// An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted. + /// + COPY_FILE_ALLOW_DECRYPTED_DESTINATION = 8, + + + /// COPY_FILE_COPY_SYMLINK + /// If the source file is a symbolic link, the destination file is also a symbolic link pointing to the same file that the source symbolic link is pointing to. + /// + COPY_FILE_COPY_SYMLINK = 2048, + + + /// COPY_FILE_NO_BUFFERING + /// The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers. + /// + COPY_FILE_NO_BUFFERING = 4096 + } + } +} diff --git a/AlphaFS/Filesystem/Native Structures/FILETIME.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/FILETIME.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/FILETIME.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/FILETIME.cs diff --git a/AlphaFS/Filesystem/Native Structures/FILE_BASIC_INFO.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/FILE_BASIC_INFO.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/FILE_BASIC_INFO.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/FILE_BASIC_INFO.cs diff --git a/AlphaFS/Filesystem/Native Structures/FILE_ID_BOTH_DIR_INFO.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/FILE_ID_BOTH_DIR_INFO.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/FILE_ID_BOTH_DIR_INFO.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/FILE_ID_BOTH_DIR_INFO.cs diff --git a/AlphaFS/Filesystem/Native Structures And Enumerations/MOVE_FILE_OPTIONS.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/MOVE_FILE_OPTIONS.cs new file mode 100644 index 000000000..f1920eca6 --- /dev/null +++ b/AlphaFS/Filesystem/Native Structures And Enumerations/MOVE_FILE_OPTIONS.cs @@ -0,0 +1,84 @@ +/* Copyright (C) 2008-2017 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.Filesystem +{ + internal static partial class NativeMethods + { + public enum MOVE_FILE_OPTIONS + { + /// No MoveOptions used, this fails when the file name already exists. + None = 0, + + /// MOVE_FILE_REPLACE_EXISTSING + /// If the destination file name already exists, the function replaces its contents with the contents of the source file. + /// This value cannot be used if lpNewFileName or lpExistingFileName names a directory. + /// This value cannot be used if either source or destination names a directory. + /// + MOVE_FILE_REPLACE_EXISTSING = 1, + + /// 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 . + /// + MOVE_FILE_COPY_ALLOWED = 2, + + /// MOVE_FILE_DELAY_UNTIL_REBOOT + /// + /// The system does not move the file until the operating system is restarted. + /// The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. + /// + /// + /// 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 . + /// + MOVE_FILE_DELAY_UNTIL_REBOOT = 4, + + + /// MOVE_FILE_WRITE_THROUGH + /// The function does not return until the file has actually been moved on the disk. + /// + /// 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. + /// + MOVE_FILE_WRITE_THROUGH = 8, + + + /// MOVE_FILE_CREATE_HARDLINK + /// Reserved for future use. + /// + MOVE_FILE_CREATE_HARDLINK = 16, + + + /// MOVE_FILE_FAIL_IF_NOT_TRACKABLE + /// The function fails if the source file is a link source, but the file cannot be tracked after the move. + /// This situation can occur if the destination is a volume formatted with the FAT file system. + /// + MOVE_FILE_FAIL_IF_NOT_TRACKABLE = 32 + } + } +} diff --git a/AlphaFS/Filesystem/Native Structures/MountPointReparseBuffer.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/MountPointReparseBuffer.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/MountPointReparseBuffer.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/MountPointReparseBuffer.cs diff --git a/AlphaFS/Filesystem/Native Structures/REPARSE_DATA_BUFFER.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/REPARSE_DATA_BUFFER.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/REPARSE_DATA_BUFFER.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/REPARSE_DATA_BUFFER.cs diff --git a/AlphaFS/Filesystem/Native Structures/ReparseDataBufferHeader.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/ReparseDataBufferHeader.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/ReparseDataBufferHeader.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/ReparseDataBufferHeader.cs diff --git a/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DATA.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/SP_DEVICE_INTERFACE_DATA.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DATA.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/SP_DEVICE_INTERFACE_DATA.cs diff --git a/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DETAIL_DATA.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/SP_DEVICE_INTERFACE_DETAIL_DATA.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DETAIL_DATA.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/SP_DEVICE_INTERFACE_DETAIL_DATA.cs diff --git a/AlphaFS/Filesystem/Native Structures/SP_DEVINFO_DATA.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/SP_DEVINFO_DATA.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/SP_DEVINFO_DATA.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/SP_DEVINFO_DATA.cs diff --git a/AlphaFS/Filesystem/Native Structures/SymbolicLinkReparseBuffer.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/SymbolicLinkReparseBuffer.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/SymbolicLinkReparseBuffer.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/SymbolicLinkReparseBuffer.cs diff --git a/AlphaFS/Filesystem/Native Structures/WIN32_FILE_ATTRIBUTE_DATA.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_FILE_ATTRIBUTE_DATA.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/WIN32_FILE_ATTRIBUTE_DATA.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_FILE_ATTRIBUTE_DATA.cs diff --git a/AlphaFS/Filesystem/Native Structures/WIN32_FIND_DATA.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_FIND_DATA.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/WIN32_FIND_DATA.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_FIND_DATA.cs diff --git a/AlphaFS/Filesystem/Native Structures/WIN32_FIND_STREAM_DATA.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_FIND_STREAM_DATA.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/WIN32_FIND_STREAM_DATA.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_FIND_STREAM_DATA.cs diff --git a/AlphaFS/Filesystem/Native Structures/WIN32_STREAM_ID.cs b/AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_STREAM_ID.cs similarity index 100% rename from AlphaFS/Filesystem/Native Structures/WIN32_STREAM_ID.cs rename to AlphaFS/Filesystem/Native Structures And Enumerations/WIN32_STREAM_ID.cs