[Resolved] File sharing under iOS

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post by VertPingouin »

Sorry for the mess in my post ! I'll try to clarify this a bit :

1.
If you can read and write data to the Documents directory, then everything is accomplished, no? What's the problem / what are you triyng to do now?
Yes it is. But there must be something I miss here. After making the appdata folder point to the document folder, how do I access it from my love project ? For now, I'm looking for xml files within my love folder so with an relative path, something like this :

Code: Select all

    local xd = xml:new("levels/"..name..".xml")
What does my file path become then ?

2.

Code: Select all

no, you shouldn't (need to) hardcode the ID et cetera.
I know, especially because I can't know the id before the app is installed but how do I get the documents path by code ?
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post by VertPingouin »

Yes it is. But there must be something I miss here. After making the appdata folder point to the document folder, how do I access it from my love project ? For now, I'm looking for xml files within my love folder so with an relative path, something like
Yes, I was just missing love.filesystem.getAppdataDirectory(), that was pretty obvious !
About the document folder, I just did this in my love project :

Code: Select all

local d = love.filesystem.getAppdataDirectory()
documents = '/var/mobile/Containers/Data/Application/'..split(d,'/')[5]..'/Documents/'
for i,f in ipairs(love.filesystem.getDirectoryItems(documents)) do
  print(f)
end
So I got a document path like this :
/var/mobile/Containers/Data/Application/74B84D21-DB70-4DF0-BCFA-30E19A0DED56/Documents/
but, there is no item in it. A lovE.filesystem.isDirectory returns False, and I failed to read any of my xml put in itunes.

So there is two possibility :
- either my document path is not good at all and, in this case I'm missing an answer to my question 2 from my previous post
- either the folder is not accessible at all from love code and the topic end here...
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: File sharing under iOS

Post by s-ol »

VertPingouin wrote:
Yes it is. But there must be something I miss here. After making the appdata folder point to the document folder, how do I access it from my love project ? For now, I'm looking for xml files within my love folder so with an relative path, something like
Yes, I was just missing love.filesystem.getAppdataDirectory(), that was pretty obvious !
About the document folder, I just did this in my love project :

Code: Select all

local d = love.filesystem.getAppdataDirectory()
documents = '/var/mobile/Containers/Data/Application/'..split(d,'/')[5]..'/Documents/'
for i,f in ipairs(love.filesystem.getDirectoryItems(documents)) do
  print(f)
end
So I got a document path like this :
/var/mobile/Containers/Data/Application/74B84D21-DB70-4DF0-BCFA-30E19A0DED56/Documents/
but, there is no item in it. A lovE.filesystem.isDirectory returns False, and I failed to read any of my xml put in itunes.

So there is two possibility :
- either my document path is not good at all and, in this case I'm missing an answer to my question 2 from my previous post
- either the folder is not accessible at all from love code and the topic end here...
no, no, no, no. love.filesystem.isDirectory etc are all relative to the Appdata directory already! Usually, on unix they go into °/home/USER/.love/IDENTITY/". You should change the love code so that the default path is "/var/mobile/Containers/Data/Application/74B84D21-DB70-4DF0-BCFA-30E19A0DED56/Documents/". Then "love.filesystem.getDirectoryItems(".")" will show all the files and you can use lf.read, lf.write etc. to access all the data.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post by VertPingouin »

At last !
I just replaced this
by

Code: Select all

appdata = normalize(Filesystem::getUserDirectory() + "/Documents/");
And change commented save_identity
here so I don't have to put file in appname folder.

I put my xml in itunes then I just have to get them in root directory !

@s-ol : thank you so much for your patience ! I could have understood this quicker if only I read the love.filesystem wiki carefuly...
Thank you a thousand times !
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Bobble68, Google [Bot] and 7 guests