Skip to content

Commit

Permalink
Fixed Read_File
Browse files Browse the repository at this point in the history
  • Loading branch information
rosidae committed Sep 13, 2021
1 parent ac3d051 commit 76f0917
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
5 changes: 1 addition & 4 deletions include/utl/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ namespace Files {
std::string Read_File(std::string File_Name) {
std::ifstream File(File_Name);
std::string Text;
if(!File.is_open()) {
return "";
}
File >> Text;
std::getline(File, Text);
File.close();
return Text;
}
Expand Down
4 changes: 1 addition & 3 deletions include/utl/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace Strings {
std::string Find_And_Replace_All(std::string Original, std::string Find, std::string Replace) {
std::string New = Original;
for(char i: New) {
New.replace(New.begin(), New.begin() + New.find(Find), Replace);
}
New.replace(New.begin(), New.begin() + New.find(Find), Replace);
return New;
}
}
2 changes: 1 addition & 1 deletion test/file.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Finding
Lorem ipsum dolor sit amet
2 changes: 1 addition & 1 deletion test/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <utl/files.h>

int main() {
Files::Find_And_Replace_File("./file.txt", "Finding", "Replacing");
std::cout << Files::Read_File("./file.txt");
return 0;
}

0 comments on commit 76f0917

Please sign in to comment.