Dictu icon indicating copy to clipboard operation
Dictu copied to clipboard

[FEATURE] `Path.isLink`

Open WillDaSilva opened this issue 4 years ago • 8 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem?

The Path library does not have a method to check if a given path is symbolic link.

Describe the solution you'd like

A Path.isLink method that takes a single string argument, the path, and returns a bool indicating whether it is or is not a symbolic link.

Describe alternatives you've considered

Could also be called Path.isSymLink, which is more accurate, but more verbose.

Additional context

No response

WillDaSilva avatar Oct 03 '21 15:10 WillDaSilva

Can you assign me this issue. I would like to contribute to this?

Kishore-abhimanyu avatar Oct 04 '21 12:10 Kishore-abhimanyu

Done @Kishore-abhimanyu !

Jason2605 avatar Oct 04 '21 14:10 Jason2605

@Jason2605 Can you share some test cases for this?

Kishore-abhimanyu avatar Oct 04 '21 17:10 Kishore-abhimanyu

For testing the method is working for non-symbolic links just use any directory within the project. For testing symbolic links we may have to get a bit creative to appease the tests.

You do have System.platform available to you so that you can build the tests in a way that are platform related checking for symlinks that are there by default. Will have to do some research into finding these.

Jason2605 avatar Oct 04 '21 17:10 Jason2605

@Kishore-abhimanyu you'll have to write your own test cases. I would recommend creating a directory under tests/path that has a symlink to a regular file, a symlink to a directory, and a broken symlink. Note that git can commit symlinks. Then add the file tests/path/isLink.du, and use assert with Path.isLink to test against those symlinks and non-symlinks under tests/path.

WillDaSilva avatar Oct 04 '21 17:10 WillDaSilva

@Kishore-abhimanyu you'll have to write your own test cases. I would recommend creating a directory under tests/path that has a symlink to a regular file, a symlink to a directory, and a broken symlink. Note that git can commit symlinks. Then add the file tests/path/isLink.du, and use assert with Path.isLink to test against those symlinks and non-symlinks under tests/path.

This may cause issues for windows machines. If i'm not mistaken (untested) a symlink created on say a unix machine and pulled down on a windows machine creates a text file rather than an actual symbolic link.

Jason2605 avatar Oct 04 '21 17:10 Jason2605

will add the windows functionality also

Kishore-abhimanyu avatar Oct 04 '21 19:10 Kishore-abhimanyu