]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/Files.scl
Adding FileSystem and FileSystems to Files SCL-API
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Files.scl
index ed413889ca4fbcbb53722139d58f741c82ca685a..d1bc885616e2d34c91c2e633fe2939ece0a6d4e9 100644 (file)
@@ -4,6 +4,20 @@ import "Charset"
 
 importJava "java.nio.file.Path" where
     data Path
 
 importJava "java.nio.file.Path" where
     data Path
+    
+    @JavaName "getParent"
+    getParentPath :: Path -> <Proc> Path
+    
+    @JavaName "resolve"
+    resolvePath :: Path -> String -> <Proc> Path
+
+    @JavaName "relativize"
+    relativizePath :: Path -> Path -> <Proc> Path
+    
+    toAbsolutePath :: Path -> <Proc> Path
+    
+    @JavaName "toString"
+    pathToString :: Path -> <Proc> String
 
 importJava "java.nio.file.Paths" where
     
 
 importJava "java.nio.file.Paths" where
     
@@ -45,6 +59,25 @@ importJava "java.nio.file.LinkOption" where
 importJava "java.nio.file.attribute.FileAttribute" where
     data FileAttribute
 
 importJava "java.nio.file.attribute.FileAttribute" where
     data FileAttribute
 
+importJava "java.nio.file.FileSystem" where
+    data FileSystem
+    
+    @JavaName close
+    closeFileSystem :: FileSystem -> <Proc> ()
+    
+    @JavaName getPath
+    getPathFromFileSystem :: FileSystem -> String -> Vector String -> <Proc> Path
+
+importJava "java.lang.ClassLoader" where
+    @private
+    data ClassLoader
+
+importJava "java.nio.file.FileSystems" where
+    @private
+    newFileSystem :: Path -> Maybe ClassLoader -> FileSystem
+
+newFileSystemFromPath path = newFileSystem path Nothing
+
 importJava "java.nio.file.Files" where
     @JavaName newInputStream
     newInputStreamWithOpenOptions :: Path -> Vector OpenOption -> <Proc, Exception> InputStream 
 importJava "java.nio.file.Files" where
     @JavaName newInputStream
     newInputStreamWithOpenOptions :: Path -> Vector OpenOption -> <Proc, Exception> InputStream 
@@ -62,7 +95,7 @@ importJava "java.nio.file.Files" where
     createDirectoriesWithFileAttributes :: Path -> Vector FileAttribute -> <Proc, Exception> Path
 
     @JavaName createTempFile
     createDirectoriesWithFileAttributes :: Path -> Vector FileAttribute -> <Proc, Exception> Path
 
     @JavaName createTempFile
-    createTempFileWithFileAttributes :: Path -> String -> String -> Vector FileAttribute -> <Proc, Exception> Path
+    createTempFileWithFileAttributes :: String -> String -> Vector FileAttribute -> <Proc, Exception> Path
 
     delete :: Path -> <Proc, Exception> ()
 
 
     delete :: Path -> <Proc, Exception> ()
 
@@ -99,6 +132,7 @@ importJava "java.nio.file.Files" where
     copyToOutputStream :: Path -> OutputStream -> <Proc, Exception> Long 
 
     readAllBytes :: Path -> <Proc, Exception> Vector Byte
     copyToOutputStream :: Path -> OutputStream -> <Proc, Exception> Long 
 
     readAllBytes :: Path -> <Proc, Exception> Vector Byte
+    write :: Path -> Vector Byte -> Vector OpenOption -> <Proc,Exception> ()
 
     @JavaName readAllLines
     readAllLinesWithCharset :: Path -> Charset -> <Proc, Exception> [String]
 
     @JavaName readAllLines
     readAllLinesWithCharset :: Path -> Charset -> <Proc, Exception> [String]
@@ -123,8 +157,8 @@ createDirectory path = createDirectoryWithFileAttributes path (vector [])
 createDirectories :: Path -> <Proc, Exception> Path
 createDirectories path = createDirectoriesWithFileAttributes path (vector [])
 
 createDirectories :: Path -> <Proc, Exception> Path
 createDirectories path = createDirectoriesWithFileAttributes path (vector [])
 
-createTempFile :: Path -> String -> String -> <Proc, Exception> Path
-createTempFile dir prefix suffix = createTempFileWithFileAttributes dir prefix suffix (vector [])
+createTempFile :: String -> String -> <Proc, Exception> Path
+createTempFile prefix suffix = createTempFileWithFileAttributes prefix suffix (vector [])
 
 copy :: Path -> Path -> <Proc, Exception> Path
 copy source target = copyWithCopyOptions source target (vector [])
 
 copy :: Path -> Path -> <Proc, Exception> Path
 copy source target = copyWithCopyOptions source target (vector [])