MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / doTruncate

Function doTruncate

system/lib/wasmfs/syscalls.cpp:1265–1284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263}
1264
1265static int doTruncate(std::shared_ptr<File>& file, off_t size) {
1266 auto dataFile = file->dynCast<DataFile>();
1267
1268 if (!dataFile) {
1269 return -EISDIR;
1270 }
1271
1272 auto locked = dataFile->locked();
1273 if (!(locked.getMode() & WASMFS_PERM_WRITE)) {
1274 return -EACCES;
1275 }
1276
1277 if (size < 0) {
1278 return -EINVAL;
1279 }
1280
1281 int ret = locked.setSize(size);
1282 assert(ret <= 0);
1283 return ret;
1284}
1285
1286int __syscall_truncate64(const char* path, off_t length) {
1287 auto parsed = path::parseFile(path);

Callers 3

__syscall_truncate64Function · 0.70
__syscall_ftruncate64Function · 0.70
doChmodFunction · 0.50

Calls 4

getModeMethod · 0.80
assertFunction · 0.50
lockedMethod · 0.45
setSizeMethod · 0.45

Tested by

no test coverage detected