Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement prim_file:make_(sym|)link/2 driver API

  • Loading branch information...
commit 9563a8151de8c0ce34cd62006d3c83138a973f41 1 parent dc580a5
@krestenkrab krestenkrab authored
Showing with 38 additions and 0 deletions.
  1. +38 −0 src/main/java/erjang/driver/efile/EFile.java
View
38 src/main/java/erjang/driver/efile/EFile.java
@@ -1311,6 +1311,44 @@ public void ready() throws Pausable {
} break;
+ case FILE_LINK:
+ case FILE_SYMLINK: {
+ final String old_file = IO.strcpy(buf);
+ final String new_file = IO.strcpy(buf);
+
+
+ d = new FileAsync() {
+
+ @Override
+ public void async() {
+ Path existing = ERT.newFile(old_file).toPath();
+ Path link = new File(new_file).toPath();
+ try {
+ if (cmd == FILE_LINK) {
+ Files.createLink(link, existing);
+ } else if (cmd == FILE_SYMLINK) {
+ Files.createSymbolicLink(link, existing);
+ } else {
+ posix_errno = Posix.EUNKNOWN;
+ result_ok = false;
+ return;
+ }
+
+ result_ok = true;
+ } catch (IOException e) {
+ posix_errno = IO.exception_to_posix_code(e);
+ result_ok = false;
+ }
+ }
+
+ @Override
+ public void ready() throws Pausable {
+ reply(EFile.this);
+ }
+ };
+
+ } break;
+
case FILE_READLINK: {
d = new SimpleFileAsync(cmd, IO.strcpy(buf)) {
Please sign in to comment.
Something went wrong with that request. Please try again.