]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/scl/Files.scl
ed413889ca4fbcbb53722139d58f741c82ca685a
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Files.scl
1 import "Stream"
2 import "Vector"
3 import "Charset"
4
5 importJava "java.nio.file.Path" where
6     data Path
7
8 importJava "java.nio.file.Paths" where
9     
10     @JavaName "get"
11     paths :: String -> Vector String -> Path
12
13 path :: String -> Path
14 path path = paths path (vector [])
15
16 importJava "java.nio.file.OpenOption" where
17     data OpenOption
18
19 importJava "java.nio.file.StandardOpenOption" where
20     READ :: OpenOption
21     WRITE :: OpenOption
22     APPEND :: OpenOption
23     TRUNCATE_EXISTING :: OpenOption
24     CREATE :: OpenOption
25     CREATE_NEW :: OpenOption
26     DELETE_ON_CLOSE :: OpenOption
27     SPARSE :: OpenOption
28     SYNC :: OpenOption
29     DSYNC :: OpenOption
30
31 importJava "java.nio.file.CopyOption" where
32     data CopyOption
33
34 importJava "java.nio.file.LinkOption" where
35     data LinkOption
36
37 importJava "java.nio.file.StandardCopyOption" where
38     REPLACE_EXISTING :: CopyOption
39     COPY_ATTRIBUTES :: CopyOption
40     ATOMIC_MOVE :: CopyOption
41
42 importJava "java.nio.file.LinkOption" where
43     NOFOLLOW_LINKS :: CopyOption // OpenOption
44
45 importJava "java.nio.file.attribute.FileAttribute" where
46     data FileAttribute
47
48 importJava "java.nio.file.Files" where
49     @JavaName newInputStream
50     newInputStreamWithOpenOptions :: Path -> Vector OpenOption -> <Proc, Exception> InputStream 
51
52     @JavaName newOutputStream
53     newOutputStreamWithOpenOptions :: Path -> Vector OpenOption -> <Proc, Exception> OutputStream
54
55     @JavaName createFile
56     createFileWithFileAttributes :: Path -> Vector FileAttribute -> <Proc, Exception> Path
57
58     @JavaName createDirectory
59     createDirectoryWithFileAttributes :: Path -> Vector FileAttribute -> <Proc, Exception> Path
60
61     @JavaName createDirectories
62     createDirectoriesWithFileAttributes :: Path -> Vector FileAttribute -> <Proc, Exception> Path
63
64     @JavaName createTempFile
65     createTempFileWithFileAttributes :: Path -> String -> String -> Vector FileAttribute -> <Proc, Exception> Path
66
67     delete :: Path -> <Proc, Exception> ()
68
69     deleteIfExists :: Path -> <Proc, Exception> Boolean
70     
71     @JavaName copy
72     copyWithCopyOptions :: Path -> Path -> Vector CopyOption -> <Proc, Exception> Path
73
74     @JavaName move
75     moveWithCopyOptions :: Path -> Path -> Vector CopyOption -> <Proc, Exception> Path
76
77     size :: Path -> <Proc, Exception> Long
78
79     @JavaName exists
80     existsWithLinkOptions :: Path -> Vector LinkOption -> <Proc> Boolean
81
82     @JavaName notExists
83     notExistsWithLinkOptions :: Path -> Vector LinkOption -> <Proc> Boolean
84
85     isReadable :: Path -> <Proc> Boolean
86
87     isWritable :: Path -> <Proc> Boolean
88
89     isExecutable :: Path -> <Proc> Boolean
90
91     // Simupedia has BufferedReader.scl module which contains BufferedReader
92     // newBufferedReader :: Path -> Charset -> <Proc> BufferedReader
93     // newBufferedReader :: Path -> <Proc> BufferedReader
94
95     @JavaName copy
96     copyInputStreamWithCopyOptions :: InputStream -> Path -> Vector CopyOption -> <Proc, Exception> Long
97
98     @JavaName copy
99     copyToOutputStream :: Path -> OutputStream -> <Proc, Exception> Long 
100
101     readAllBytes :: Path -> <Proc, Exception> Vector Byte
102
103     @JavaName readAllLines
104     readAllLinesWithCharset :: Path -> Charset -> <Proc, Exception> [String]
105
106     readAllLines :: Path -> <Proc, Exception> [String]
107
108     @JavaName write
109     writeBytesWithOpenOptions :: Path -> Vector Byte -> Vector OpenOption -> <Proc, Exception> Path
110
111 newInputStream :: Path -> <Proc, Exception> InputStream
112 newInputStream path = newInputStreamWithOpenOptions path (vector [])
113
114 newOutputStream :: Path -> <Proc, Exception> OutputStream
115 newOutputStream path = newOutputStreamWithOpenOptions path (vector [])
116
117 createFile :: Path -> <Proc, Exception> Path
118 createFile path = createFileWithFileAttributes path (vector [])
119
120 createDirectory :: Path -> <Proc, Exception> Path
121 createDirectory path = createDirectoryWithFileAttributes path (vector [])
122
123 createDirectories :: Path -> <Proc, Exception> Path
124 createDirectories path = createDirectoriesWithFileAttributes path (vector [])
125
126 createTempFile :: Path -> String -> String -> <Proc, Exception> Path
127 createTempFile dir prefix suffix = createTempFileWithFileAttributes dir prefix suffix (vector [])
128
129 copy :: Path -> Path -> <Proc, Exception> Path
130 copy source target = copyWithCopyOptions source target (vector [])
131
132 move :: Path -> Path -> <Proc, Exception> Path
133 move source target = moveWithCopyOptions source target (vector [])
134
135 exists :: Path -> <Proc> Boolean
136 exists path = existsWithLinkOptions path (vector [])
137
138 notExists :: Path -> <Proc> Boolean
139 notExists path = notExistsWithLinkOptions path (vector [])