Update Storage without Removing Content
2 min
If you want update your applications, but don't want to wipe out the local storage files, content, registration keys, etc. on your microSD card, create a separate folder on the destination drive to receive those files.
For example:
- Use a script like the one below to create a folder where you can unzip the updated files.
- Delete the files that you want to replace in their respective folder(s).
- Copy or move the updated files to the correct folder. You can use scripts to move multiple files to the SD card folder, as shown in the example below.
- The main zip file that you download can contain other zip files. So you could unzip the main file, and then do targeted unzips to replace selected files.
path$="SD:/" 'USB1, SSD2, SD2
CreateDirectory(path$+"Update") 'unzipping here
package = CreateObject("roBrightPackage", path$+"autorun.zip")
package.Unpack(path$+"Update")Example
To copy everything from an “Update” folder to a “Myapplication” folder, do the following:
Copyroot("Update", "Myapplication")
Sub copyroot(path$ as string, Target$ as String)
mylist = listdir(path$)
For each item in mylist
if instr(1, item, ".") > 0 then
print "found a file: "; item
print "path: "; path$
CopyFile(path$+"\"+item, Target$+"\"+item)
else
print "found folder: " ;item
CreateDirectory(Target$+"\"+item)
copytree("\"+item)
endif
next
end Sub
Sub Copytree(path$ as string)
print "copy tree: "; path$
'e.g. \pool
mylistb = listdir("\Update"+path$)
print mylistb
For each item in mylistb
print len(item)
if instr(1, item, ".") > 0 then CopyFile("\Update"+path$+"\"+item, Target$+path$)
if len(item) > 1 then
print "copying sha file: "; Target$+path$+"\"+item
showstatus("copying file: "+ Target$+path$+"\"+item)
CopyFile("\Update"+path$+"\"+item, Target$+path$+"\"+item) 'folders only 1 digit long outside root ?
else
print "found sub folder: "; path$+"\"+item
CreateDirectory(Target$+path$+"\"+item)
copytree(path$+"\"+item)
endif
next