コード例 #1
0
ファイル: CopyFile.cpp プロジェクト: cosmicb0y/CopyFile
bool
file_copy_using_memory_map2(
	_In_ const wchar_t* src_file,
	_In_ const wchar_t* dst_file
	)
{
	_ASSERTE(NULL != src_file);
	_ASSERTE(NULL != dst_file);
	if (NULL == src_file || NULL == dst_file) return false;

	if (!is_file_existsW(src_file))
	{
		print("err ] no src file = %ws", src_file);
		return false;
	}

	if (is_file_existsW(dst_file))
	{
		DeleteFileW(dst_file);
	}

	// map src, dst file
	pmap_context src_ctx = open_map_context(src_file);
	pmap_context dst_ctx = create_map_context(dst_file, src_ctx->size);
	if (NULL == src_ctx || NULL == dst_ctx)
	{
		print("err ] open_map_context() failed.");
		close_map_context(src_ctx);
		close_map_context(dst_ctx);
		return false;
	}

	// copy src to dst by mmio
	uint32_t i = 0;
	uint32_t bs = 0;
	uint32_t rest = src_ctx->size;
	while (0 < rest)
	{
		if (rest > 4096)
		{
			bs = 4096;
			rest -= 4096;
		}
		else
		{
			bs = rest;
			rest = 0;
		}

		RtlCopyMemory(&dst_ctx->view[i], &src_ctx->view[i], bs);
		i += bs;
	}
	return true;
}
コード例 #2
0
ファイル: 150714 OS.cpp プロジェクト: cshwan96/BOB4_OS2
/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
**/
bool
file_copy_using_memory_map(
_In_ const wchar_t* src_file,
_In_ const wchar_t* dst_file
)
{
	_ASSERTE(NULL != src_file);
	_ASSERTE(NULL != dst_file);
	if (NULL == src_file || NULL == dst_file) return false;

	if (!is_file_existsW(src_file))
	{
		print("err ] no src file = %ws", src_file);
		return false;
	}

	if (is_file_existsW(dst_file))
	{
		DeleteFileW(dst_file);
	}

	// map src, dst file
	pmap_context src_ctx = open_map_context(src_file);
	pmap_context dst_ctx = create_map_context(dst_file, src_ctx->size);
	if (NULL == src_ctx || NULL == dst_ctx)
	{
		print("err ] open_map_context() failed.");
		close_map_context(src_ctx);
		close_map_context(dst_ctx);
		return false;
	}

	// copy src to dst by mmio
	for (uint32_t i = 0; i < src_ctx->size; ++i)
	{
		dst_ctx->view[i] = src_ctx->view[i];
	}

	close_map_context(src_ctx);
	close_map_context(dst_ctx);
	
	return true;
}