 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
eiji Guest
|
Posted: Mon Jan 30, 2006 9:00 pm Post subject: ifstream read() loop |
|
|
Hi folks,
I'm new to binary-file handling and try to work/learn playing around
with MD5.
Now everything works fine with small files, but when files get
bigger(e.g. 28MB) this loop stops in the second read()! I don't know
why!
typedef basic_ifstream<unsigned char> ifstream_uc;
void MD5::update (unsinged char *input, unsinged int input_length)
{...}
void MD5::update(ifstream_uc& stream){
unsigned char ubuffer[1024];
unsigned int len;
while (stream.good()){
cout << ( stream.rdstate( ) & ios::badbit ) << endl;
cout << ( stream.rdstate( ) & ios::failbit ) << endl;
cout << ( stream.rdstate( ) & ios::eofbit ) << endl << endl;
stream.read(ubuffer, 1024); // note that return value of read is
unusable.
cout << ( stream.rdstate( ) & ios::badbit ) << endl;
cout << ( stream.rdstate( ) & ios::failbit ) << endl;
cout << ( stream.rdstate( ) & ios::eofbit ) << endl << endl << endl;
len=static_cast<unsigned int>(stream.gcount());
update(ubuffer, len);
}
}
0
0
0
0
0
0
0
0
0
2
1
Regards,
eiji |
|
| Back to top |
|
 |
eiji Guest
|
Posted: Mon Jan 30, 2006 11:00 pm Post subject: Re: ifstream read() loop |
|
|
I "solved" the problem, just changing:
ifstream_uc file(filename);
to:
ifstream_uc file(filename, ios::binary);
This flag is not well documented. So what is the result of
opening in ios::binary-mode?
Stroustrup didn't say something about that.
I will move on "googleing".
Thanks,
Sascha |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|