(stream: Stream, cb: () => number, method: string)
| 166 | } |
| 167 | |
| 168 | function readWriteHelper(stream: Stream, cb: () => number, method: string) { |
| 169 | let nbytes; |
| 170 | try { |
| 171 | nbytes = handleEAGAIN(cb); |
| 172 | } catch (e: any) { |
| 173 | if (e && e.code && Module.ERRNO_CODES[e.code]) { |
| 174 | throw new FS.ErrnoError(Module.ERRNO_CODES[e.code]); |
| 175 | } |
| 176 | if (isErrnoError(e)) { |
| 177 | // the handler set an errno, propagate it |
| 178 | throw e; |
| 179 | } |
| 180 | console.error(`Error thrown in ${method}:`); |
| 181 | console.error(e); |
| 182 | throw new FS.ErrnoError(cDefs.EIO); |
| 183 | } |
| 184 | if (nbytes === undefined) { |
| 185 | // Prevent an infinite loop caused by incorrect code that doesn't return a |
| 186 | // value |
| 187 | // Maybe we should set nbytes = buffer.length here instead? |
| 188 | console.warn( |
| 189 | `${method} returned undefined; a correct implementation must return a number`, |
| 190 | ); |
| 191 | throw new FS.ErrnoError(cDefs.EIO); |
| 192 | } |
| 193 | if (nbytes !== 0) { |
| 194 | stream.node.timestamp = Date.now(); |
| 195 | } |
| 196 | return nbytes; |
| 197 | } |
| 198 | |
| 199 | const prepareBuffer = ( |
| 200 | buffer: Uint8Array, |
no test coverage detected
searching dependent graphs…