interfaces/inc/c_pal/file.h (38 lines of code) (raw):

// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifndef FILE_H #define FILE_H #ifdef __cplusplus #include <cstdint> #else #include <stdbool.h> #include <stdint.h> #endif #include "macro_utils/macro_utils.h" #include "c_pal/execution_engine.h" #include "umock_c/umock_c_prod.h" #ifdef __cplusplus extern "C" { #endif #define FILE_WRITE_ASYNC_VALUES \ FILE_WRITE_ASYNC_INVALID_ARGS, \ FILE_WRITE_ASYNC_WRITE_ERROR, \ FILE_WRITE_ASYNC_ERROR,\ FILE_WRITE_ASYNC_OK MU_DEFINE_ENUM(FILE_WRITE_ASYNC_RESULT, FILE_WRITE_ASYNC_VALUES); #define FILE_READ_ASYNC_VALUES \ FILE_READ_ASYNC_INVALID_ARGS, \ FILE_READ_ASYNC_READ_ERROR, \ FILE_READ_ASYNC_ERROR,\ FILE_READ_ASYNC_OK MU_DEFINE_ENUM(FILE_READ_ASYNC_RESULT, FILE_READ_ASYNC_VALUES); typedef struct FILE_HANDLE_DATA_TAG* FILE_HANDLE; typedef void(*FILE_REPORT_FAULT)(void* user_report_fault_context, const char* information); typedef void(*FILE_CB)(void* user_context, bool is_successful); MOCKABLE_FUNCTION(, FILE_HANDLE, file_create, EXECUTION_ENGINE_HANDLE, execution_engine, const char*, full_file_name, FILE_REPORT_FAULT, user_report_fault_callback, void*, user_report_fault_context); MOCKABLE_FUNCTION(, void, file_destroy, FILE_HANDLE, handle); MOCKABLE_FUNCTION_WITH_RETURNS(, FILE_WRITE_ASYNC_RESULT, file_write_async, FILE_HANDLE, handle, const unsigned char*, source, uint32_t, size, uint64_t, position, FILE_CB, user_callback, void*, user_context)(FILE_WRITE_ASYNC_OK, FILE_WRITE_ASYNC_ERROR); MOCKABLE_FUNCTION_WITH_RETURNS(, FILE_READ_ASYNC_RESULT, file_read_async, FILE_HANDLE, handle, unsigned char*, destination, uint32_t, size, uint64_t, position, FILE_CB, user_callback, void*, user_context)(FILE_READ_ASYNC_OK, FILE_READ_ASYNC_ERROR); MOCKABLE_FUNCTION_WITH_RETURNS(, int, file_extend, FILE_HANDLE, handle, uint64_t, desired_size)(0, MU_FAILURE); #ifdef __cplusplus } #endif #endif