1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsIStorageStream.h"
7 #include "nsIInputStream.h"
8 #include "nsIOutputStream.h"
14 memset(kData
, 0, sizeof(kData
));
17 nsCOMPtr
<nsIStorageStream
> stor
;
19 rv
= NS_NewStorageStream(4096, UINT32_MAX
, getter_AddRefs(stor
));
23 nsCOMPtr
<nsIOutputStream
> out
;
24 rv
= stor
->GetOutputStream(0, getter_AddRefs(out
));
30 rv
= out
->Write(kData
, sizeof(kData
), &n
);
34 rv
= out
->Write(kData
, sizeof(kData
), &n
);
44 nsCOMPtr
<nsIInputStream
> in
;
45 rv
= stor
->NewInputStream(0, getter_AddRefs(in
));
51 // consume contents of input stream
53 rv
= in
->Read(buf
, sizeof(buf
), &n
);
63 // now, write 3 more full 4k segments + 11 bytes, starting at 8192
64 // total written equals 20491 bytes
66 rv
= stor
->GetOutputStream(8192, getter_AddRefs(out
));
70 rv
= out
->Write(kData
, sizeof(kData
), &n
);
74 rv
= out
->Write(kData
, sizeof(kData
), &n
);
78 rv
= out
->Write(kData
, sizeof(kData
), &n
);
82 rv
= out
->Write(kData
, 11, &n
);
93 rv
= stor
->NewInputStream(0, getter_AddRefs(in
));
97 // consume contents of input stream
99 rv
= in
->Read(buf
, sizeof(buf
), &n
);