Benoit Quenaudon
10/12/2021, 7:10 PMrealpath (platform.posix.realpath) but for some reason, a private prefix is added on the resolved path. Any idea why that could be?
Code is something like that
val fullpath = realpath(path.toString(), null)
try {
symlinkTarget = Buffer().writeNullTerminated(fullpath).toPath()
} finally {
free(fullpath)
}
And my test fails with
kotlin.AssertionError: Expected </base/symlink-target>, actual </private/base/symlink-target>.Benoit Quenaudon
10/12/2021, 7:11 PMephemient
10/12/2021, 7:15 PMBenoit Quenaudon
10/12/2021, 7:19 PMBenoit Quenaudon
10/12/2021, 7:26 PMgetenv("TMPDIR") which points to something like /var/folders/vc/5dwj5pms6s97y5snf5t4042c0000gn/T/.
Why would realpath adds a prefix here?ephemient
10/12/2021, 7:26 PMBenoit Quenaudon
10/12/2021, 7:27 PM/var/folders/vc/5dwj5pms6s97y5snf5t4042c0000gn/T/ looks like an absolute path though.
Is there a way to use realpath, or another tool to stay within the working directory?ephemient
10/12/2021, 7:27 PMephemient
10/12/2021, 7:27 PMls -l /var you'll see /var -> /private/varephemient
10/12/2021, 7:28 PMBenoit Quenaudon
10/12/2021, 7:33 PM/var/base/source which points to /var/base/target
• assert that the symlink target of /var/base/source is /var/base/target
but it fails because of the /private being added.Benoit Quenaudon
10/12/2021, 7:33 PMprivate has no slash in front
$ ls -ahl /var
lrwxr-xr-x 1 root wheel 11 Jan 1 2020 /var -> private/var/ephemient
10/12/2021, 7:37 PMephemient
10/12/2021, 7:38 PMBenoit Quenaudon
10/12/2021, 7:38 PMuli
10/13/2021, 12:40 PMBenoit Quenaudon
10/13/2021, 1:23 PMplatform.posix.readlink did the job well for me eventually