@@ -31,6 +31,12 @@ public void init() {
31
31
32
32
Functions .set ("fopen" , new fopen ());
33
33
Functions .set ("listFiles" , new listFiles ());
34
+ Functions .set ("delete" , new delete ());
35
+ Functions .set ("exists" , new exists ());
36
+ Functions .set ("isDirectory" , new isDirectory ());
37
+ Functions .set ("isFile" , new isFile ());
38
+ Functions .set ("mkdir" , new mkdir ());
39
+ Functions .set ("fileSize" , new fileSize ());
34
40
Functions .set ("readBoolean" , new readBoolean ());
35
41
Functions .set ("readByte" , new readByte ());
36
42
Functions .set ("readBytes" , new readBytes ());
@@ -128,6 +134,48 @@ protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
128
134
}
129
135
}
130
136
137
+ private static class delete extends FileFunction {
138
+ @ Override
139
+ protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
140
+ return NumberValue .fromBoolean (fileInfo .file .delete ());
141
+ }
142
+ }
143
+
144
+ private static class exists extends FileFunction {
145
+ @ Override
146
+ protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
147
+ return NumberValue .fromBoolean (fileInfo .file .exists ());
148
+ }
149
+ }
150
+
151
+ private static class isDirectory extends FileFunction {
152
+ @ Override
153
+ protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
154
+ return NumberValue .fromBoolean (fileInfo .file .isDirectory ());
155
+ }
156
+ }
157
+
158
+ private static class isFile extends FileFunction {
159
+ @ Override
160
+ protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
161
+ return NumberValue .fromBoolean (fileInfo .file .isFile ());
162
+ }
163
+ }
164
+
165
+ private static class mkdir extends FileFunction {
166
+ @ Override
167
+ protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
168
+ return NumberValue .fromBoolean (fileInfo .file .mkdir ());
169
+ }
170
+ }
171
+
172
+ private static class fileSize extends FileFunction {
173
+ @ Override
174
+ protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
175
+ return new NumberValue (fileInfo .file .length ());
176
+ }
177
+ }
178
+
131
179
private static class readBoolean extends FileFunction {
132
180
@ Override
133
181
protected Value execute (FileInfo fileInfo , Value [] args ) throws IOException {
0 commit comments