|
|
|
@ -26,13 +26,20 @@ void FileManager::writeFile(const std::string &path, const std::string &content, |
|
|
|
|
FileManager * FileManager::instance = new FileManager; |
|
|
|
|
|
|
|
|
|
void FileReadCommand::execute() { |
|
|
|
|
|
|
|
|
|
std::ifstream in(path); |
|
|
|
|
if (in.is_open()){ |
|
|
|
|
std::string line, content; |
|
|
|
|
while (std::getline(in, line)) |
|
|
|
|
content += line; |
|
|
|
|
in.close(); |
|
|
|
|
readCallback(content); |
|
|
|
|
} else |
|
|
|
|
readCallback(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FileWriteCommand::execute() { |
|
|
|
|
std::ofstream out; |
|
|
|
|
auto mode = append ? std::ios_base::app : std::ios_base::out; |
|
|
|
|
out.open(path, mode); |
|
|
|
|
const auto mode = append ? std::ios_base::app : std::ios_base::out; |
|
|
|
|
std::ofstream out(path, mode); |
|
|
|
|
out << content; |
|
|
|
|
out.close(); |
|
|
|
|
} |
|
|
|
|