Home » U++ Library support » U++ Core » How to use FileStream?
How to use FileStream? [message #8202] |
Sun, 18 February 2007 16:42 |
Ulti
Messages: 108 Registered: September 2006
|
Experienced Member |
|
|
Any example to show how to use Stream class?
my following code result empty file
[I]char data[512];
for(int i=0;i<512;i++) data=0;
MemStream ms(data,512);
header.ToBuf(ms);
CDocFile.Put(data,512);
|
|
|
|
Re: How to use FileStream? [message #8207 is a reply to message #8206] |
Mon, 19 February 2007 04:15 |
Ulti
Messages: 108 Registered: September 2006
|
Experienced Member |
|
|
Sorry,it's my stupid,I just forget to save the buffer into filestream.
but I wonder if my idea is the best one,hope you can give some advice:
I have a buffer which hold 512byte character,and I want save it into file like this way
void CompoundFile::Header::ToBuf(MemStream &buf)
{
buf.Put64le(MagicId);
buf.Put64le(UID1);
buf.Put64le(UID2);
buf.Put16le(rev);
buf.Put16le(ver);
buf.Put16le(byteorder);
buf.Put16le(ssz);
buf.Put16le(sssz);
buf.Put16le(notused1);
buf.Put64le(notused2);
buf.Put32le(SATSecCnt);
buf.Put32le(DirStartSID);
buf.Put32le(notused3);
buf.Put32le(StdStreamSize);
buf.Put32le(SSATStartSID);
buf.Put32le(SSATSecCnt);
buf.Put32le(MSAT1StartSID);
buf.Put32le(MSAT1SecCnt);
buf.Put32le(MSAT1SecCnt);
for(int i=0;i<109;i++)
buf.Put32le(MSAT0[i]);
}
first I put this 512byte into MemStream,and then use the already exist method to write big/little endian,and then put this MemStream into FileStream.
is this is the best way,or any other good ideas(I don't want write any other endian function,they are already in Stream)?
thanks a lot!
[Updated on: Mon, 19 February 2007 04:16] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Apr 25 00:01:17 CEST 2024
Total time taken to generate the page: 0.02938 seconds
|