MCPcopy Create free account
hub / github.com/Snapchat/Valdi / tsn_read_file

Function tsn_read_file

tsn/src/tsn/tsn.cpp:518–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518static tsn_value tsn_read_file(tsn_vm* ctx, tsn_value_const /*this_val*/, int argc, tsn_value_const* argv) {
519 const char* filename;
520 filename = JS_ToCString(ctx, argv[0]);
521 std::ifstream f(filename);
522 std::string str((istreambuf_iterator<char>(f)), istreambuf_iterator<char>());
523 JS_FreeCString(ctx, filename);
524 return JS_NewStringLen(ctx, str.data(), str.size());
525 ;
526}
527
528static tsn_value tsn_now(tsn_vm* ctx, tsn_value_const /*this_val*/, int argc, tsn_value_const* argv) {
529 auto nano_since_epoch = std::chrono::high_resolution_clock::now().time_since_epoch() / std::chrono::nanoseconds(1);

Callers

nothing calls this directly

Calls 3

JS_ToCStringFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected