From 555984a37ad5812e5905312f20d95913836ecd58 Mon Sep 17 00:00:00 2001 From: pathikrit Date: Mon, 13 Feb 2017 16:43:15 -0500 Subject: [PATCH] Document #113 --- CHANGES.md | 1 + core/src/main/scala/better/files/File.scala | 23 ++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3b5142e8..2edb4dfa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ ## v3.0.0 +* [PR #113](https://github.com/pathikrit/better-files/pull/113): File anchor util * [Issue #105](https://github.com/pathikrit/better-files/issues/105): Remove dependency on scala.io * [File.usingTemp](https://github.com/pathikrit/better-files/commit/d3522e8da63b55c7d3fa14cc9b0b76acd57c60ca) * [Optional symbolic operations](https://github.com/pathikrit/better-files/issues/102) diff --git a/core/src/main/scala/better/files/File.scala b/core/src/main/scala/better/files/File.scala index d80f602e..c8c14f65 100644 --- a/core/src/main/scala/better/files/File.scala +++ b/core/src/main/scala/better/files/File.scala @@ -894,17 +894,14 @@ object File { /** * Get File to path with help of reference anchor. * - * Anchor is used as a reference in case that path - * is not absolute. Anchor could be path to directory or - * path to file. If anchor is file, then file's parent dir - * is used as an anchor. + * Anchor is used as a reference in case that path is not absolute. + * Anchor could be path to directory or path to file. + * If anchor is file, then file's parent dir is used as an anchor. * - * If anchor itself is relative, then anchor is used together - * with current working directory. + * If anchor itself is relative, then anchor is used together with current working directory. * - * NOTE: If anchor is non-existing path on filesystem, - * then it's always treated as file, e.g. it's last component - * is removed when it is used as an anchor. + * NOTE: If anchor is non-existing path on filesystem, then it's always treated as file, + * e.g. it's last component is removed when it is used as an anchor. * * @param anchor path to be used as anchor * @param path as string @@ -915,12 +912,10 @@ object File { val p = Paths.get(path, fragments: _*) if (p.isAbsolute) { p + } else if (anchor.isDirectory) { + anchor / p.toString } else { - if (anchor.isDirectory) { - anchor / p.toString - } else { - anchor.parent / p.toString - } + anchor.parent / p.toString } }