Skip to content

Commit bb8faf7

Browse files
committed
Fixed warning by deepcode
1 parent f36ee5d commit bb8faf7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/wsjcpp_core.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,18 @@ bool WsjcppCore::copyFile(const std::string &sSourceFilename, const std::string
421421
return false;
422422
}
423423

424-
std::ifstream src(sSourceFilename, std::ios::binary);
425-
std::ofstream dst(sTargetFilename, std::ios::binary);
424+
std::ifstream src(sSourceFilename, std::ios::binary);
425+
if (!src.is_open()) {
426+
WsjcppLog::err("copyFile", "Could not open file '" + sSourceFilename + "' for read");
427+
return false;
428+
}
429+
430+
std::ofstream dst(sTargetFilename, std::ios::binary);
431+
if (!dst.is_open()) {
432+
WsjcppLog::err("copyFile", "Could not open file '" + sTargetFilename + "' for write");
433+
return false;
434+
}
435+
426436
dst << src.rdbuf();
427437
return true;
428438
}

0 commit comments

Comments
 (0)