Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the target of a symlink in Perl 6?

Tags:

symlink

raku

You can create a symlink in Perl 6:

my $symlink-path = ...;
$target.symlink: $symlink-path;

Given just the symlink how can you get the target path?

$symlink-path.IO.????

I'm looking for the exact string that is the target, not any interpretation of that (such as .resolve).

like image 207
brian d foy Avatar asked Jun 11 '18 23:06

brian d foy


2 Answers

There is no equivalent in Perl 6 for that to my knowledge.

The closest thing to a solution, is to zef install P5readlink (https://modules.raku.org/dist/P5readlink) and use readlink like you would in Perl 5.

like image 161
Elizabeth Mattijsen Avatar answered Dec 03 '22 14:12

Elizabeth Mattijsen


Method resolve works:

 my $target       = "../tmp/file".IO; 
 my $symlink-path = "files".IO;
 $target.symlink: $symlink-path;

 say $symlink-path.resolve;
 say $symlink-path.resolve(:completely) ~~ $target.resolve(:completely);
like image 20
wamba Avatar answered Dec 03 '22 13:12

wamba