alignment #1

Merged
Persson-dev merged 19 commits from alignment into main 2025-02-23 09:40:46 +00:00
2 changed files with 13 additions and 25 deletions
Showing only changes of commit baa52d3baa - Show all commits

View File

@@ -261,13 +261,13 @@ class DataBuffer {
* \brief Read a file into the buffer
* \param fileName The name of the file to read
*/
bool ReadFile(const std::string& fileName);
void ReadFile(const std::string& fileName);
/**
* \brief Write a file into the buffer
* \param fileName The name of the file to write to
*/
bool WriteFile(const std::string& fileName) const;
void WriteFile(const std::string& fileName) const;
/**
* \brief Allocate the buffer on the heap

View File

@@ -130,31 +130,19 @@ std::ostream& operator<<(std::ostream& os, const DataBuffer& buffer) {
return os;
}
bool DataBuffer::ReadFile(const std::string& fileName) {
try {
void DataBuffer::ReadFile(const std::string& fileName) {
std::ifstream file(fileName, std::istream::binary);
std::ostringstream ss;
ss << file.rdbuf();
const std::string& s = ss.str();
m_Buffer = DataBuffer::Data(s.begin(), s.end());
m_ReadOffset = 0;
} catch (std::exception& e) {
// utils::LOGE(utils::Format("[IO] Failed to read file %s ! reason : %s", fileName.c_str(), e.what()));
return false;
}
return m_Buffer.size() > 0;
}
bool DataBuffer::WriteFile(const std::string& fileName) const {
try {
void DataBuffer::WriteFile(const std::string& fileName) const {
std::ofstream file(fileName, std::ostream::binary);
file.write(reinterpret_cast<const char*>(m_Buffer.data()), static_cast<std::streamsize>(m_Buffer.size()));
file.flush();
} catch (std::exception& e) {
// utils::LOGE(utils::Format("[IO] Failed to read file %s ! reason : %s", fileName.c_str(), e.what()));
return false;
}
return true;
}
} // namespace sp