diff options
author | Tristan Partin <tristan@partin.io> | 2023-08-18 00:04:12 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-08-18 07:46:08 -0400 |
commit | 946a3561c2f45b2e522f695a08516333cf7ec9d4 (patch) | |
tree | 84a7f16b6da32300686ee0554d440317aca92985 /docs/markdown/snippets | |
parent | 22f90fd469a2742a2bb2d4f79e4a585a525ea934 (diff) | |
download | meson-946a3561c2f45b2e522f695a08516333cf7ec9d4.zip meson-946a3561c2f45b2e522f695a08516333cf7ec9d4.tar.gz meson-946a3561c2f45b2e522f695a08516333cf7ec9d4.tar.bz2 |
Revert "Revert "Add fs.relative_to()""
This reverts commit 84c8905d527893bedc673e8a036b8b2ec89368b4.
Fixed the cygwin failure...
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r-- | docs/markdown/snippets/fs_relative_to.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/markdown/snippets/fs_relative_to.md b/docs/markdown/snippets/fs_relative_to.md new file mode 100644 index 0000000..82e6a42 --- /dev/null +++ b/docs/markdown/snippets/fs_relative_to.md @@ -0,0 +1,17 @@ +## `fs.relative_to()` + +The `fs` module now has a `relative_to` method. The method will return the +relative path from argument one to argument two, if one exists. Otherwise, the +absolute path to argument one is returned. + +```meson +assert(fs.relative_to('c:\\prefix\\lib', 'c:\\prefix\\bin') == '..\\lib') +assert(fs.relative_to('c:\\proj1\\foo', 'd:\\proj1\\bar') == 'c:\\proj1\\foo') +assert(fs.relative_to('prefix\\lib\\foo', 'prefix') == 'lib\\foo') + +assert(fs.relative_to('/prefix/lib', '/prefix/bin') == '../lib') +assert(fs.relative_to('prefix/lib/foo', 'prefix') == 'lib/foo') +``` + +In addition to strings, it can handle files, custom targets, custom target +indices, and build targets. |