[interfacekit] BBufferIO: some testing results

I have been doing some tests with BBufferIO, since it's an undocumented 
class.
For who doesn't know this class, I'll say it's a buffered adapter for 
BPositionIO derived classes.

I ran into a strange problem:

If I assign a BFile to a BBufferIO object, there is no problem (although I 
haven't yet completely understand its functionality). But if I assign a 
read only BFile to a BBufferIO object, I end up with a file full of garbage=
.

Here's the code:

#include <BufferIO.h>
#include <File.h>

#define DEBUG 1
#include <Debug.h>
#include <string.h>

int main()
{
=09BBufferIO *buffer;
=09BFile *file =3D NULL;
=09ssize_t err;
=09
=09const char b[10] =3D "ABCDEFGHI";
=09
=09file =3D new BFile("/boot/home/just_a_try", B_READ_ONLY|B_CREATE_FILE);

=09PRINT(("InitCheck(): %d\n", file->InitCheck()));
=09buffer =3D new BBufferIO(file);
=09
=09/* Write */
=09err =3D buffer->WriteAt(0, b, 10);
=09PRINT(("Written %d\n", err));=09// Here I don't get any error
=09=09=09
=09delete buffer;
=09delete file;
}
  

Ok, now look into the generated file and you'll see.. garbage.
Shouldn't the file be read only? Am I missing something?

Other related posts: