mirror of https://github.com/dahall/Vanara.git
Updated and ran tests for CldApi after changes for #241
parent
30a5fa2d72
commit
df344844bf
|
@ -872,6 +872,22 @@ namespace Vanara.PInvoke
|
|||
[PInvokeData("cfapi.h", MSDNShortId = "1CB7955D-E530-4F34-8D67-BC608F8B6AF1")]
|
||||
public static extern HRESULT CfSetInSyncState(HFILE FileHandle, CF_IN_SYNC_STATE InSyncState, CF_SET_IN_SYNC_FLAGS InSyncFlags, ref USN InSyncUsn);
|
||||
|
||||
/// <summary>Sets the in-sync state for a placeholder file or folder.</summary>
|
||||
/// <param name="FileHandle">A handle to the placeholder. The caller must have WRITE_DATA or WRITE_DAC access to the placeholder.</param>
|
||||
/// <param name="InSyncState">The in-sync state. See CF_IN_SYNC_STATE for more details.</param>
|
||||
/// <param name="InSyncFlags">The in-sync state flags. See CF_SET_IN_SYNC_FLAGS for more details.</param>
|
||||
/// <param name="InSyncUsn">
|
||||
/// When specified, this instructs the platform to only perform in-sync setting if the file still has the same USN value as the one
|
||||
/// passed in. Passing a pointer to a USN value of 0 on input is the same as passing a NULL pointer. On return, this is the final
|
||||
/// USN value after setting the in-sync state.
|
||||
/// </param>
|
||||
/// <returns>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns>
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/cfapi/nf-cfapi-cfsetinsyncstate HRESULT CfSetInSyncState( HANDLE FileHandle,
|
||||
// CF_IN_SYNC_STATE InSyncState, CF_SET_IN_SYNC_FLAGS InSyncFlags, USN *InSyncUsn );
|
||||
[DllImport(Lib.CldApi, SetLastError = false, ExactSpelling = true)]
|
||||
[PInvokeData("cfapi.h", MSDNShortId = "1CB7955D-E530-4F34-8D67-BC608F8B6AF1")]
|
||||
public static extern HRESULT CfSetInSyncState(HFILE FileHandle, CF_IN_SYNC_STATE InSyncState, CF_SET_IN_SYNC_FLAGS InSyncFlags, [In, Optional] IntPtr InSyncUsn);
|
||||
|
||||
/// <summary>
|
||||
/// This sets the pin state of a placeholder, used to represent a user’s intent. Any application (not just the sync provider) can
|
||||
/// call this function.
|
||||
|
|
|
@ -209,8 +209,7 @@ namespace Vanara.PInvoke.Tests
|
|||
Assert.That(File.Exists(destFile), Is.True);
|
||||
|
||||
using var hFile = GetHFILE(destFile);
|
||||
var usn = 0;
|
||||
Assert.That(CfSetInSyncState(hFile, CF_IN_SYNC_STATE.CF_IN_SYNC_STATE_IN_SYNC, CF_SET_IN_SYNC_FLAGS.CF_SET_IN_SYNC_FLAG_NONE, ref usn), ResultIs.Successful);
|
||||
Assert.That(CfSetInSyncState(hFile, CF_IN_SYNC_STATE.CF_IN_SYNC_STATE_IN_SYNC, CF_SET_IN_SYNC_FLAGS.CF_SET_IN_SYNC_FLAG_NONE), ResultIs.Successful);
|
||||
Assert.That(CfSetPinState(hFile, CF_PIN_STATE.CF_PIN_STATE_PINNED, CF_SET_PIN_FLAGS.CF_SET_PIN_FLAG_NONE), ResultIs.Successful);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -14,6 +14,7 @@ using Windows.Storage.Provider;
|
|||
using static Vanara.PInvoke.CldApi;
|
||||
using static Vanara.PInvoke.Kernel32;
|
||||
using static Vanara.PInvoke.SearchApi;
|
||||
using USN = System.Int64;
|
||||
|
||||
namespace Vanara.PInvoke.Tests
|
||||
{
|
||||
|
@ -172,7 +173,7 @@ namespace Vanara.PInvoke.Tests
|
|||
public DateTime ChangeTime;
|
||||
|
||||
/// <summary>The final USN value after create actions are performed.</summary>
|
||||
public int CreateUsn;
|
||||
public USN CreateUsn;
|
||||
|
||||
/// <summary>
|
||||
/// The time the file was created in FILETIME format, which is a 64-bit value representing the number of 100-nanosecond intervals
|
||||
|
@ -345,7 +346,7 @@ namespace Vanara.PInvoke.Tests
|
|||
/// </item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public int ConvertToPlaceholder(string relativeFilePath, bool inSync = true, bool dehydrate = false, IntPtr fileIdentity = default, uint fileIdentityLength = 0)
|
||||
public USN ConvertToPlaceholder(string relativeFilePath, bool inSync = true, bool dehydrate = false, IntPtr fileIdentity = default, uint fileIdentityLength = 0)
|
||||
{
|
||||
CfOpenFileWithOplock(relativeFilePath, CF_OPEN_FILE_FLAGS.CF_OPEN_FILE_FLAG_EXCLUSIVE, out var hCfFile).ThrowIfFailed();
|
||||
using (hCfFile)
|
||||
|
@ -413,7 +414,7 @@ namespace Vanara.PInvoke.Tests
|
|||
/// </item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public int ConvertToPlaceholder(HFILE fileHandle, bool inSync = true, bool dehydrate = false, IntPtr fileIdentity = default, uint fileIdentityLength = 0)
|
||||
public USN ConvertToPlaceholder(HFILE fileHandle, bool inSync = true, bool dehydrate = false, IntPtr fileIdentity = default, uint fileIdentityLength = 0)
|
||||
{
|
||||
var flags = (inSync ? CF_CONVERT_FLAGS.CF_CONVERT_FLAG_MARK_IN_SYNC : 0) | (dehydrate ? CF_CONVERT_FLAGS.CF_CONVERT_FLAG_DEHYDRATE : 0);
|
||||
CfConvertToPlaceholder(fileHandle, fileIdentity, fileIdentityLength, flags, out var usn).ThrowIfFailed();
|
||||
|
@ -425,7 +426,7 @@ namespace Vanara.PInvoke.Tests
|
|||
/// <param name="fileInfo">The file information of the file.</param>
|
||||
/// <param name="inSync">if set to <see langword="true"/>, the file is synchronized.</param>
|
||||
/// <returns>The final USN value for the file.</returns>
|
||||
public int CreatePlaceholderFromFile(string relativeFilePath, FileInfo fileInfo, bool inSync = true)
|
||||
public USN CreatePlaceholderFromFile(string relativeFilePath, FileInfo fileInfo, bool inSync = true)
|
||||
{
|
||||
using var pRelativeName = new SafeCoTaskMemString(relativeFilePath);
|
||||
var ph = new PlaceholderInfo[] { PlaceHolderFileInfo.CreateFromFile(fileInfo, inSync, relativeFilePath) };
|
||||
|
|
Loading…
Reference in New Issue