fs icon indicating copy to clipboard operation
fs copied to clipboard

How to clean up paths? Remove `./` etc.

Open dereckmezquita opened this issue 3 years ago • 1 comments

Hi maybe I am missing something, I am just seeking some guidance. How would I clean up this path? It is still working and valid but I don't like it:

fs::path("some/path", "./file.txt")
some/path/./file.txt

Desired output:

some/path/file.txt

dereckmezquita avatar Jun 26 '22 06:06 dereckmezquita

I would look at the path_*() functions:

❯ fs::path_
fs::path_abs         fs::path_ext_set     fs::path_package
fs::path_common      fs::path_file        fs::path_real
fs::path_dir         fs::path_filter      fs::path_rel
fs::path_expand      fs::path_has_parent  fs::path_sanitize
fs::path_expand_r    fs::path_home        fs::path_split
fs::path_ext         fs::path_home_r      fs::path_temp
fs::path_ext<-       fs::path_join        fs::path_tidy
fs::path_ext_remove  fs::path_norm        fs::path_wd

path_norm() or path_tidy() look promising.

gaborcsardi avatar Jun 26 '22 07:06 gaborcsardi

Seemingly path_norm() does this.

gaborcsardi avatar Nov 01 '23 13:11 gaborcsardi