From 2f4ad253a12e7bab938fc460876b1c65bd752b91 Mon Sep 17 00:00:00 2001
From: Nikola Petrov <nikolape7@gmail.com>
Date: Mon, 12 Aug 2024 21:43:12 +0200
Subject: [PATCH] Remove string from buffer

---
 inc/values/Buffer.hpp |  4 ----
 src/values/Buffer.cpp | 20 ++++----------------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/inc/values/Buffer.hpp b/inc/values/Buffer.hpp
index a0b7b06..67cc2c5 100644
--- a/inc/values/Buffer.hpp
+++ b/inc/values/Buffer.hpp
@@ -11,7 +11,6 @@ public:
 	uint8_t *buffer = nullptr;
 	size_t taken = 0;
 	size_t size = 0;
-	std::string file_path;
 
 	Buffer(size_t size);
 	Buffer();
@@ -31,10 +30,7 @@ public:
 
 	void clear() { taken = 0; }
 
-	bool save_to_file();
 	bool save_to_file(std::string file_path);
-
-	bool load_from_file();
 	bool load_from_file(std::string file_path);
 };
 
diff --git a/src/values/Buffer.cpp b/src/values/Buffer.cpp
index 3104862..1df5f79 100644
--- a/src/values/Buffer.cpp
+++ b/src/values/Buffer.cpp
@@ -103,9 +103,9 @@ void Buffer::remove(uint8_t *data, size_t data_size)
 	remove(index, data_size);
 }
 
-bool Buffer::save_to_file()
+bool Buffer::save_to_file(std::string file_path)
 {
-	std::ofstream file(this->file_path, std::ios::binary | std::ios::out);
+	std::ofstream file(file_path, std::ios::binary | std::ios::out);
 	if (!file.is_open())
 	{
 		printf("Error saving file\n");
@@ -116,15 +116,9 @@ bool Buffer::save_to_file()
 	return true;
 }
 
-bool Buffer::save_to_file(std::string file_path)
+bool Buffer::load_from_file(std::string file_path)
 {
-	this->file_path = file_path;
-	return save_to_file();
-}
-
-bool Buffer::load_from_file()
-{
-	std::ifstream file(this->file_path, std::ios::binary | std::ios::in);
+	std::ifstream file(file_path, std::ios::binary | std::ios::in);
 	if (!file.is_open())
 		return false;
 
@@ -144,9 +138,3 @@ bool Buffer::load_from_file()
 	file.close();
 	return true;
 }
-
-bool Buffer::load_from_file(std::string file_path)
-{
-	this->file_path = file_path;
-	return load_from_file();
-}