readfile.agi 606 B

12345678910111213141516171819202122
  1. /*
  2. Terminal — Read File Backend
  3. Reads an AGI/JS script from the user's virtual filesystem and
  4. returns its raw text content so the frontend can preview and
  5. optionally execute it.
  6. POST param: path (virtual path, e.g. user:/Desktop/script.agi)
  7. */
  8. requirelib("filelib");
  9. if (!filelib.fileExists(path)) {
  10. sendResp("__ERROR__File not found: " + path);
  11. } else {
  12. var content = filelib.readFile(path);
  13. if (content === false || content === null || content === undefined) {
  14. sendResp("__ERROR__Cannot read file: " + path);
  15. } else {
  16. sendResp(content);
  17. }
  18. }