Skip to content

Commit

Permalink
Use ifstream and ofstream instead of fstream
Browse files Browse the repository at this point in the history
  • Loading branch information
josepho0918 committed Jul 27, 2024
1 parent a3ba267 commit e5e3696
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions TrimTail/TrimTail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool HasTrailingBlanks(const fs::path& file_path)
return false;
}

static optional<string> GetCleanLine(fstream& file)
static optional<string> GetCleanLine(ifstream& file)
{
if (string line; getline(file, line)) {
line.erase(ranges::find_if_not(line | views::reverse, IsWhiteSpace).base(), line.cend());
Expand All @@ -60,9 +60,9 @@ void RemoveTrailingBlanks(const fs::path& file_path)

auto temp_path = fs::temp_directory_path() / boost::filesystem::unique_path().string();

if (auto [orig_file, temp_file] = make_pair<fstream, fstream>(
fstream(file_path, ios::in),
fstream(temp_path, ios::out | ios::trunc)
if (auto [orig_file, temp_file] = make_pair<ifstream, ofstream>(
ifstream(file_path),
ofstream(temp_path)
);
orig_file.is_open() && temp_file.is_open())
{
Expand Down

0 comments on commit e5e3696

Please sign in to comment.