Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behavior in cwk_path_get_relative when child directory have same name as its parents #23

Closed
aomsin2526 opened this issue Sep 2, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@aomsin2526
Copy link

Example:

cwk_path_set_style(::CWK_STYLE_UNIX);

char buffer[FILENAME_MAX];

cwk_path_get_relative(
	"/dir/dir/",
	"/dir/dir3/file",
	buffer,
	sizeof(buffer));

printf("The relative path is: %s\n", buffer);

Will return
The relative path is: file

This is wrong. Expected results should be
../dir3/file

If i change base dir to something else for example from "/dir/dir/" to "/dir/dir2/"

cwk_path_set_style(::CWK_STYLE_UNIX);

char buffer[FILENAME_MAX];

cwk_path_get_relative(
	"/dir/dir2/",
	"/dir/dir3/file",
	buffer,
	sizeof(buffer));

printf("The relative path is: %s\n", buffer);

it will return correct results.
The relative path is: ../dir3/file

@aomsin2526 aomsin2526 changed the title Weird behavior in cwk_path_get_relative when child directory name have same name as its parents Weird behavior in cwk_path_get_relative when child directory have same name as its parents Sep 2, 2021
@likle likle self-assigned this Sep 2, 2021
@likle likle added the bug Something isn't working label Sep 2, 2021
@likle
Copy link
Owner

likle commented Sep 2, 2021

Hi @aomsin2526 ! Thanks for reporting this. I will have a look at it

@likle
Copy link
Owner

likle commented Sep 2, 2021

Hi @aomsin2526 , this should be resolved on the master branch. Could you verify? I will create a release with this soon.

@aomsin2526
Copy link
Author

Yes, working as expected now.

@likle
Copy link
Owner

likle commented Sep 2, 2021

@aomsin2526 thank you very much for your help! This fix is now in the newest release v1.2.6.

@likle likle closed this as completed Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants