Skip to content

Commit

Permalink
Document #113
Browse files Browse the repository at this point in the history
  • Loading branch information
pathikrit committed Feb 13, 2017
1 parent 76fcfd1 commit 555984a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
23 changes: 9 additions & 14 deletions core/src/main/scala/better/files/File.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down

0 comments on commit 555984a

Please sign in to comment.