Unsolved Is Qt support autosave API for sandbox application [OSX] ?
-
For OSX, the sandbox application can't save files (except special temporary folders) if the user does not initiate that (through save dialog).
It might be a problem in two cases:- if you want to implement autosave functionality
- if you want to implement safe save (save to another file then rename it to original).
For these cases (as far I know), OSX propose use containers (autosavesInPlace(), autosavedContentsFileURL() and similar low-level API).
Is Qt has hight level API for use that feature?
-
Hi,
For such highly OS specific stuff, no.
However, what about requesting a temporary folder within the sandbox to store the file ?
-
The problem not in keep file in a temporary folder (for the sandbox application it is allowable).
The problem is: correctly save user file to avoid damage it.
I.e. for example:
The user saves file "documents/aaa.txt". When the application "decides" make autosave, it should create (for example) file in "documents/aaa.txt.autosave". Save data. And then rename it to "documents/aaa.txt"If something happens with the application during the save file it will help protect the original file from the damage.
Honestly speaking I have not figured it out yet how to native autosave API work on OSX and thought Qt have hight level API for that. But looks like I should investigate native OSX API deeply. :-)
-
-
@faiszalkhan
Nice example but I think poster wants to save to something special on OSX. -
Sorry for pick up this theme again, but I just investigated Qt documentation and found that QSaveFile do that functionality.
From the documentation:
"QSaveFile is an I/O device for writing text and binary files, without losing existing data if the writing operation fails.
While writing, the contents will be written to a temporary file, and if no error happened, commit() will move it to the final file. This ensures that no data at the final file is lost in case an error happens while writing, and no partially-written file is ever present at the final location. Always use QSaveFile when saving entire documents to disk."
Hm... It will work on OSX (for sandbox application) or I miss something?
UPDATE:
QSaveFile - didn't work for sandbox application :-(