mardi 24 juillet 2018

How to check if file copy and writing was successful

I am using C++ 11 to copy a file this way:

std::ifstream  src(srcPath, std::ios::binary);
std::ofstream  dst(destinationPath, std::ios::binary);
dst << src.rdbuf();

I am creating a new file this way:

std::ofstream out(path);
out << fileContent;
out.close();

In both cases, how do I check if the operation actually succeeded or if it failed?

Aucun commentaire:

Enregistrer un commentaire