MCPcopy Create free account
hub / github.com/questdb/questdb / readLink

Method readLink

core/src/main/java/io/questdb/std/Files.java:475–498  ·  view source on GitHub ↗
(Path softLink, Path readTo)

Source from the content-addressed store, hash-verified

473 }
474
475 public static boolean readLink(Path softLink, Path readTo) {
476 final int len = readTo.size();
477 final int bufSize = 1024;
478 readTo.zeroPad(bufSize);
479 // readlink copies link target into the give buffer, without null-terminating it
480 // the buffer therefor is filled with zeroes. It is also possible that buffer is
481 // not large enough to copy the entire target. We detect this by checking the return
482 // value. If the value is the same as the buffer size we make an assumption that
483 // the link target is perhaps longer than the buffer.
484
485 int res = readLink0(softLink.$().ptr(), readTo.$().ptr() + len, bufSize);
486 if (res > 0 && res < bufSize) {
487 readTo.trimTo(len + res);
488 // check if symlink is absolute or relative
489 if (readTo.byteAt(0) != '/') {
490 int prefixLen = Utf8s.lastIndexOfAscii(softLink, '/');
491 if (prefixLen > 0) {
492 readTo.prefix(softLink, prefixLen + 1).$();
493 }
494 }
495 return true;
496 }
497 return false;
498 }
499
500 public static byte readNonNegativeByte(long fd, long offset) {
501 return readNonNegativeByte(toOsFd(fd), offset);

Callers 2

testSoftLinkReadMethod · 0.95
readLinkMethod · 0.95

Calls 9

readLink0Method · 0.95
lastIndexOfAsciiMethod · 0.95
zeroPadMethod · 0.80
prefixMethod · 0.80
sizeMethod · 0.65
ptrMethod · 0.65
$Method · 0.65
trimToMethod · 0.65
byteAtMethod · 0.65

Tested by 1

testSoftLinkReadMethod · 0.76