MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / copyFile

Method copyFile

src/os_macos.cpp:376–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376void OS::copyFile(int src_fd, int dst_fd, off_t offset, size_t size) {
377 size_t map_size = size + offset;
378 char* buf = (char*)mmap(NULL, map_size, PROT_READ, MAP_PRIVATE, src_fd, 0);
379 if (buf == MAP_FAILED) {
380 return;
381 }
382
383 while (size > 0) {
384 ssize_t bytes = write(dst_fd, buf + offset, size < 262144 ? size : 262144);
385 if (bytes <= 0) {
386 break;
387 }
388 offset += (size_t)bytes;
389 size -= (size_t)bytes;
390 }
391
392 munmap(buf, map_size);
393}
394
395void OS::freePageCache(int fd, off_t start_offset) {
396 // Not supported on macOS

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected