I am trying to write a file to a directory within the WWW directory of my Cordova app.
Here is the situation:
My program saves an image to the temporary directory
I want the program to move the image from the temporary directory to the WWW directory, so that the file does not get deleted every time the app is initialized.
Is this possible?
Thanks.
No that's not possible. The WWW is sandboxed and therefore, you can't write anything inside of this folder. If you want to save a file you need to use the DOCUMENTS path and rely on the Cordova file plugin (PERSISTENT is the keyword)
https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md
You can also check the folder permissions here:
https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md#ios-file-system-layout
As you can see, www is read-only (not r/w)
Related
I'm creating a portable Electron app that writes some files to the program folder. It works pretty well when I package it without the --asar option in Electron-packager, which leaves the resources folder with plain html + js files.
Now when I try to compile it with the --asar option, so that it packages the resources folder into one file, I can't access the program directory any more with the following code:
remote.app.getAppPath()
This now returns the path of the asar file, so I can't really write to the application folder any more. Is there any way around this?
No, you cannot modify the asar of a running Electron app. You should be saving your config outside of the asar path.
i want to copy some files to the app's tmp directory when the xcode package the app , so when the user install the app , the files is be put in the tmp directory already , but in xcode 's copy bundle resources , the files can't be copied to the tmp directy , is there anyway to achive this?
From your question, I understand that you're trying to make several files be put in the tmp directory at app install time.
Unfortunately, that is not possible. The iOS creates 3 containers upon an app installation as mentioned here.
Bundle Container: This is where the app gets installed
Data Container: Creates 3 separate folders where the app can store data
iCloud Container: Where iCloud specific data can be saved
Workaround
You can simply check every time the app launches to see if it's the first time the app launches and manually copy the files to your destination. You can use a Boolean in your app's NSUserDefaults to check whether the app was installed before.
I have a Grails application in which I generate PDF/Excel files in a folder.
My problem is, everytime I need to change the directory path through code when I test or run the code on different machines like Windows, Linux, Mac.
So what is the generic path, which will be applicable for any/all platforms as the default temp directory, so that I won't need to manually set path for the directory while running code on different machines/platforms.
The temp directory is available via
String tempDir = System.getProperty('java.io.tmpdir')
To create temp files in the default location for the OS you can use File.createTempFile(prefix,suffix)
I'm new to the downloading process in iOS .. I would like to know how to download a file (.sqlite file) from server and overwrite the previous one which is already in the bundle.
Do I have to copy the old sqlite file to the app documents folder so that I can overwrite it? And if I copy it to the documents folder can anyone access it or is it protected?
Anything stored in the application bundle is read-only, so yes you will have to copy your .sqlite file into the Documents/ directory first. Then when you download a new version, you can overwrite the original version in the Documents/ directory.
And the Documents/ directory is part of the iOS application sandbox, so only your application will be able to read/write from/to here.
I'm currently building an app for jailbroken device, and I need root privileges for my app so that I can perform some tasks ask root. I found a related question : Gaining root permissions on iOS for NSFileManager (Jailbreak). But I am really new to iOS, I don't understand and unable to complete task from step 4. Can anyone make it more detail please?
What step 4 is telling you:
Open the original executable file and delete its contents (the contents are now stored in the previously copied and renamed binary).
is simply that you have moved the executable file for your app to a new filename, and you should replace it with a script with the name of the original executable.
Example
If you build an app named HelloWorld, Xcode will create a HelloWorld.app directory, with a file named HelloWorld inside it, which is executable.
The answer you link to suggests basically renaming the executable to something like MobileHelloWorld.
Once you've done that, create a new file in the HelloWorld.app directory called HelloWorld, and edit it with a text editor to give it this content:
#!/bin/bash
dir=$(dirname "$0")
exec "${dir}"/MobileHelloWorld "$#"
That script will then be run when you tap the app's icon, because in the app's Info.plist file, the name of the executable is
<key>CFBundleExecutable</key>
<string>HelloWorld</string>
and HelloWorld is now a shell script, which invokes MobileHelloWorld, the renamed binary executable file.