2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2025-04-09 23:18:28 +08:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2019-02-27 18:39:32 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2025-04-09 23:18:28 +08:00
|
|
|
#include "shared/source/helpers/stdio.h"
|
|
|
|
#include "shared/source/utilities/io_functions.h"
|
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cstdint>
|
2019-08-29 21:10:51 +08:00
|
|
|
#include <memory>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <string>
|
2025-04-11 19:24:23 +08:00
|
|
|
#include <string_view>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-08-29 21:10:51 +08:00
|
|
|
std::unique_ptr<char[]> loadDataFromFile(
|
2017-12-21 07:45:38 +08:00
|
|
|
const char *filename,
|
2019-08-29 21:10:51 +08:00
|
|
|
size_t &retSize);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
size_t writeDataToFile(
|
|
|
|
const char *filename,
|
2025-04-11 19:24:23 +08:00
|
|
|
std::string_view data);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
bool fileExists(const std::string &fileName);
|
|
|
|
bool fileExistsHasSize(const std::string &fileName);
|
2023-04-17 19:44:37 +08:00
|
|
|
void dumpFileIncrement(const char *data, size_t dataSize, const std::string &filename, const std::string &extension);
|
2025-04-09 23:18:28 +08:00
|
|
|
|
|
|
|
#define USE_REAL_FILE_SYSTEM() \
|
|
|
|
VariableBackup<decltype(NEO::IoFunctions::fopenPtr)> mockFopen(&NEO::IoFunctions::fopenPtr, [](const char *filename, const char *mode) -> FILE * { \
|
|
|
|
FILE *pFile = nullptr; \
|
|
|
|
fopen_s(&pFile, filename, mode); \
|
|
|
|
return pFile; \
|
|
|
|
}); \
|
|
|
|
VariableBackup<decltype(NEO::IoFunctions::fseekPtr)> mockFseek(&NEO::IoFunctions::fseekPtr, [](FILE *stream, long int offset, int origin) -> int { return fseek(stream, offset, origin); }); \
|
|
|
|
VariableBackup<decltype(NEO::IoFunctions::ftellPtr)> mockFtell(&NEO::IoFunctions::ftellPtr, [](FILE *stream) -> long int { return ftell(stream); }); \
|
|
|
|
VariableBackup<decltype(NEO::IoFunctions::freadPtr)> mockFread(&NEO::IoFunctions::freadPtr, [](void *ptr, size_t size, size_t count, FILE *stream) -> size_t { return fread(ptr, size, count, stream); }); \
|
|
|
|
VariableBackup<decltype(NEO::IoFunctions::fclosePtr)> mockFclose(&NEO::IoFunctions::fclosePtr, [](FILE *stream) -> int { return fclose(stream); });
|