Skip to content

Commit fd3574f

Browse files
committed
Fix os.write.outputStream with perms for Scala 3
1 parent 36e00e0 commit fd3574f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

os/src/ReadWriteOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ object write {
3030
checker.value.onWrite(target)
3131
if (createFolders) makeDir.all(target / RelPath.up, perms)
3232
if (perms != null && !exists(target)) {
33-
val permArray =
34-
if (perms == null) Array[FileAttribute[PosixFilePermission]]()
33+
val permArray: Array[FileAttribute[_]] =
34+
if (perms == null) Array.empty
3535
else Array(PosixFilePermissions.asFileAttribute(perms.toSet()))
3636
java.nio.file.Files.createFile(target.toNIO, permArray: _*)
3737
}

os/test/src/ReadingWritingTests.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ object ReadingWritingTests extends TestSuite {
121121
out.write('o')
122122
out.close()
123123

124+
os.read(wd / "New File.txt") ==> "Hello"
125+
}
126+
}
127+
test("outputStreamWithPerms") {
128+
test - prep { wd =>
129+
val out = os.write.outputStream(wd / "New File.txt", perms = os.PermSet(420))
130+
out.write('H')
131+
out.write('e')
132+
out.write('l')
133+
out.write('l')
134+
out.write('o')
135+
out.close()
136+
124137
os.read(wd / "New File.txt") ==> "Hello"
125138
}
126139
}

0 commit comments

Comments
 (0)