mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 00:34:20 +03:00
Функции для работы с файлами
This commit is contained in:
parent
ef701c979f
commit
c67060a7f3
@ -31,6 +31,12 @@ public final class files implements Module {
|
||||
|
||||
Functions.set("fopen", new fopen());
|
||||
Functions.set("listFiles", new listFiles());
|
||||
Functions.set("delete", new delete());
|
||||
Functions.set("exists", new exists());
|
||||
Functions.set("isDirectory", new isDirectory());
|
||||
Functions.set("isFile", new isFile());
|
||||
Functions.set("mkdir", new mkdir());
|
||||
Functions.set("fileSize", new fileSize());
|
||||
Functions.set("readBoolean", new readBoolean());
|
||||
Functions.set("readByte", new readByte());
|
||||
Functions.set("readBytes", new readBytes());
|
||||
@ -128,6 +134,48 @@ public final class files implements Module {
|
||||
}
|
||||
}
|
||||
|
||||
private static class delete extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
return NumberValue.fromBoolean(fileInfo.file.delete());
|
||||
}
|
||||
}
|
||||
|
||||
private static class exists extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
return NumberValue.fromBoolean(fileInfo.file.exists());
|
||||
}
|
||||
}
|
||||
|
||||
private static class isDirectory extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
return NumberValue.fromBoolean(fileInfo.file.isDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
private static class isFile extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
return NumberValue.fromBoolean(fileInfo.file.isFile());
|
||||
}
|
||||
}
|
||||
|
||||
private static class mkdir extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
return NumberValue.fromBoolean(fileInfo.file.mkdir());
|
||||
}
|
||||
}
|
||||
|
||||
private static class fileSize extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
return new NumberValue(fileInfo.file.length());
|
||||
}
|
||||
}
|
||||
|
||||
private static class readBoolean extends FileFunction {
|
||||
@Override
|
||||
protected Value execute(FileInfo fileInfo, Value[] args) throws IOException {
|
||||
|
Loading…
Reference in New Issue
Block a user