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