aboutsummaryrefslogtreecommitdiff
path: root/LocalFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LocalFile.cpp')
-rw-r--r--LocalFile.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/LocalFile.cpp b/LocalFile.cpp
index d5bad67..1f9d574 100644
--- a/LocalFile.cpp
+++ b/LocalFile.cpp
@@ -1,12 +1,12 @@
#include <cstdio>
#include <iterator>
-#include "LocalFile.h"
+#include "LocalFileReader.h"
#include "Exception.h"
-LocalFile LocalFile::instance(protocol);
+LocalFileReader LocalFileReader::instance(protocol);
-void LocalFile::open(const std::string url) {
+void LocalFileReader::open(const std::string url) {
std::string path = url;
if (path.starts_with(protocol))
path = path.substr(protocol.size());
@@ -16,22 +16,22 @@ void LocalFile::open(const std::string url) {
throw Exception("cannot open file://%s\n", path.c_str());
}
-void LocalFile::close() {
+void LocalFileReader::close() {
if (this->file == nullptr) return;
if (this->file->is_open())
this->file->close();
}
-const std::string LocalFile::read() {
+const std::string LocalFileReader::read() {
if (this->content != nullptr)
return *this->content;
if (this->file == nullptr)
- throw Exception("FileStrategy read after destructor\n");
+ throw Exception("FileReader read after destructor\n");
if (!this->file->is_open())
- throw Exception("FileStrategy read after close\n");
+ throw Exception("FileReader read after close\n");
this->content = new std::string(
std::istreambuf_iterator<char>(*this->file),
@@ -41,7 +41,7 @@ const std::string LocalFile::read() {
return *this->content;
}
-LocalFile::~LocalFile() {
+LocalFileReader::~LocalFileReader() {
this->close();
if (this->file != nullptr) {
@@ -55,9 +55,9 @@ LocalFile::~LocalFile() {
}
}
-LocalFile * LocalFile::clone() const {
- return new LocalFile(this);
+LocalFileReader * LocalFileReader::clone() const {
+ return new LocalFileReader(this);
}
-LocalFile::LocalFile(const LocalFile *) : FileStrategy() { }
+LocalFileReader::LocalFileReader(const LocalFileReader *) : FileReader() { }