MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / open_mode_options

Method open_mode_options

examples/doom/src/runtime.rs:132–161  ·  view source on GitHub ↗
(mode: &str)

Source from the content-addressed store, hash-verified

130 }
131
132 fn open_mode_options(mode: &str) -> OpenOptions {
133 let mut options = OpenOptions::new();
134 let plus = mode.as_bytes().contains(&b'+');
135
136 match mode.as_bytes().first().copied() {
137 Some(b'r') => {
138 options.read(true);
139 if plus {
140 options.write(true);
141 }
142 }
143 Some(b'w') => {
144 options.write(true).create(true).truncate(true);
145 if plus {
146 options.read(true);
147 }
148 }
149 Some(b'a') => {
150 options.write(true).create(true).append(true);
151 if plus {
152 options.read(true);
153 }
154 }
155 _ => {
156 options.read(true);
157 }
158 }
159
160 options
161 }
162}
163
164fn build_imports(store: &mut Store, state: Rc<RefCell<HostState>>) -> Imports {

Callers

nothing calls this directly

Calls 3

createMethod · 0.80
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected