Skip to content

Commit c0cc9cb

Browse files
authored
Document additional path methods [ci fast] (#6169)
--------- Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent fa5a40e commit c0cc9cb

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

docs/reference/stdlib-types.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -449,53 +449,62 @@ Paths in Nextflow are backed by the [Java](https://docs.oracle.com/en/java/javas
449449
The following operations are supported for paths:
450450

451451
`/ : (Path, String) -> Path`
452-
: Resolve a relative file name against a directory path.
452+
: Resolves a relative path string against a directory path. Equivalent to `resolve()`.
453453

454454
`<< : (Path, String)`
455455
: Appends text to a file without replacing existing content. Equivalent to `append()`.
456456

457457
<h3>Getting attributes</h3>
458458

459-
The following methods are useful for getting attributes of a file:
459+
The following methods are useful for getting attributes of a path:
460460

461461
`exists() -> boolean`
462-
: Returns `true` if the file exists.
462+
: Returns `true` if the path exists.
463463

464464
`getBaseName() -> String`
465-
: Gets the file name without its extension, e.g. `/some/path/file.tar.gz` -> `file.tar`.
465+
: Gets the path name without its extension, e.g. `/some/path/file.tar.gz` -> `file.tar`.
466466

467467
`getExtension() -> String`
468-
: Gets the file extension, e.g. `/some/path/file.txt` -> `txt`.
468+
: Gets the path extension, e.g. `/some/path/file.txt` -> `txt`.
469469

470470
`getName() -> String`
471-
: Gets the file name, e.g. `/some/path/file.txt` -> `file.txt`.
471+
: Gets the path name, e.g. `/some/path/file.txt` -> `file.txt`.
472472

473473
`getSimpleName() -> String`
474-
: Gets the file name without any extension, e.g. `/some/path/file.tar.gz` -> `file`.
474+
: Gets the path name without any extension, e.g. `/some/path/file.tar.gz` -> `file`.
475475

476476
`getParent() -> Path`
477-
: Gets the file parent path, e.g. `/some/path/file.txt` -> `/some/path`.
477+
: Gets the path parent path, e.g. `/some/path/file.txt` -> `/some/path`.
478478

479479
`getScheme() -> String`
480-
: Gets the file URI scheme, e.g. `s3://some-bucket/hello.txt` -> `s3`.
480+
: Gets the path URI scheme, e.g. `s3://some-bucket/hello.txt` -> `s3`.
481481

482482
`isDirectory() -> boolean`
483-
: Returns `true` if the file is a directory.
483+
: Returns `true` if the path is a directory.
484484

485485
`isEmpty() -> boolean`
486-
: Returns `true` if the file is empty or does not exist.
486+
: Returns `true` if the path is empty or does not exist.
487487

488488
`isFile() -> boolean`
489-
: Returns `true` if it is a regular file (i.e. not a directory).
489+
: Returns `true` if the path is a file (i.e. not a directory).
490490

491491
`isHidden() -> boolean`
492-
: Returns `true` if the file is hidden.
492+
: Returns `true` if the path is hidden.
493493

494494
`isLink() -> boolean`
495-
: Returns `true` if the file is a symbolic link.
495+
: Returns `true` if the path is a symbolic link.
496496

497497
`lastModified() -> long`
498-
: Returns the file last modified timestamp in Unix time (i.e. milliseconds since January 1, 1970).
498+
: Returns the path last modified timestamp in Unix time (i.e. milliseconds since January 1, 1970).
499+
500+
`relativize(other: Path) -> Path`
501+
: Returns the relative path between this path and the given path.
502+
503+
`resolve(other: String) -> Path`
504+
: Resolves the given path string against this path.
505+
506+
`resolveSibling(other: String) -> Path`
507+
: Resolves the given path string against this path's parent path.
499508

500509
`size() -> long`
501510
: Gets the file size in bytes.

modules/nf-lang/src/main/java/nextflow/script/types/shim/Path.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ Returns the file last modified timestamp in Unix time (i.e. milliseconds since J
9999
""")
100100
long lastModified();
101101

102+
@Description("""
103+
Returns the relative path between this path and the given path.
104+
""")
105+
Path relativize(Path other);
106+
107+
@Description("""
108+
Resolves the given path string against this path.
109+
""")
110+
Path resolve(String other);
111+
112+
@Description("""
113+
Resolves the given path string against this path's parent path.
114+
""")
115+
Path resolveSibling(String other);
116+
102117
@Description("""
103118
Gets the file size in bytes.
104119
""")

0 commit comments

Comments
 (0)