Page 1 of 1
adding a folder to the documents folder
Posted: Sat Oct 06, 2012 8:33 pm
by jmburnod
Hi All,
It is a new topic as follow "Documents folder is empty"
I want add a folder with subfolders. Subfolders contains snd files, png files and txt files.

DesImagePictos contains a subfolder with 683 png files
DesSonsPictos contains a subfolder with 683 aiff files
Gugliemo suggested me three ways
1. on startup, the first time, you can copy your folder from the "engine" folder into the "document" folder
How can i do this. RevCopy don't work for IOS and it means there are two folder with the same contents one in the document folder and one in the engine folder. I have understood deleting a folder in the engine folder is impossible. I'm right ?
2. you can set the "document sharing" flag and you can access the "document" folder from iTunes
I tried that but i can't add a folder
3. you can trasfer file into the "document" folder from the network (e.g. FTP, Dropbox, ...)
Yes. I can create the directory of the folder and copy file after file from a server to the document folder. I have simulated this on OSX and it spend 28 minutes to do that !
Is there a way to download a zip file and decompressing it in the document folder ?
Thanks at all for help
Jean-Marc
Re: adding a folder to the documents folder
Posted: Sat Oct 06, 2012 9:54 pm
by gpb01
Hi Jean-Mark,
1. "
... I have understood deleting a folder in the engine folder is impossible. I'm right ?" : YES, "engine" folder is READ ONLY so, you can create your folder structure where you want, you can copy your files (get URL ... & put URL ...) but you CAN'T delete them from the "engine" folder
2. "
... I tried that but i can't add a folder" : TRUE, you can add only the files, but after, from program, you can rearrange
3. "
... Is there a way to download a zip file and decompressing it in the document folder ?" : YES, is what I do in some of my programs. I save my compressed files & folders structure in a .zip file, I put the zip on the application dropbox and, retrieved the file in iOS I unzip the structure.
revZip functions work fine on iOS
Guglielmo
Re: adding a folder to the documents folder
Posted: Sat Oct 06, 2012 10:32 pm
by endernafi
Hi Jean-Marc,
You have to find a way to copy your
resources from engine folder to the documents -or any other read/write capable- folder.
This is your responsibility as a developer.
Using some conditional statements and loops, you can handle this easily.
I've attached a stack just to demonstrate an example.
Beware that it's only an example, though it served me well for months.
But it's not optimized and it's good merely for
my needs.
You have to customize it.
Or better, you should write your own code tailored for your needs.
A little help to understand what the stack does:
Put all of your resources into one folder named as
theContent.
Copy it to the engine folder via LiveCode's Copy Pane.
The stack script iterates and enumerates through that folder and copy everything to the documents folder.
You can check later the job in the simulator's local folder
~/Library/Application Support/iPhone Simulator/.
I want to warn one more time, it's far from being optimized and there isn't any explanatory comments,
I actually don't have time for these tasks or maybe I'm too lazy
Hope it helps
Best,
~ Ender Nafi
Re: adding a folder to the documents folder
Posted: Sat Oct 06, 2012 10:56 pm
by jmburnod
Hi Ender,
Thank a lot for reply.
I saw your script and i understand it COPY the content of a folder of the engine folder to the documents folder, but we can't delete this folder of the engine folder. I would like to avoid having two folder with the same contents.
I search a way to have the content in the document folder only.
Best regards
Jean-Marc
Re: adding a folder to the documents folder
Posted: Sun Oct 07, 2012 7:02 am
by jacque
Does the app write changes to the files? If you only need to read the resources, you don't need to move them at all. Just read them from the engine folder.
Be careful that your files are not too large. I think 500 megs is the limit for apps submitted to the App Store, and it will be rejected if it is larger than that.
Re: adding a folder to the documents folder
Posted: Sun Oct 07, 2012 8:08 am
by jmburnod
Hi Jaque,
Thank for reply
Does the app write changes to the files?
Yes. Some files .txt that collect informations about each users but they will be created by the app in the documents folder
If you only need to read the resources, you don't need to move them at all. Just read them from the engine folder.
No. The user should be able to add pictures and sounds from a server to the collections of aiff and png files
I think 500 megs is the limit for apps submitted to the App Store
This app isn't for the applestore but for a "school store"
Best regards
Jean-Marc
Re: adding a folder to the documents folder
Posted: Sun Oct 07, 2012 10:44 pm
by jmburnod
Hi All,
There is a plan to add a folder in the specialfolderpath("documents").
1. Download a zip archive (the names of files are encoding with urlEncode() if there are diacritical chars in their names)
2. Define tPathD in specialfolderpath("documents") and create tPathD folder
3. Open zip: revZipOpenArchive tPathS,read
4. Enumerate items of zip: revZipEnumerateItems(tPathS), list of items (tUnItem)
5. Building the list of names of files
6. Extract items of zip and copy them in documents folder: revZipExtractItemToFile tPathS,tUnItem,tPathD
7. Close zip: revZipCloseArchive tPathS
8. Delete zip: delete file tPathS
Tested on desktop until point 7, not still on device
Comments welcome
Best and thanks at all for help and support
Jean-Marc
Re: adding a folder to the documents folder solved
Posted: Mon Oct 08, 2012 5:39 pm
by jmburnod
Hi All,
The plan explained in my previous post also work on IOS
Many thanks for help and suggestions
Best regards
Jean-Marc
Re: adding a folder to the documents folder
Posted: Wed Oct 10, 2012 4:56 pm
by FireWorx
I know this might be asking a lot but an example stack of this procedure would be very helpful to me.
I would like to have a folder of say 50 or 60 PDF maps sitting on my web server. When a map page is updated it is dropped in the folder on the web server. I would like my IOS app to check for updates and be able to download updated PDF's to a folder in the documents or library folder of my IOS app. Having them zipped would make things even better.
I know enough live code to know this is advanced stuff however hence the demo would be great.
Thanks,
Dave
Re: adding a folder to the documents folder
Posted: Fri Oct 19, 2012 7:21 pm
by jmburnod
Hi All,
After some experiments i think that creating a temporary folder and copy files by "put url("binfile:" & tpathFile) seem the best way.
FireWorx,
The stack of endernafi is very useful.
Have also a look to the tutorials/advanced-zip-tool:
http://www.runrev.com/developers/lesson ... -zip-tool/
Here is the new plan:
1. Download a zip with a .aiff files folder and a .png files folder
2. Extract all items of the zip in a temporary folder
3. Copy the files by "put url("binfile:" & tpathFileSource) into url("binfile:" & tpathFileDest)
4. Delete all files of the temporary folders
5. Delete the temporary folders
I hope i'm coming back soon with a stack...after test and test and ....
Best
Jean-Marc
Re: adding a folder to the documents folder
Posted: Mon Oct 22, 2012 9:54 am
by endernafi
Hello Dave,
I'm attaching a stack which may help.
It's a slightly optimized version of my previous demo stack in this post.
It does 3 things mainly,
* Copies the initial & essential content from engine into the documents folder.
* Checks any updates via a php function, downloads new content and deletes removed/depreciated content.
* Make thumbnails of newly downloaded images.
There isn't much comment but all the names of variables and procedures are self-explanatory.
You have to tweak it for your needs, though.
Hope it helps...
Best,
~ Ender Nafi
Re: adding a folder to the documents folder
Posted: Thu Sep 26, 2024 6:09 pm
by trevix
endernafi wrote: ↑Sat Oct 06, 2012 10:32 pm
Hi Jean-Marc,
You have to find a way to copy your
resources from engine folder to the documents -or any other read/write capable- folder.
This is your responsibility as a developer.
Using some conditional statements and loops, you can handle this easily.
I've attached a stack just to demonstrate an example.
Beware that it's only an example, though it served me well for months.
But it's not optimized and it's good merely for
my needs.
You have to customize it.
Or better, you should write your own code tailored for your needs.
copyInstallationDemo.zip
A little help to understand what the stack does:
Put all of your resources into one folder named as
theContent.
Copy it to the engine folder via LiveCode's Copy Pane.
The stack script iterates and enumerates through that folder and copy everything to the documents folder.
You can check later the job in the simulator's local folder
~/Library/Application Support/iPhone Simulator/.
I want to warn one more time, it's far from being optimized and there isn't any explanatory comments,
I actually don't have time for these tasks or maybe I'm too lazy
Hope it helps
Best,
~ Ender Nafi
Hello Ender Nafi and thanks for your demo stack.
I played with your demo stack "copyInstallationDemo.zip" (adapting it also for OSX Sonoma, LC10 ide) and is working nicely.
But I found something very odd:
In order to implement some error checking, after having done a new "copyInstallation" in OSx, I "locked" on the Finder one of the text file inside the folder (on the target).
From then on, I wasn't able anymore to delete the folder containing the file.
Not manually removing the lock from the file
Not manually deleting the file.
What is even more strange, deleting manually the entire "theContent" folder, restarting the Mac, doing a new install, doing an update, The "clearOldInstallation" command was not able anymore to delete the "folder1" wich once contained the locked file.
We know that a folder cannot be delete if there are files inside, so I even checked the existence of some hidden ".xxx" file (none).
Anybody can explain me this?
Thanks
Re: adding a folder to the documents folder
Posted: Thu Sep 26, 2024 6:14 pm
by trevix
Here is your stack slightly modified, in order to do some test on the IDE (Sonoma LC10RC1)
Re: adding a folder to the documents folder
Posted: Thu Oct 17, 2024 1:54 pm
by trevix
Using the script below, on a slow Android 11 device whereI want to implement the splash screen method, if I copy all files and folders to the document folder and I launch a stack that was copied, the standalone crashes silently. Like as if the copy process wasn't concluded before the launch.
I would avoid putting an arbitrary "wait x seconds with message" before launching the stack (which works in avoiding the crash). The number of seconds would depend on the speed of the device and would be difficult to pin point.
Any suggestions?
Code: Select all
--this function will copy all files and folder to destination
Function CopyFilesFolders pFolder, pTargetPath --recursive
local tCurrentFiles, tFolders
put files(pFolder) into tCurrentFiles
filter tCurrentFiles without ".*"
--breakpoint
if tCurrentFiles is not empty then
ensureFolder pTargetPath --be sure there is a folder
repeat for each line tFile in tCurrentFiles
put URL ("binfile:" & pFolder & slash & tFile) into URL ("binfile:" & pTargetPath & slash & tFile)
end repeat
end if
## Now the recursion
put folders(pFolder) into tFolders
filter tFolders without ".*"
filter tFolders without "..*"
repeat for each line tFolder in tFolders
put pTargetPath & slash & tFolder into tTargetPath
put CopyFilesFolders((pFolder & slash & tFolder), tTargetPath) into tCurrentFiles
end repeat
wait 3 seconds with messages
return true
end CopyFilesFolders
on ensureFolder pFolder --be sure there is a folder, if not create it
if there is a folder pFolder or pFolder is empty then
exit ensureFolder
end if
set the itemDel to "/"
ensureFolder item 1 to -2 of pFolder
create folder pFolder
end ensureFolder