By default we return directories with a / already there. It looks like 
you're adding an extra / and iOS is very sensitive to those things.

On Sunday, May 9, 2021 at 4:19:06 PM UTC+3 P5music wrote:

> My app is being tested on the iOS simulator.
>
> It writes some files in the private folder by means of this method:
>
>     public void writeFile() throws IOException {
>     try(OutputStream os = FileSystemStorage.getInstance
> ().openOutputStream(Utils.getRootPath()+DATA_FILE);) 
>     {
>     os.write(JSONText.getBytes("UTF-8"));
>     os.flush();
>     os.close();
>     } catch(IOException err) {
>     System.out.println("exception trying to write");
>     }
>     }
>
> It works on the CN simulator (writes inside the .cn1/ folder)
> but on iOS the exception is catched.
>
> Below is the method to get the root path
> public static String getRootPath()
> {
> String documentsRoot=FileSystemStorage.getInstance().getRoots()[0];
> String os=Display.getInstance().getPlatformName();
>
> if (os.toLowerCase().contains("ios")) {
>
> int pos=documentsRoot.lastIndexOf("Documents");
> if (pos==-1) return documentsRoot+"/";
> String libraryRoot=documentsRoot.substring(0,pos)+"Library";
> String result=libraryRoot+"/";
>
> return result;
> }
>
> The CN version of my app has to write those private files in the same 
> location as the swift version, that is Library.
> So the string
>
> file:///Users/mac/Library/Developer/CoreSimulator/Devices/alphanumeric-string/data/Containers/Data/Application/another-alphanumeric-string/Documents/
> is transformed and
> the getRootPath() method returns
>
> file:///Users/mac/Library/Developer/CoreSimulator/Devices/alphanumeric-string/data/Containers/Data/Application/another-alphanumeric-string/Library/
> But there is exception.
>
> Furthermore, at some point after the writing attempt, I see in the 
> console output something I think is relevant:
> Failed to create directory 
> /Users/mac/Library/Developer/CoreSimulator/Devices/alphanumeric-string
> /data/Containers/Data/Application/another-alphanumeric-string
> /Documents/cn1storage/
>
> What is this? Is it related to my problem? How to fix it?
> Thanks in advance
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/11f54a50-63b0-43a5-a979-362e7682a183n%40googlegroups.com.

Reply via email to