Files
cinema-ticket-management-sy…/tests_schema/tests_sources/file_reader.cpp
T

24 lines
467 B
C++
Raw Normal View History

2026-07-12 14:34:52 +04:00
#include "file_reader.h"
#include <fstream>
#include <iostream>
#include <sstream>
// Read a SQL file
bool FileReader::read(const std::string &sqlFilePath, std::string &sql) {
// Try read the SQL file
std::ifstream file(sqlFilePath);
if (!file.is_open()) {
std::cerr << "Error opening file:" << sqlFilePath << std::endl;
return false;
}
std::stringstream buffer;
buffer << file.rdbuf();
sql = buffer.str();
file.close();
return true;
}