Skip to content

Commit

Permalink
replace fopen with ifstream
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Nov 21, 2024
1 parent bf95347 commit 22694d7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,14 +1795,12 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType
// if we used a temporary target, copy it to stdout
if (rc == 0 && bStdout) {
_setmode(fileno(stdout), O_BINARY);
if (auto f = std::fopen(target.c_str(), "rb")) {
char buffer[8 * 1024];
size_t n = 1;
while (!feof(f) && n > 0) {
n = fread(buffer, 1, sizeof buffer, f);
fwrite(buffer, 1, n, stdout);
if (auto f = std::ifstream(target, std::ios::binary)) {
std::vector<char> buffer(8 * 1024);

while (f.read(buffer.data(), buffer.size()) || f.gcount() > 0) {
std::fwrite(buffer.data(), 1, f.gcount(), stdout);
}
fclose(f);
}
}

Expand Down

0 comments on commit 22694d7

Please sign in to comment.