24 lines
467 B
C++
24 lines
467 B
C++
|
|
#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;
|
||
|
|
}
|