-
-
Save kriskowal/279108 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
application.end = function(){ | |
sys.puts('application end'); | |
application.saveState(true); | |
}; | |
application.saveState = function(shutdown){ | |
sys.puts('application saveState'); | |
//dump data.json into application state | |
var mode = 0444; | |
var x = posix.open(application.dataPath ,process.O_RDWR|process.O_TRUNC,0444).addCallback(function(fd){ | |
sys.puts('opening : ' + application.dataPath); | |
/* open and write */ | |
posix.write( fd, 'application.data = ' + JSON.stringify( application.data ) + ';' ).addCallback(function(){ | |
sys.puts('application state serialized and stored in : ' + application.dataPath); | |
posix.close(fd).addCallback(function () { | |
if (shutdown) { | |
process.exit(); | |
} | |
}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment