33#include < string>
44#include < condition_variable>
55#include < mutex>
6- #include < FileCopierWithProgress.h>
76#include < fstream>
87#include < vector>
98#include < utility>
@@ -23,13 +22,43 @@ napi_threadsafe_function g_fetch_data_threadsafe_callback = nullptr;
2322
2423#define CHUNK_SIZE (32 * 1024 * 1024 )
2524
25+ #define FIELD_SIZE (type, field ) (sizeof (((type *)0 )->field))
26+
27+ #define CF_SIZE_OF_OP_PARAM (field ) \
28+ (FIELD_OFFSET (CF_OPERATION_PARAMETERS , field) + \
29+ FIELD_SIZE (CF_OPERATION_PARAMETERS , field))
30+
2631napi_value create_response(napi_env env, bool finished)
2732{
2833 napi_value result;
2934 napi_get_boolean (env, finished, &result);
3035 return result;
3136}
3237
38+ void transfer_data (
39+ _In_ CF_CONNECTION_KEY connectionKey,
40+ _In_ LARGE_INTEGER transferKey,
41+ _In_reads_bytes_opt_ (length.QuadPart) LPCVOID transferData,
42+ _In_ LARGE_INTEGER startingOffset,
43+ _In_ LARGE_INTEGER length,
44+ _In_ NTSTATUS completionStatus)
45+ {
46+ CF_OPERATION_INFO opInfo = {0 };
47+ opInfo.StructSize = sizeof (opInfo);
48+ opInfo.Type = CF_OPERATION_TYPE_TRANSFER_DATA ;
49+ opInfo.ConnectionKey = connectionKey;
50+ opInfo.TransferKey = transferKey;
51+
52+ CF_OPERATION_PARAMETERS opParams = {0 };
53+ opParams.ParamSize = CF_SIZE_OF_OP_PARAM (TransferData);
54+ opParams.TransferData .CompletionStatus = completionStatus;
55+ opParams.TransferData .Buffer = transferData;
56+ opParams.TransferData .Offset = startingOffset;
57+ opParams.TransferData .Length = length;
58+
59+ winrt::check_hresult (CfExecute (&opInfo, &opParams));
60+ }
61+
3362size_t file_incremental_reading (napi_env env, TransferContext &ctx, bool final_step)
3463{
3564 std::ifstream file (ctx.tmpPath , std::ios::in | std::ios::binary);
@@ -56,7 +85,7 @@ size_t file_incremental_reading(napi_env env, TransferContext &ctx, bool final_s
5685 startingOffset.QuadPart = ctx.lastReadOffset ;
5786 chunkBufferSize.QuadPart = min (datasizeAvailableUnread, CHUNK_SIZE );
5887
59- FileCopierWithProgress::TransferData (
88+ transfer_data (
6089 ctx.connectionKey ,
6190 ctx.transferKey ,
6291 buffer.data (),
@@ -74,7 +103,7 @@ size_t file_incremental_reading(napi_env env, TransferContext &ctx, bool final_s
74103 {
75104 Logger::getInstance ().log (" Excepción en file_incremental_reading." , LogLevel::ERROR );
76105 ctx.loadFinished = true ;
77- FileCopierWithProgress::TransferData (
106+ transfer_data (
78107 ctx.connectionKey ,
79108 ctx.transferKey ,
80109 nullptr ,
0 commit comments