@@ -58,7 +58,7 @@ class FileUtil
5858 */
5959 public static var PROTECTED_PATHS (get , never ): Array <String >;
6060
61- public static function get_PROTECTED_PATHS (): Array <String >
61+ static function get_PROTECTED_PATHS (): Array <String >
6262 {
6363 final protected : Array <String > = [
6464 ' ' ,
@@ -83,7 +83,8 @@ class FileUtil
8383 #if sys
8484 for (i in 0 ... protected .length )
8585 {
86- protected [i ] = sys. FileSystem .fullPath (Path .join ([gameDirectory , protected [i ]]));
86+ // On Linux 'fullPath' just makes most of these null which actually just makes the paths unprotected
87+ protected [i ] = #if !linux sys. FileSystem .fullPath #end (Path .join ([gameDirectory , protected [i ]]));
8788 }
8889 #end
8990
@@ -1306,8 +1307,26 @@ class FileUtilSandboxed
13061307
13071308 #if sys
13081309 // TODO: figure out how to get "real" path of symlinked paths
1309- final realPath : String = sys. FileSystem .fullPath (Path .join ([FileUtil .gameDirectory , sanitized .join (' /' )]));
1310- if (! realPath .startsWith (FileUtil .gameDirectory ))
1310+ #if linux
1311+ // The implementation on Linux fails if the path doesn't exist
1312+ var realPath : Null <String > = null ;
1313+ var unresolvedSegments : Array <String > = [];
1314+ while (realPath == null && sanitized .length > 0 )
1315+ {
1316+ realPath = sys. FileSystem .fullPath (Path .join ([FileUtil .gameDirectory ].concat (sanitized )));
1317+ if (realPath == null ) unresolvedSegments .unshift (sanitized .pop () ?? continue );
1318+ }
1319+
1320+ if (unresolvedSegments .length > 0 )
1321+ {
1322+ if (realPath != null ) unresolvedSegments .unshift (realPath );
1323+ realPath = Path .join (unresolvedSegments );
1324+ }
1325+ #else
1326+ final realPath : Null <String > = sys. FileSystem .fullPath (Path .join ([FileUtil .gameDirectory ].concat (sanitized )));
1327+ #end
1328+
1329+ if (realPath == null || ! realPath .startsWith (FileUtil .gameDirectory ))
13111330 {
13121331 return FileUtil .gameDirectory ;
13131332 }
0 commit comments