Macgoober
October 6th, 2009, 07:43 PM
Using the code below....is it possible that data could be lost? Please advise on how it could be lost, in what circumstances, and how to get around this problem...
std::ifstream in((dirCom.c_str()),
ios_base::in | ios_base::binary);
std::ofstream out(strFinal.c_str(),
ios_base::out | ios_base::binary);
char buf[BUF_SIZE];
do {
in.read(&buf[0], BUF_SIZE);
out.write(&buf[0], in.gcount( ));
} while (in.gcount( ) > 0);
in.close( );
out.close( );
so could the described above cause a loss of data in any circumstances? Because after running a function of the sort, all the files in a shared folder became unusable, they all had a file size of 0bytes...
Why would this occur?
could it have something to do with using SetAttributes()? Can setattributes even cause a loss of information? As far as I know setattributes only manipulates file flags.... not actual data...
Any help / advice in this matter is much appreciated!
Regards,
- Mac
std::ifstream in((dirCom.c_str()),
ios_base::in | ios_base::binary);
std::ofstream out(strFinal.c_str(),
ios_base::out | ios_base::binary);
char buf[BUF_SIZE];
do {
in.read(&buf[0], BUF_SIZE);
out.write(&buf[0], in.gcount( ));
} while (in.gcount( ) > 0);
in.close( );
out.close( );
so could the described above cause a loss of data in any circumstances? Because after running a function of the sort, all the files in a shared folder became unusable, they all had a file size of 0bytes...
Why would this occur?
could it have something to do with using SetAttributes()? Can setattributes even cause a loss of information? As far as I know setattributes only manipulates file flags.... not actual data...
Any help / advice in this matter is much appreciated!
Regards,
- Mac