Skip to content

Instantly share code, notes, and snippets.

@QGao
Created December 6, 2011 01:07
Show Gist options
  • Save QGao/1436206 to your computer and use it in GitHub Desktop.
Save QGao/1436206 to your computer and use it in GitHub Desktop.
A sample shows how to set the "DO NOT BACKUP" flag in TiSDK
var newDir = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'mydir');
Ti.API.info("Created mydir: " + newDir.createDirectory());
Ti.API.info('newdir ' + newDir);
var newFile = Titanium.Filesystem.getFile(newDir.nativePath,'backup.txt');
if(newFile.exists()){
newFile.write("I should be backed up!");
newFile.remoteBackup = true;
//or we can set the whole folder to be iCloudable
//newDir.remoteBackup = true;
}
var newFile2 = Titanium.Filesystem.getFile(newDir.nativePath,'dontbackup.txt');
if(newFile2.exists()){
newFile2.write("I should NOT be backed up!");
newFile2.remoteBackup = false;
}
//-------------------------------------
//Test from your console
//-------------------------------------
// cd to your current directory
// xattr -p -x "com.apple.MobileBackup" *
// Output: backup.tex should return "00" and dontbackup.txt return "01"
var newDir = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'mydir');
Ti.API.info("Created mydir: " + newDir.createDirectory());
Ti.API.info('newdir ' + newDir);
var newFile = Titanium.Filesystem.getFile(newDir.nativePath,'backup.txt');
if(newFile.exists()){
newFile.write("I should be backed up!");
newFile.remoteBackup = true;
//or we can set the whole folder to be iCloudable
//newDir.remoteBackup = true;
}
var newFile2 = Titanium.Filesystem.getFile(newDir.nativePath,'dontbackup.txt');
if(newFile2.exists()){
newFile2.write("I should NOT be backed up!");
newFile2.remoteBackup = false;
}
//-------------------------------------
//Test from your console
//-------------------------------------
// cd to your current directory
// xattr -p -x "com.apple.MobileBackup" *
// Output: backup.tex should return "00" and dontbackup.txt return "01"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment