@@ -385,7 +385,7 @@ public abstract static class ChdirNode extends PythonBuiltinNode {
385
385
PNone chdir (String spath ) {
386
386
Env env = getContext ().getEnv ();
387
387
try {
388
- TruffleFile dir = env .getTruffleFile (spath ).getAbsoluteFile ();
388
+ TruffleFile dir = env .getPublicTruffleFile (spath ).getAbsoluteFile ();
389
389
env .setCurrentWorkingDirectory (dir );
390
390
return PNone .NONE ;
391
391
} catch (UnsupportedOperationException | IllegalArgumentException | SecurityException e ) {
@@ -512,7 +512,7 @@ Object setInheritableStd(@SuppressWarnings("unused") int fd, @SuppressWarnings("
512
512
@ Specialization (guards = "fd > 2" )
513
513
Object setInheritable (int fd , @ SuppressWarnings ("unused" ) Object inheritable ) {
514
514
String path = getResources ().getFilePath (fd );
515
- TruffleFile f = getContext ().getEnv ().getTruffleFile (path );
515
+ TruffleFile f = getContext ().getEnv ().getPublicTruffleFile (path );
516
516
if (!f .exists ()) {
517
517
throw raise (OSError , "No such file or directory: '%s'" , path );
518
518
}
@@ -566,7 +566,7 @@ long fileTimeToSeconds(FileTime t) {
566
566
567
567
@ TruffleBoundary
568
568
Object stat (String path , boolean followSymlinks ) {
569
- TruffleFile f = getContext ().getEnv (). getTruffleFile ( path );
569
+ TruffleFile f = getContext ().getPublicTruffleFileRelaxed ( path , PythonLanguage . DEFAULT_PYTHON_EXTENSIONS );
570
570
LinkOption [] linkOptions = followSymlinks ? new LinkOption [0 ] : new LinkOption []{LinkOption .NOFOLLOW_LINKS };
571
571
try {
572
572
return unixStat (f , linkOptions );
@@ -818,7 +818,7 @@ public abstract static class ListdirNode extends PythonBuiltinNode {
818
818
Object listdir (VirtualFrame frame , String path ,
819
819
@ Cached PRaiseOSErrorNode raiseOS ) {
820
820
try {
821
- TruffleFile file = getContext ().getEnv (). getTruffleFile ( path );
821
+ TruffleFile file = getContext ().getPublicTruffleFileRelaxed ( path , PythonLanguage . DEFAULT_PYTHON_EXTENSIONS );
822
822
Collection <TruffleFile > listFiles = file .list ();
823
823
Object [] filenames = listToArray (listFiles );
824
824
return factory ().createList (filenames );
@@ -852,7 +852,7 @@ public abstract static class ScandirIterNode extends PythonBinaryBuiltinNode {
852
852
@ Specialization
853
853
Object doit (LazyPythonClass cls , String path ) {
854
854
try {
855
- TruffleFile file = getContext ().getEnv ().getTruffleFile (path );
855
+ TruffleFile file = getContext ().getEnv ().getPublicTruffleFile (path );
856
856
return factory ().createScandirIterator (cls , path , file .newDirectoryStream ());
857
857
} catch (SecurityException | IOException e ) {
858
858
gotException .enter ();
@@ -870,7 +870,7 @@ public abstract static class DirEntryNode extends PythonTernaryBuiltinNode {
870
870
@ Specialization
871
871
Object doit (LazyPythonClass cls , String name , String path ) {
872
872
try {
873
- TruffleFile dir = getContext ().getEnv ().getTruffleFile (path );
873
+ TruffleFile dir = getContext ().getEnv ().getPublicTruffleFile (path );
874
874
TruffleFile file = dir .resolve (name );
875
875
return factory ().createDirEntry (cls , name , file );
876
876
} catch (SecurityException | InvalidPathException e ) {
@@ -921,7 +921,7 @@ Object open(VirtualFrame frame, String pathname, int flags, @SuppressWarnings("u
921
921
Object open (VirtualFrame frame , String pathname , int flags , int fileMode , @ SuppressWarnings ("unused" ) PNone dir_fd ) {
922
922
Set <StandardOpenOption > options = flagsToOptions (flags );
923
923
FileAttribute <Set <PosixFilePermission >>[] attributes = modeToAttributes (fileMode );
924
- TruffleFile truffleFile = getContext ().getEnv (). getTruffleFile ( pathname );
924
+ TruffleFile truffleFile = getContext ().getPublicTruffleFileRelaxed ( pathname , PythonLanguage . DEFAULT_PYTHON_EXTENSIONS );
925
925
try {
926
926
SeekableByteChannel fc = truffleFile .newByteChannel (options , attributes );
927
927
return getResources ().open (truffleFile , fc );
@@ -1098,7 +1098,7 @@ public abstract static class UnlinkNode extends PythonFileNode {
1098
1098
@ Specialization
1099
1099
Object unlink (String path ) {
1100
1100
try {
1101
- getContext ().getEnv ().getTruffleFile (path ).delete ();
1101
+ getContext ().getEnv ().getPublicTruffleFile (path ).delete ();
1102
1102
} catch (RuntimeException | IOException e ) {
1103
1103
gotException .enter ();
1104
1104
throw raise (OSError , e );
@@ -1112,7 +1112,7 @@ Object unlink(VirtualFrame frame, Object pathLike,
1112
1112
@ Cached CastToStringNode castToStringNode ) {
1113
1113
try {
1114
1114
Object fsPathObj = callFspathNode .executeObject (frame , pathLike );
1115
- getContext ().getEnv ().getTruffleFile (castToStringNode .execute (frame , fsPathObj )).delete ();
1115
+ getContext ().getEnv ().getPublicTruffleFile (castToStringNode .execute (frame , fsPathObj )).delete ();
1116
1116
} catch (RuntimeException | IOException e ) {
1117
1117
gotException .enter ();
1118
1118
throw raise (OSError , e );
@@ -1149,7 +1149,7 @@ Object mkdir(VirtualFrame frame, String path, @SuppressWarnings("unused") PNone
1149
1149
@ Specialization
1150
1150
Object mkdir (VirtualFrame frame , String path , @ SuppressWarnings ("unused" ) int mode , @ SuppressWarnings ("unused" ) PNone dirFd ) {
1151
1151
try {
1152
- getContext ().getEnv ().getTruffleFile (path ).createDirectory ();
1152
+ getContext ().getEnv ().getPublicTruffleFile (path ).createDirectory ();
1153
1153
} catch (FileAlreadyExistsException e ) {
1154
1154
throw raiseOSError (frame , OSErrorEnum .EEXIST , path );
1155
1155
} catch (RuntimeException | IOException e ) {
@@ -1304,7 +1304,7 @@ Object chmod(String path, long mode, @SuppressWarnings("unused") PNone dir_fd, @
1304
1304
Object chmod (String path , long mode , @ SuppressWarnings ("unused" ) PNone dir_fd , boolean follow_symlinks ) {
1305
1305
Set <PosixFilePermission > permissions = modeToPermissions (mode );
1306
1306
try {
1307
- TruffleFile truffleFile = getContext ().getEnv ().getTruffleFile (path );
1307
+ TruffleFile truffleFile = getContext ().getEnv ().getPublicTruffleFile (path );
1308
1308
if (!follow_symlinks ) {
1309
1309
truffleFile = truffleFile .getCanonicalFile (LinkOption .NOFOLLOW_LINKS );
1310
1310
} else {
@@ -1447,7 +1447,7 @@ private void setAtime(TruffleFile truffleFile, long mtime) {
1447
1447
}
1448
1448
1449
1449
private TruffleFile getFile (String path , boolean followSymlinks ) {
1450
- TruffleFile truffleFile = getContext ().getEnv ().getTruffleFile (path );
1450
+ TruffleFile truffleFile = getContext ().getEnv ().getPublicTruffleFile (path );
1451
1451
if (!followSymlinks ) {
1452
1452
try {
1453
1453
truffleFile = truffleFile .getCanonicalFile (LinkOption .NOFOLLOW_LINKS );
@@ -1687,11 +1687,11 @@ Object rename(VirtualFrame frame, Object src, Object dst, @SuppressWarnings("unu
1687
1687
1688
1688
private Object rename (String src , String dst ) {
1689
1689
try {
1690
- TruffleFile dstFile = getContext ().getEnv ().getTruffleFile (dst );
1690
+ TruffleFile dstFile = getContext ().getEnv ().getPublicTruffleFile (dst );
1691
1691
if (dstFile .isDirectory ()) {
1692
1692
throw raise (OSError , "%s is a directory" , dst );
1693
1693
}
1694
- TruffleFile file = getContext ().getEnv ().getTruffleFile (src );
1694
+ TruffleFile file = getContext ().getEnv ().getPublicTruffleFile (src );
1695
1695
file .move (dstFile , StandardCopyOption .REPLACE_EXISTING , StandardCopyOption .ATOMIC_MOVE );
1696
1696
return PNone .NONE ;
1697
1697
} catch (IOException e ) {
@@ -1780,7 +1780,7 @@ boolean access(String path, int mode, Object dirFd, boolean effectiveIds, boolea
1780
1780
notImplementedBranch .enter ();
1781
1781
throw raise (NotImplementedError );
1782
1782
}
1783
- TruffleFile f = getContext ().getEnv ().getTruffleFile (path );
1783
+ TruffleFile f = getContext ().getEnv ().getPublicTruffleFile (path );
1784
1784
LinkOption [] linkOptions = followSymlinks ? new LinkOption [0 ] : new LinkOption []{LinkOption .NOFOLLOW_LINKS };
1785
1785
if (!f .exists (linkOptions )) {
1786
1786
return false ;
@@ -1933,7 +1933,7 @@ String readlinkPString(PString str, PNone none) {
1933
1933
@ Specialization
1934
1934
String readlink (String str , @ SuppressWarnings ("unused" ) PNone none ) {
1935
1935
try {
1936
- return getContext ().getEnv ().getTruffleFile (str ).getCanonicalFile ().getPath ();
1936
+ return getContext ().getEnv ().getPublicTruffleFile (str ).getCanonicalFile ().getPath ();
1937
1937
} catch (IOException e ) {
1938
1938
throw raise (OSError , e );
1939
1939
}
0 commit comments