Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions os/src/ReadWriteOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ object write {
checker.value.onWrite(target)
if (createFolders) makeDir.all(target / RelPath.up, perms)
if (perms != null && !exists(target)) {
val permArray =
if (perms == null) Array[FileAttribute[PosixFilePermission]]()
Comment on lines -33 to -34
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lihaoyi It's because the type here is wrong. It should be Array[FileAttribute[java.util.Set[PosixFilePermission]]] instead. I don't know how this compiles or why it runs on Scala 2 though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the details, but looks like Scala 3 handles varargs differently https://docs.scala-lang.org/scala3/reference/changed-features/vararg-splices.html

val permArray: Array[FileAttribute[_]] =
if (perms == null) Array.empty
else Array(PosixFilePermissions.asFileAttribute(perms.toSet()))
java.nio.file.Files.createFile(target.toNIO, permArray: _*)
}
Expand Down
15 changes: 15 additions & 0 deletions os/test/src/ReadingWritingTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ object ReadingWritingTests extends TestSuite {
os.read(wd / "New File.txt") ==> "Hello"
}
}
test("outputStreamWithPerms") {
test - prep { wd =>
if (!scala.util.Properties.isWin) {
val out = os.write.outputStream(wd / "New File.txt", perms = os.PermSet(420))
out.write('H')
out.write('e')
out.write('l')
out.write('l')
out.write('o')
out.close()

os.read(wd / "New File.txt") ==> "Hello"
}
}
}
}
test("truncate") {
test - prep { wd =>
Expand Down
Loading