Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Added COPY_FILE_OPTIONS and MOVE_FILE_OPTIONS native enums.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomodo authored and Yomodo committed Jun 22, 2017
1 parent c009ff8 commit 9944ab2
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 29 deletions.
32 changes: 17 additions & 15 deletions AlphaFS/AlphaFS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,11 @@
<Compile Include="Filesystem\Native Methods\NativeMethods.BackupStreams.cs" />
<Compile Include="Filesystem\Native Methods\NativeMethods.Utilities.cs" />
<Compile Include="Filesystem\Native Methods\NativeMethods.PathManagement.cs" />
<Compile Include="Filesystem\Native Structures\REPARSE_DATA_BUFFER.cs" />
<Compile Include="Filesystem\Native Structures\WIN32_FIND_STREAM_DATA.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\MOVE_FILE_OPTIONS.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\COPY_FILE_OPTIONS.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\FILE_BASIC_INFO.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\REPARSE_DATA_BUFFER.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\WIN32_FIND_STREAM_DATA.cs" />
<Compile Include="Filesystem\Path Class\Path.cs" />
<Compile Include="Filesystem\Path Class\Path.ValidationAndChecks.cs" />
<Compile Include="Filesystem\Path Class\Path.GetComponents.cs" />
Expand All @@ -410,24 +413,23 @@
<Compile Include="Filesystem\Safe Handles\SafeSetupDiClassDevsExHandle.cs" />
<Compile Include="Filesystem\Shell32Info.cs" />
<Compile Include="Filesystem\CopyMoveResult.cs" />
<Compile Include="Filesystem\Native Structures\FILE_BASIC_INFO.cs" />
<Compile Include="Filesystem\Native Structures\BY_HANDLE_FILE_INFORMATION.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\BY_HANDLE_FILE_INFORMATION.cs" />
<Compile Include="Filesystem\ChangeErrorMode.cs" />
<Compile Include="Filesystem\Native Structures\FILE_ID_BOTH_DIR_INFO.cs" />
<Compile Include="Filesystem\Native Structures\FILETIME.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\FILE_ID_BOTH_DIR_INFO.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\FILETIME.cs" />
<Compile Include="Filesystem\LinkTargetInfo.cs" />
<Compile Include="Filesystem\Enumerations\MoveOptions.cs" />
<Compile Include="Filesystem\Exceptions\NotAReparsePointException.cs" />
<Compile Include="Filesystem\Shell32.cs" />
<Compile Include="Filesystem\Native Structures\MountPointReparseBuffer.cs" />
<Compile Include="Filesystem\Native Structures\ReparseDataBufferHeader.cs" />
<Compile Include="Filesystem\Native Structures\SP_DEVINFO_DATA.cs" />
<Compile Include="Filesystem\Native Structures\SP_DEVICE_INTERFACE_DATA.cs" />
<Compile Include="Filesystem\Native Structures\SP_DEVICE_INTERFACE_DETAIL_DATA.cs" />
<Compile Include="Filesystem\Native Structures\SymbolicLinkReparseBuffer.cs" />
<Compile Include="Filesystem\Native Structures\WIN32_FILE_ATTRIBUTE_DATA.cs" />
<Compile Include="Filesystem\Native Structures\WIN32_FIND_DATA.cs" />
<Compile Include="Filesystem\Native Structures\WIN32_STREAM_ID.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\MountPointReparseBuffer.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\ReparseDataBufferHeader.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\SP_DEVINFO_DATA.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\SP_DEVICE_INTERFACE_DATA.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\SP_DEVICE_INTERFACE_DETAIL_DATA.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\SymbolicLinkReparseBuffer.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\WIN32_FILE_ATTRIBUTE_DATA.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\WIN32_FIND_DATA.cs" />
<Compile Include="Filesystem\Native Structures And Enumerations\WIN32_STREAM_ID.cs" />
<Compile Include="Network\DfsInfo.cs" />
<Compile Include="Network\DfsStorageInfo.cs" />
<Compile Include="Network\Enumerations\DfsPropertyFlags.cs" />
Expand Down
20 changes: 13 additions & 7 deletions AlphaFS/Filesystem/Enumerations/CopyOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public enum CopyOptions
/// <summary>No CopyOptions used, this allows overwriting the file.</summary>
None = 0,


/// <summary>COPY_FILE_FAIL_IF_EXISTS
/// <para>The copy operation fails immediately if the target file already exists.</para>
/// </summary>
FailIfExists = 1,
FailIfExists = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_FAIL_IF_EXISTS,


/// <summary>COPY_FILE_RESTARTABLE
/// <para>
Expand All @@ -44,26 +46,30 @@ public enum CopyOptions
/// </para>
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Restartable")]
Restartable = 2,
Restartable = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_RESTARTABLE,


/// <summary>COPY_FILE_OPEN_SOURCE_FOR_WRITE
/// <para>The file is copied and the original file is opened for write access.</para>
/// </summary>
OpenSourceForWrite = 4,
OpenSourceForWrite = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_OPEN_SOURCE_FOR_WRITE,


/// <summary>COPY_FILE_ALLOW_DECRYPTED_DESTINATION
/// <para>An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted.</para>
/// </summary>
AllowDecryptedDestination = 8,
AllowDecryptedDestination = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_ALLOW_DECRYPTED_DESTINATION,


/// <summary>COPY_FILE_COPY_SYMLINK
/// <para>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.</para>
/// </summary>
CopySymbolicLink = 2048,
CopySymbolicLink = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_COPY_SYMLINK,


/// <summary>COPY_FILE_NO_BUFFERING
/// <para>The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers.</para>
/// </summary>
NoBuffering = 4096
NoBuffering = NativeMethods.COPY_FILE_OPTIONS.COPY_FILE_NO_BUFFERING
}
}
}
20 changes: 13 additions & 7 deletions AlphaFS/Filesystem/Enumerations/MoveOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ public enum MoveOptions
/// <summary>No MoveOptions used, this fails when the file name already exists.</summary>
None = 0,


/// <summary>MOVE_FILE_REPLACE_EXISTSING
/// <para>If the destination file name already exists, the function replaces its contents with the contents of the source file.</para>
/// <para>This value cannot be used if lpNewFileName or lpExistingFileName names a directory.</para>
/// <para>This value cannot be used if either source or destination names a directory.</para>
/// </summary>
ReplaceExisting = 1,
ReplaceExisting = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_REPLACE_EXISTSING,


/// <summary>MOVE_FILE_COPY_ALLOWED
/// <para>If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.</para>
/// <para>This value cannot be used with <see cref="MoveOptions.DelayUntilReboot"/>.</para>
/// </summary>
CopyAllowed = 2,
CopyAllowed = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_COPY_ALLOWED,


/// <summary>MOVE_FILE_DELAY_UNTIL_REBOOT
/// <para>
Expand All @@ -55,7 +58,8 @@ public enum MoveOptions
/// </para>
/// <para>This value cannot be used with <see cref="MoveOptions.CopyAllowed"/>.</para>
/// </summary>
DelayUntilReboot = 4,
DelayUntilReboot = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_DELAY_UNTIL_REBOOT,


/// <summary>MOVE_FILE_WRITE_THROUGH
/// <para>The function does not return until the file has actually been moved on the disk.</para>
Expand All @@ -65,19 +69,21 @@ public enum MoveOptions
/// </para>
/// <para>This value has no effect if <see cref="MoveOptions.DelayUntilReboot"/> is set.</para>
/// </summary>
WriteThrough = 8,
WriteThrough = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_WRITE_THROUGH,


/// <summary>MOVE_FILE_CREATE_HARDLINK
/// <para>Reserved for future use.</para>
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")]
CreateHardlink = 16,
CreateHardlink = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_CREATE_HARDLINK,


/// <summary>MOVE_FILE_FAIL_IF_NOT_TRACKABLE
/// <para>The function fails if the source file is a link source, but the file cannot be tracked after the move.</para>
/// <para>This situation can occur if the destination is a volume formatted with the FAT file system.</para>
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Trackable")]
FailIfNotTrackable = 32
FailIfNotTrackable = NativeMethods.MOVE_FILE_OPTIONS.MOVE_FILE_FAIL_IF_NOT_TRACKABLE
}
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>COPY_FILE_FAIL_IF_EXISTS
/// <para>The copy operation fails immediately if the target file already exists.</para>
/// </summary>
COPY_FILE_FAIL_IF_EXISTS = 1,


/// <summary>COPY_FILE_RESTARTABLE
/// <para>
/// 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.
/// </para>
/// </summary>
COPY_FILE_RESTARTABLE = 2,


/// <summary>COPY_FILE_OPEN_SOURCE_FOR_WRITE
/// <para>The file is copied and the original file is opened for write access.</para>
/// </summary>
COPY_FILE_OPEN_SOURCE_FOR_WRITE = 4,


/// <summary>COPY_FILE_ALLOW_DECRYPTED_DESTINATION
/// <para>An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted.</para>
/// </summary>
COPY_FILE_ALLOW_DECRYPTED_DESTINATION = 8,


/// <summary>COPY_FILE_COPY_SYMLINK
/// <para>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.</para>
/// </summary>
COPY_FILE_COPY_SYMLINK = 2048,


/// <summary>COPY_FILE_NO_BUFFERING
/// <para>The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers.</para>
/// </summary>
COPY_FILE_NO_BUFFERING = 4096
}
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>No MoveOptions used, this fails when the file name already exists.</summary>
None = 0,

/// <summary>MOVE_FILE_REPLACE_EXISTSING
/// <para>If the destination file name already exists, the function replaces its contents with the contents of the source file.</para>
/// <para>This value cannot be used if lpNewFileName or lpExistingFileName names a directory.</para>
/// <para>This value cannot be used if either source or destination names a directory.</para>
/// </summary>
MOVE_FILE_REPLACE_EXISTSING = 1,

/// <summary>MOVE_FILE_COPY_ALLOWED
/// <para>If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.</para>
/// <para>This value cannot be used with <see cref="MOVE_FILE_OPTIONS.MOVE_FILE_DELAY_UNTIL_REBOOT"/>.</para>
/// </summary>
MOVE_FILE_COPY_ALLOWED = 2,

/// <summary>MOVE_FILE_DELAY_UNTIL_REBOOT
/// <para>
/// 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.
/// </para>
/// <para>
/// 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.
/// </para>
/// <para>This value cannot be used with <see cref="MOVE_FILE_OPTIONS.MOVE_FILE_COPY_ALLOWED"/>.</para>
/// </summary>
MOVE_FILE_DELAY_UNTIL_REBOOT = 4,


/// <summary>MOVE_FILE_WRITE_THROUGH
/// <para>The function does not return until the file has actually been moved on the disk.</para>
/// <para>
/// 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.
/// </para>
/// <para>This value has no effect if <see cref="MOVE_FILE_OPTIONS.MOVE_FILE_DELAY_UNTIL_REBOOT"/> is set.</para>
/// </summary>
MOVE_FILE_WRITE_THROUGH = 8,


/// <summary>MOVE_FILE_CREATE_HARDLINK
/// <para>Reserved for future use.</para>
/// </summary>
MOVE_FILE_CREATE_HARDLINK = 16,


/// <summary>MOVE_FILE_FAIL_IF_NOT_TRACKABLE
/// <para>The function fails if the source file is a link source, but the file cannot be tracked after the move.</para>
/// <para>This situation can occur if the destination is a volume formatted with the FAT file system.</para>
/// </summary>
MOVE_FILE_FAIL_IF_NOT_TRACKABLE = 32
}
}
}

0 comments on commit 9944ab2

Please sign in to comment.