| 1293 | |
| 1294 | #if !defined(__wasi__) |
| 1295 | static JSValue js_std_popen(JSContext *ctx, JSValueConst this_val, |
| 1296 | int argc, JSValueConst *argv) |
| 1297 | { |
| 1298 | const char *filename, *mode = NULL; |
| 1299 | FILE *f; |
| 1300 | int err; |
| 1301 | |
| 1302 | filename = JS_ToCString(ctx, argv[0]); |
| 1303 | if (!filename) |
| 1304 | goto fail; |
| 1305 | mode = JS_ToCString(ctx, argv[1]); |
| 1306 | if (!mode) |
| 1307 | goto fail; |
| 1308 | if (strcmp(mode, "r") && strcmp(mode, "w")) { |
| 1309 | JS_ThrowTypeError(ctx, "invalid file mode"); |
| 1310 | goto fail; |
| 1311 | } |
| 1312 | |
| 1313 | f = popen(filename, mode); |
| 1314 | if (!f) |
| 1315 | err = errno; |
| 1316 | else |
| 1317 | err = 0; |
| 1318 | if (argc >= 3) |
| 1319 | js_set_error_object(ctx, argv[2], err); |
| 1320 | JS_FreeCString(ctx, filename); |
| 1321 | JS_FreeCString(ctx, mode); |
| 1322 | if (!f) |
| 1323 | return JS_NULL; |
| 1324 | return js_new_std_file(ctx, f, true); |
| 1325 | fail: |
| 1326 | JS_FreeCString(ctx, filename); |
| 1327 | JS_FreeCString(ctx, mode); |
| 1328 | return JS_EXCEPTION; |
| 1329 | } |
| 1330 | #endif // !defined(__wasi__) |
| 1331 | |
| 1332 | static JSValue js_std_fdopen(JSContext *ctx, JSValueConst this_val, |
nothing calls this directly
no test coverage detected