appdata.readFile.js 877 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. appdata.readFile.js
  3. This script test the appdata read file function.
  4. This should be able to read file
  5. */
  6. //Require the appdata library
  7. var succ = requirelib("appdata");
  8. function main(){
  9. //Get a file from the UnitTest WebApp. This path is relative from the web root
  10. var webAppDataFileContent = appdata.readFile("UnitTest/appdata.txt");
  11. //Check if there are any error for reading the file
  12. if (webAppDataFileContent == false){
  13. sendJSONResp(JSON.stringify({
  14. error: "Unable to get appdata from app folder"
  15. }));
  16. }else{
  17. //Success. Return the content of the file
  18. sendResp(webAppDataFileContent)
  19. }
  20. }
  21. if (!succ){
  22. //Library include failed.
  23. sendResp("Include Appdata lib failed. Is your ArozOS version too old?")
  24. }else{
  25. //Library include succeed. Start reading from webroot
  26. main();
  27. }