[OSX] UnauthorizedAccessException at ES3.LoadRawString

Discussion and help for Easy Save 3
Post Reply
fur
Posts: 9
Joined: Fri Jul 28, 2017 6:12 am

[OSX] UnauthorizedAccessException at ES3.LoadRawString

Post by fur »

When I try to use ES3.LoadRawString to read a file from a subfolder StreamingAssets folder, I got this error:

Code: Select all

UnauthorizedAccessException: Access to the path "/private/var/folders/sn/p7zy4k013sddkp0sdbttp1j40000gn/T/AppTranslocation/ED19FB83-0355-4F3A-81B1-531EAE35CCCD/d/Block42.app/Contents/Resources/Data/StreamingAssets/MyGame/Category/" is denied.
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <00000000000000000000000000000000>:0 
  at ES3Internal.ES3FileStream.GetPath (System.String path, ES3Internal.ES3FileMode fileMode) [0x00000] in <00000000000000000000000000000000>:0 
  at ES3Internal.ES3FileStream..ctor (System.String path, ES3Internal.ES3FileMode fileMode, System.Int32 bufferSize, System.Boolean useAsync) [0x00000] in <00000000000000000000000000000000>:0 
  at ES3Internal.ES3Stream.CreateStream (ES3Settings settings, ES3Internal.ES3FileMode fileMode) [0x00000] in <00000000000000000000000000000000>:0 
  at ES3.LoadRawBytes (ES3Settings settings) [0x00000] in <00000000000000000000000000000000>:0 
  at ES3.LoadRawString (ES3Settings settings) [0x00000] in <00000000000000000000000000000000>:0 
  at Block42.ModelEditor.ModelEditorModellingManager.LoadDataFromFile (Block42.Block42ModelBundle modelBundle) [0x00000] in <00000000000000000000000000000000>:0 
  at Block42.ModelEditor.ModelEditorModellingManager+<LoadModelCoroutine>d__68.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 
 
(Filename: currently not available on il2cpp Line: -1)
I'm not 100% sure how OSX works, but I assume when you access StreamingAssets, OSX actually assign you a random symlink path and you cannot write/create anything in the path, but at line 22 of ES3FileStream.cs, you are trying to create a directory, which causes this exception:

Code: Select all

if(directoryPath != UnityEngine.Application.persistentDataPath)
  ES3IO.CreateDirectory(directoryPath);
It seems to be that you shouldn't create a directory for just reading a file, so I modified the line to:

Code: Select all

if(fileMode != ES3FileMode.Read && directoryPath != UnityEngine.Application.persistentDataPath)
  ES3IO.CreateDirectory(directoryPath);

Using:
Unity 2018.4.15f
macOS 10.15.2 Catalina
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: [OSX] UnauthorizedAccessException at ES3.LoadRawString

Post by Joel »

Hi there,

Well spotted, thanks for the detailed info. Judging by our repo it looks like this was changed in the last update when we were adjusting how temporary files were created, but the ES3FileMode.Read check wasn't put back in.

I'll make sure this is fixed in the upcoming update.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply