2016-10-06 20:06:51 +00:00
|
|
|
/++ dub.sdl:
|
|
|
|
name "test"
|
|
|
|
dependency "vibe-core" path=".."
|
|
|
|
+/
|
|
|
|
module test;
|
|
|
|
|
|
|
|
import vibe.core.file;
|
|
|
|
|
2016-12-19 20:57:52 +00:00
|
|
|
enum ubyte[] bytes(BYTES...) = [BYTES];
|
|
|
|
|
2016-10-06 20:06:51 +00:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
auto f = openFile("test.dat", FileMode.createTrunc);
|
|
|
|
assert(f.size == 0);
|
2016-12-19 20:57:52 +00:00
|
|
|
f.write(bytes!(1, 2, 3, 4, 5));
|
2016-10-06 20:06:51 +00:00
|
|
|
assert(f.size == 5);
|
|
|
|
f.seek(0);
|
2016-12-19 20:57:52 +00:00
|
|
|
f.write(bytes!(1, 2, 3, 4, 5));
|
2016-10-06 20:06:51 +00:00
|
|
|
assert(f.size == 5);
|
2016-12-19 20:57:52 +00:00
|
|
|
f.write(bytes!(6, 7, 8, 9, 10));
|
2016-10-06 20:06:51 +00:00
|
|
|
assert(f.size == 10);
|
|
|
|
ubyte[5] dst;
|
|
|
|
f.seek(2);
|
|
|
|
f.read(dst);
|
2016-12-19 20:57:52 +00:00
|
|
|
assert(dst[] == bytes!(3, 4, 5, 6, 7));
|
2016-10-06 20:15:25 +00:00
|
|
|
f.close();
|
|
|
|
|
|
|
|
removeFile("test.dat");
|
2016-10-06 20:06:51 +00:00
|
|
|
}
|