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/mfstest.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 '')
-rw-r--r-- | src/tests/mfstest.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/tests/mfstest.cpp b/src/tests/mfstest.cpp deleted file mode 100644 index 813ef8e..0000000 --- a/src/tests/mfstest.cpp +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | #include <bu/file.h> | ||
2 | #include <bu/myriadfs.h> | ||
3 | #include <bu/myriadstream.h> | ||
4 | #include <bu/sio.h> | ||
5 | |||
6 | class Obstore | ||
7 | { | ||
8 | public: | ||
9 | Obstore() : | ||
10 | fStore("test.mfs", Bu::File::WriteNew|Bu::File::Read ), | ||
11 | fsOb( fStore, 1024 ) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | virtual ~Obstore() | ||
16 | { | ||
17 | } | ||
18 | |||
19 | Bu::String getObject( const Bu::String &sPath ) | ||
20 | { | ||
21 | try | ||
22 | { | ||
23 | Bu::MyriadStream s = fsOb.open( | ||
24 | sPath, | ||
25 | Bu::MyriadFs::Read | ||
26 | ); | ||
27 | return s.readAll(); | ||
28 | } | ||
29 | catch( Bu::ExceptionBase &e ) | ||
30 | { | ||
31 | Bu::println("Exception opening file: %1").arg( e.what() ); | ||
32 | return Bu::String(); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | void storeObject( const Bu::String &sPath, const Bu::String &sData ) | ||
37 | { | ||
38 | for( Bu::String::const_iterator i = sPath.begin()+1; i; i++ ) | ||
39 | { | ||
40 | if( *i == '/' ) | ||
41 | { | ||
42 | Bu::String sChunk( sPath.begin(), i ); | ||
43 | fsOb.mkDir( sChunk, 0664 ); | ||
44 | } | ||
45 | } | ||
46 | try | ||
47 | { | ||
48 | Bu::MyriadStream s = fsOb.open( | ||
49 | sPath, | ||
50 | Bu::MyriadFs::Write|Bu::MyriadFs::Create|Bu::MyriadFs::Truncate | ||
51 | ); | ||
52 | s.write( sData ); | ||
53 | } | ||
54 | catch(Bu::ExceptionBase &e ) | ||
55 | { | ||
56 | Bu::println("Exception opening file: %1").arg( e.what() ); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | Bu::File fStore; | ||
61 | Bu::MyriadFs fsOb; | ||
62 | }; | ||
63 | |||
64 | int main( int, char *[] ) | ||
65 | { | ||
66 | Obstore os; | ||
67 | |||
68 | os.storeObject("/killTeamState.json", "This is a json file."); | ||
69 | os.storeObject("/appCredentials/local", "App credentials"); | ||
70 | os.storeObject("/appCredentials/inckybot", "App credentials"); | ||
71 | os.storeObject("/appCredentials/playwith", "App credentials"); | ||
72 | os.storeObject("/restreamIo/users", "User data"); | ||
73 | os.storeObject("/youTube/users", "User data"); | ||
74 | os.storeObject("/topTippers.json", "{\"people\": [\"sam\", \"joe\", \"bob\"]}"); | ||
75 | os.storeObject("/wh40kDecks.json", ""); | ||
76 | |||
77 | Bu::MyriadStream s = os.fsOb.open( | ||
78 | "/appCredentials/inckybot", | ||
79 | Bu::MyriadFs::Write|Bu::MyriadFs::Create|Bu::MyriadFs::Truncate | ||
80 | ); | ||
81 | s.write("Some new credentials, this is a bigger bit of data."); | ||
82 | |||
83 | os.storeObject("/wh40kDecks.json", "{ \"op\": \"replaceDecks\", \"decks\": { \"lev\": { \"name\": \"Leviathan\", \"primary\": { \"pt\": {\"name\": \"Priority Targets\"}, \"vg\": {\"name\": \"Vital Ground\"}, \"se\": {\"name\": \"Scorched Earth\"}, \"pf\": {\"name\": \"Purge the Foe\"}, \"th\": {\"name\": \"Take and Hold\"}, \"sd\": {\"name\": \"Supply Drop\"}, \"tr\": {\"name\": \"The Ritual\"}, \"ds\": {\"name\": \"Deploy Servo-Skulls\"}, \"sp\": {\"name\": \"Sites of Power\"}, }, \"secondary\": { \"tt\": {\"name\": \"A Tempting Target\"}, \"ad\": {\"name\": \"Area Denial\"}, \"as\": {\"name\": \"Assassination\"}, \"be\": {\"name\": \"Behind Enemy Lines\"}, \"bd\": {\"name\": \"Bring It Down\"}, \"ce\": {\"name\": \"Capture Enemy Outpost\"}, \"cl\": {\"name\": \"Cleanse\"}, \"ds\": {\"name\": \"Defend Stronghold\"}, \"dt\": {\"name\": \"Deploy Teleport Homer\"}, \"ef\": {\"name\": \"Engage On All Fronts\"}, \"eb\": {\"name\": \"Extend Battle Lines\"}, \"is\": {\"name\": \"Investigate Signals\"}, \"np\": {\"name\": \"No Prisoners\"}, \"of\": {\"name\": \"Overwhelming Force\"}, \"sl\": {\"name\": \"Secure No Man’s Land\"}, \"sh\": {\"name\": \"Storm Hostile Objective\"}, }, \"gambit\": { \"dt\": {\"name\": \"Delaying Tactics\"}, \"ee\": {\"name\": \"Emergency Evacuation\"}, \"oc\": {\"name\": \"Orbital Strike Coordinates\"}, \"pp\": {\"name\": \"Proceed As Planned\"}, }, \"missionRule\": { \"cr\": {\"name\": \"Chilling Rain\"}, \"sc\": {\"name\": \"Sweep and Clear\"}, \"hs\": {\"name\": \"Hidden Supplies\"}, \"mi\": {\"name\": \"Minefields\"}, \"to\": {\"name\": \"Targets of Opportunity\"}, \"sf\": {\"name\": \"Scrambler Fields\"}, \"dr\": {\"name\": \"Delayed Reserves\"}, \"cb\": {\"name\": \"Chosen Battlefield\"}, \"mb\": {\"name\": \"Maelstrom of Battle\"}, \"sl\": {\"name\": \"Supply Lines\"}, \"si\": {\"name\": \"Secret Intel\"}, \"vs\": {\"name\": \"Vox Static\"}, }, }, } }"); | ||
84 | os.storeObject("/wh40kState.json", "{\"cards\": \"hello\"}"); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||