diff options
author | Mike Buland <mike@xagasoft.com> | 2024-08-27 13:37:36 -0700 |
---|---|---|
committer | Mike Buland <mike@xagasoft.com> | 2024-08-27 13:37:36 -0700 |
commit | f1e3f25d9b7a12cdedb99e4cb0bfa66157a1a972 (patch) | |
tree | c8414b8040cdcd38bd98471d96a01908cdef49ad /src/tests/myriadfs.cpp | |
parent | caee572ff94822ca2ed354fcb79ca04ed9adf388 (diff) | |
download | libbu++-f1e3f25d9b7a12cdedb99e4cb0bfa66157a1a972.tar.gz libbu++-f1e3f25d9b7a12cdedb99e4cb0bfa66157a1a972.tar.bz2 libbu++-f1e3f25d9b7a12cdedb99e4cb0bfa66157a1a972.tar.xz libbu++-f1e3f25d9b7a12cdedb99e4cb0bfa66157a1a972.zip |
Making progress.
Diffstat (limited to 'src/tests/myriadfs.cpp')
-rw-r--r-- | src/tests/myriadfs.cpp | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/tests/myriadfs.cpp b/src/tests/myriadfs.cpp deleted file mode 100644 index 1266e4b..0000000 --- a/src/tests/myriadfs.cpp +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | #include "bu/file.h" | ||
2 | #include "bu/membuf.h" | ||
3 | #include "bu/myriadfs.h" | ||
4 | #include "bu/myriadstream.h" | ||
5 | #include "bu/sio.h" | ||
6 | |||
7 | using namespace Bu; | ||
8 | |||
9 | int main() | ||
10 | { | ||
11 | // Bu::MemBuf mb; | ||
12 | Bu::File mb("store.myr", File::Read|File::Write|File::Create ); | ||
13 | Bu::MyriadFs mfs( mb, 512 ); | ||
14 | |||
15 | sio << "Creating dirs..." << sio.nl; | ||
16 | mfs.create("/etc", Bu::MyriadFs::typeDir|0755 ); | ||
17 | mfs.create("/dev", Bu::MyriadFs::typeDir|0755 ); | ||
18 | mfs.create("/usr", Bu::MyriadFs::typeDir|0755 ); | ||
19 | |||
20 | mfs.create("/dev/null", Bu::MyriadFs::typeChrDev|0666, 1, 3 ); | ||
21 | mfs.create("/dev/zero", Bu::MyriadFs::typeChrDev|0666, 1, 5 ); | ||
22 | mfs.create("/dev/sda", Bu::MyriadFs::typeBlkDev|0660, 8, 0 ); | ||
23 | |||
24 | sio << "Creating files..." << sio.nl; | ||
25 | { | ||
26 | Bu::MyriadStream ms = mfs.open("/hello", Bu::MyriadFs::Read ); | ||
27 | ms.write("world!"); | ||
28 | } | ||
29 | { | ||
30 | Bu::MyriadStream ms = mfs.open("/etc/hello", Bu::MyriadFs::Read ); | ||
31 | ms.write("world, again!"); | ||
32 | } | ||
33 | { | ||
34 | Bu::MyriadStream ms = mfs.open("/etc/trunc", Bu::MyriadFs::Write ); | ||
35 | ms.write("[longer text shouldn't be seen]"); | ||
36 | } | ||
37 | { | ||
38 | Bu::MyriadStream ms = mfs.open("/etc/trunc", Bu::MyriadFs::Write|Bu::MyriadFs::Create|Bu::MyriadFs::Truncate ); | ||
39 | ms.write("[short text]"); | ||
40 | } | ||
41 | |||
42 | sio << "Reading files..." << sio.nl; | ||
43 | { | ||
44 | Bu::MyriadStream ms = mfs.open("/hello", Bu::MyriadFs::Read ); | ||
45 | char buf[512]; | ||
46 | buf[ms.read( buf, 512 )] = '\0'; | ||
47 | sio << "read: '" << buf << "'" << sio.nl; | ||
48 | } | ||
49 | { | ||
50 | Bu::MyriadStream ms = mfs.open("/etc/hello", Bu::MyriadFs::Read ); | ||
51 | char buf[512]; | ||
52 | buf[ms.read( buf, 512 )] = '\0'; | ||
53 | sio << "read: '" << buf << "'" << sio.nl; | ||
54 | } | ||
55 | { | ||
56 | Bu::MyriadStream ms = mfs.open("/etc/trunc", Bu::MyriadFs::Read ); | ||
57 | char buf[512]; | ||
58 | buf[ms.read( buf, 512 )] = '\0'; | ||
59 | sio << "read: '" << buf << "'" << sio.nl; | ||
60 | } | ||
61 | } | ||
62 | |||