Created
June 15, 2016 20:51
-
-
Save hansemannn/496308a44dcbeffb8ecf1973a69246bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var useBackup = false; | |
var win = Ti.UI.createWindow({ | |
backgroundColor : "#fff" | |
}); | |
var btn = Ti.UI.createButton({ | |
title : "Toggle remote backhup" | |
}); | |
var dir = Ti.Filesystem.getFile("test"); | |
if (!dir.exists()) { | |
Ti.API.info("Recursive directory does not exist, yet"); | |
var newDir = dir.createDirectory(); | |
if (!newDir) { | |
Ti.API.error("Root directory could not be created"); | |
} else { | |
for (var i = 0; i < 20; i++) { | |
var tmp = Ti.Filesystem.getFile(dir.nativePath, "subDirectory-" + i); | |
if (!tmp.createDirectory()) { | |
Ti.API.error("Subdirectory " + i + " could not be created!"); | |
} | |
} | |
var newFile = Ti.Filesystem.getFile(dir.nativePath, "file.txt"); | |
if (!newFile.createFile()) { | |
Ti.API.error("File could not be created!"); | |
} | |
} | |
} else { | |
Ti.API.info("Recursive directory already exists"); | |
} | |
Ti.API.warn(dir.nativePath); | |
btn.addEventListener("click", function() { | |
useBackup = !useBackup; | |
dir.setRemoteBackup(useBackup); | |
}); | |
win.add(btn); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment