Created
August 23, 2013 00:31
-
-
Save 7gano/6314333 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fs = require("fs"); | |
var _currentBacking; | |
exports.setCurrentPage = function(backing){ | |
_currentBacking = backing; | |
}; | |
exports.getCurrentPage = function(){ | |
var path = './' + _currentBacking + '/info.json'; | |
var jsonString = fs.readFileSync(path, 'utf8'); | |
var pageInfo = JSON.parse(jsonString); | |
return pageInfo; | |
}; | |
exports.getPaperJSON = function(backing){ | |
var path = './' + _currentBacking + '/' | |
+ backing + '/info.json'; | |
var jsonString = fs.readFileSync(path, 'utf8'); | |
try{ | |
var paperJSON = JSON.parse(jsonString); | |
}catch(e){ | |
console.log(e); | |
} | |
return paperJSON; | |
}; | |
exports.setPaperJSON = function(backing, paperJSON){ | |
var path = './' + _currentBacking + '/' | |
+ backing + '/info.json'; | |
try{ | |
var jsonString = JSON.stringify(paperJSON); | |
}catch(e){ | |
console.log(e); | |
} | |
var fd = fs.openSync(path, "w"); | |
fs.writeSync(fd, jsonString, 0, "utf8"); | |
fs.closeSync(fd); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment