12345678910111213141516171819202122232425 |
- //Code Studio File writing API
- //Required paramters: filepath, content
- var success = requirelib("filelib");
- if (!success){
- sendJSONResp(JSON.stringify({
- error: "Unable to access filelib"
- }));
- }else{
- if (typeof filepath == "undefined" || typeof content == "undefined"){
- //Missing paramters
- sendJSONResp(JSON.stringify({
- error: "Invalid filename or contents"
- }));
- }else{
- //OK. Write to target directory
- if (filelib.writeFile(filepath, content)){
- sendResp("OK");
- }else{
- sendJSONResp(JSON.stringify({
- error: "Unable to write to file: " + filepath
- }));
- }
- }
- }
|