Skip to content

Commit

Permalink
Support /tmp on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Nov 27, 2020
1 parent 3918ca9 commit 387a419
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/scala/sjsonnew/JavaExtraFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ trait JavaExtraFormats {

implicit val fileStringIso: IsoString[File] = IsoString.iso[File](
(f: File) => {
val p = f.getPath
if (f.isAbsolute) {
//not using f.toURI to avoid filesystem syscalls
//we use empty string as host to force file:// instead of just file:
new URI(FileScheme, "", normalizeName(slashify(f.getAbsolutePath)), null).toASCIIString
} else if (p.startsWith(File.separatorChar.toString)) {
// supports /tmp on Windows
new URI(FileScheme, "", normalizeName(slashify(p)), null).toASCIIString
} else {
new URI(null, normalizeName(f.getPath), null).toASCIIString
}
Expand Down

0 comments on commit 387a419

Please sign in to comment.