-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from eed3si9n/wip/permission
POSIX permission operations
- Loading branch information
Showing
3 changed files
with
310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package sbt.io | ||
|
||
import org.scalatest._ | ||
import sbt.io.syntax._ | ||
import java.nio.file.attribute.PosixFilePermission | ||
|
||
class FileSpec extends FlatSpec with Matchers { | ||
"files" should "set/unset permissions" in { | ||
IO.withTemporaryDirectory { dir => | ||
val t1 = dir / "foo.txt" | ||
IO.write(t1, "foo") | ||
if (IO.isPosix) { | ||
//an[UnsupportedOperationException] should be thrownBy t1.dosAttributes | ||
t1.permissions(PosixFilePermission.OWNER_EXECUTE) shouldBe false | ||
|
||
t1.addPermission(PosixFilePermission.OWNER_EXECUTE) | ||
t1.addPermission(PosixFilePermission.GROUP_WRITE) | ||
t1.testPermission(PosixFilePermission.OWNER_EXECUTE) shouldBe true | ||
t1.permissionsAsString shouldBe "rwxrw-r--" | ||
|
||
t1.removePermission(PosixFilePermission.OWNER_EXECUTE) | ||
t1.isOwnerExecutable shouldBe false | ||
t1.permissionsAsString shouldBe "rw-rw-r--" | ||
} else () | ||
} | ||
} | ||
} |