Skip to content

Commit

Permalink
Add FilePlugin#primitiveHasFileAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Oct 24, 2021
1 parent 8fc5486 commit f154536
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017-2021 Software Architecture Group, Hasso Plattner Institute
* Copyright (c) 2021 Oracle and/or its affiliates
*
* Licensed under the MIT License.
*/
Expand Down Expand Up @@ -696,4 +697,19 @@ private static void writeToOutputStream(final OutputStream outputStream, final b
}
}
}

@GenerateNodeFactory
@SqueakPrimitive(names = "primitiveHasFileAccess")
protected abstract static class PrimHasFileAccessNode extends AbstractPrimitiveNode {
@Specialization
@TruffleBoundary
protected final boolean hasFileAccess(@SuppressWarnings("unused") final Object receiver) {
try {
getContext().env.getCurrentWorkingDirectory();
return BooleanObject.TRUE;
} catch (final SecurityException e) {
return BooleanObject.FALSE;
}
}
}
}

0 comments on commit f154536

Please sign in to comment.