@@ -1085,17 +1085,17 @@ private long[] basicStat(TruffleFile file, LinkOption... linkOptions) throws IOE
1085
1085
CREATION_TIME ,
1086
1086
SIZE ), linkOptions );
1087
1087
int mode = fileTypeBitsFromAttributes (attributes );
1088
- if (file . isReadable ()) {
1088
+ if (isReadable (file )) {
1089
1089
mode |= 0004 ;
1090
1090
mode |= 0040 ;
1091
1091
mode |= 0400 ;
1092
1092
}
1093
- if (file . isWritable ()) {
1093
+ if (isWritable (file )) {
1094
1094
mode |= 0002 ;
1095
1095
mode |= 0020 ;
1096
1096
mode |= 0200 ;
1097
1097
}
1098
- if (file . isExecutable ()) {
1098
+ if (isExecutable (file )) {
1099
1099
mode |= 0001 ;
1100
1100
mode |= 0010 ;
1101
1101
mode |= 0100 ;
@@ -1114,6 +1114,30 @@ private long[] basicStat(TruffleFile file, LinkOption... linkOptions) throws IOE
1114
1114
});
1115
1115
}
1116
1116
1117
+ private static boolean isReadable (TruffleFile file ) {
1118
+ try {
1119
+ return file .isReadable ();
1120
+ } catch (SecurityException e ) {
1121
+ return false ;
1122
+ }
1123
+ }
1124
+
1125
+ private static boolean isWritable (TruffleFile file ) {
1126
+ try {
1127
+ return file .isWritable ();
1128
+ } catch (SecurityException e ) {
1129
+ return false ;
1130
+ }
1131
+ }
1132
+
1133
+ private static boolean isExecutable (TruffleFile file ) {
1134
+ try {
1135
+ return file .isExecutable ();
1136
+ } catch (SecurityException e ) {
1137
+ return false ;
1138
+ }
1139
+ }
1140
+
1117
1141
private static long [] setTimestamps (Attributes attributes , TruffleFile .AttributeDescriptor <FileTime > ctimeDescriptor , long [] statResult ) {
1118
1142
FileTime atime = attributes .get (LAST_ACCESS_TIME );
1119
1143
FileTime mtime = attributes .get (LAST_MODIFIED_TIME );
@@ -1700,13 +1724,13 @@ public boolean faccessat(int dirFd, Object path, int mode, boolean effectiveIds,
1700
1724
}
1701
1725
boolean result = true ;
1702
1726
if ((mode & X_OK .value ) != 0 ) {
1703
- result = result && file . isExecutable ();
1727
+ result = result && isExecutable (file );
1704
1728
}
1705
1729
if ((mode & R_OK .value ) != 0 ) {
1706
- result = result && file . isReadable ();
1730
+ result = result && isReadable (file );
1707
1731
}
1708
1732
if ((mode & W_OK .value ) != 0 ) {
1709
- result = result && file . isWritable ();
1733
+ result = result && isWritable (file );
1710
1734
}
1711
1735
return result ;
1712
1736
}
@@ -2009,7 +2033,7 @@ public int forkExec(Object[] executables, Object[] args, Object cwd, Object[] en
2009
2033
for (Object o : executables ) {
2010
2034
String path = pathToJavaString (o );
2011
2035
TruffleFile executableFile = cwdFile .resolve (path );
2012
- if (executableFile . isExecutable ()) {
2036
+ if (isExecutable (executableFile )) {
2013
2037
argStrings [0 ] = path ;
2014
2038
try {
2015
2039
return exec (argStrings , cwdFile , envMap , stdinWriteFd , stdinReadFd , stdoutWriteFd , stdoutReadFd , stderrWriteFd , errPipeWriteFd , stderrReadFd );
0 commit comments