mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
refactor: Modernize writeDataToFile function
Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
dd3d294f87
commit
e82be94368
@@ -22,7 +22,6 @@
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
BuiltIns::BuiltIns() {
|
||||
@@ -49,7 +48,7 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
|
||||
|
||||
if (NEO::debugManager.flags.DumpSipHeaderFile.get() != "unk") {
|
||||
std::string name = NEO::debugManager.flags.DumpSipHeaderFile.get() + "_header.bin";
|
||||
writeDataToFile(name.c_str(), stateSaveAreaHeader.data(), stateSaveAreaHeader.size());
|
||||
writeDataToFile(name.c_str(), std::string_view(stateSaveAreaHeader.data(), stateSaveAreaHeader.size()));
|
||||
}
|
||||
|
||||
const auto allocType = AllocationType::kernelIsaInternal;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
size_t writeDataToFile(
|
||||
const char *filename,
|
||||
const void *pData,
|
||||
size_t dataSize) {
|
||||
std::string_view data) {
|
||||
FILE *fp = nullptr;
|
||||
size_t nsize = 0;
|
||||
|
||||
DEBUG_BREAK_IF(nullptr == pData);
|
||||
DEBUG_BREAK_IF(nullptr == filename);
|
||||
|
||||
fopen_s(&fp, filename, "wb");
|
||||
if (fp) {
|
||||
nsize = fwrite(pData, sizeof(unsigned char), dataSize, fp);
|
||||
nsize = fwrite(data.data(), sizeof(unsigned char), data.size(), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
std::unique_ptr<char[]> loadDataFromFile(
|
||||
const char *filename,
|
||||
@@ -21,8 +22,7 @@ std::unique_ptr<char[]> loadDataFromFile(
|
||||
|
||||
size_t writeDataToFile(
|
||||
const char *filename,
|
||||
const void *pData,
|
||||
size_t dataSize);
|
||||
std::string_view data);
|
||||
|
||||
bool fileExists(const std::string &fileName);
|
||||
bool fileExistsHasSize(const std::string &fileName);
|
||||
|
||||
@@ -58,5 +58,5 @@ void dumpFileIncrement(const char *data, size_t dataSize, const std::string &fil
|
||||
filenameWithExt = filename + "_" + std::to_string(suffix) + extension;
|
||||
suffix++;
|
||||
}
|
||||
writeDataToFile(filenameWithExt.c_str(), data, dataSize);
|
||||
writeDataToFile(filenameWithExt.c_str(), std::string_view(data, dataSize));
|
||||
}
|
||||
Reference in New Issue
Block a user