[#105] initial support for java.nio.file.Files
This commit is contained in:
parent
51b61a921e
commit
1885c45255
5 changed files with 79 additions and 11 deletions
|
|
@ -179,12 +179,14 @@ The following Java classes are available:
|
||||||
- `clojure.lang.ExceptionInfo`
|
- `clojure.lang.ExceptionInfo`
|
||||||
- `Integer`
|
- `Integer`
|
||||||
- `java.io.File`
|
- `java.io.File`
|
||||||
|
- `java.nio.Files`
|
||||||
- `java.util.regex.Pattern`
|
- `java.util.regex.Pattern`
|
||||||
- `String`
|
- `String`
|
||||||
- `System`
|
- `System`
|
||||||
- `Thread`
|
- `Thread`
|
||||||
|
|
||||||
More classes can be added by request.
|
More classes can be added by request. See `reflection.json` and the `:classes`
|
||||||
|
option in `main.clj`.
|
||||||
|
|
||||||
Babashka supports `import` : `(import clojure.lang.ExceptionInfo)`.
|
Babashka supports `import` : `(import clojure.lang.ExceptionInfo)`.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,5 +121,45 @@
|
||||||
{
|
{
|
||||||
"name":"java.lang.UNIXProcess",
|
"name":"java.lang.UNIXProcess",
|
||||||
"allPublicMethods":true
|
"allPublicMethods":true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"java.nio.file.Path",
|
||||||
|
"allPublicMethods":true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"java.nio.file.CopyOption",
|
||||||
|
"allPublicMethods":true,
|
||||||
|
"allPublicFields": true,
|
||||||
|
"allPublicConstructors": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"java.nio.file.FileAlreadyExistsException",
|
||||||
|
"allPublicMethods":true,
|
||||||
|
"allPublicFields": true,
|
||||||
|
"allPublicConstructors": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"java.nio.file.Files",
|
||||||
|
"allPublicMethods":true,
|
||||||
|
"allPublicFields": true,
|
||||||
|
"allPublicConstructors": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"java.nio.file.NoSuchFileException",
|
||||||
|
"allPublicMethods":true,
|
||||||
|
"allPublicFields": true,
|
||||||
|
"allPublicConstructors": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"java.nio.file.StandardCopyOption",
|
||||||
|
"allPublicMethods":true,
|
||||||
|
"allPublicFields": true,
|
||||||
|
"allPublicConstructors": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"sun.nio.fs.UnixPath",
|
||||||
|
"allPublicMethods":true,
|
||||||
|
"allPublicFields": true,
|
||||||
|
"allPublicConstructors": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit d91bf4bf1b831de58a4980379558aed6ce28a641
|
Subproject commit 736880b590e6df75e928a826f1aa24e17a613c67
|
||||||
|
|
@ -227,7 +227,14 @@ Everything after that is bound to *command-line-args*."))
|
||||||
'java.io.StringReader java.io.StringReader
|
'java.io.StringReader java.io.StringReader
|
||||||
'java.io.StringWriter java.io.StringWriter
|
'java.io.StringWriter java.io.StringWriter
|
||||||
'java.lang.System System
|
'java.lang.System System
|
||||||
'java.lang.Thread Thread}
|
'java.lang.Thread Thread
|
||||||
|
'sun.nio.fs.UnixPath sun.nio.fs.UnixPath
|
||||||
|
'java.nio.file.CopyOption java.nio.file.CopyOption
|
||||||
|
'java.nio.file.FileAlreadyExistsException java.nio.file.FileAlreadyExistsException
|
||||||
|
'java.nio.file.Files java.nio.file.Files
|
||||||
|
'java.nio.file.NoSuchFileException java.nio.file.NoSuchFileException
|
||||||
|
'java.nio.file.StandardCopyOption java.nio.file.StandardCopyOption
|
||||||
|
}
|
||||||
:imports '{ArithmeticException java.lang.ArithmeticException
|
:imports '{ArithmeticException java.lang.ArithmeticException
|
||||||
AssertionError java.lang.AssertionError
|
AssertionError java.lang.AssertionError
|
||||||
Boolean java.lang.Boolean
|
Boolean java.lang.Boolean
|
||||||
|
|
|
||||||
|
|
@ -269,3 +269,22 @@
|
||||||
|
|
||||||
(deftest with-in-str-test
|
(deftest with-in-str-test
|
||||||
(is (= 5 (bb nil "(count (with-in-str \"hello\" (read-line)))"))))
|
(is (= 5 (bb nil "(count (with-in-str \"hello\" (read-line)))"))))
|
||||||
|
|
||||||
|
(deftest java-nio-test
|
||||||
|
(let [f (java.io.File/createTempFile "foo" "bar")
|
||||||
|
temp-path (.getPath f)
|
||||||
|
p (.toPath (io/file f))
|
||||||
|
p' (.resolveSibling p "f2")
|
||||||
|
f2 (.toFile p')]
|
||||||
|
(bb nil (format
|
||||||
|
"(let [f (io/file \"%s\")
|
||||||
|
p (.toPath (io/file f))
|
||||||
|
p' (.resolveSibling p \"f2\")]
|
||||||
|
(.delete (.toFile p'))
|
||||||
|
(dotimes [_ 2]
|
||||||
|
(try
|
||||||
|
(java.nio.file.Files/copy p p' (into-array java.nio.file.CopyOption []))
|
||||||
|
(catch java.nio.file.FileAlreadyExistsException _
|
||||||
|
(java.nio.file.Files/copy p p' (into-array [java.nio.file.StandardCopyOption/REPLACE_EXISTING]))))))"
|
||||||
|
temp-path))
|
||||||
|
(is (.exists f2))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue