appdata.listDir.js 847 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. //List all files within the UnitTest backend example library
  10. var backendExamples = appdata.listDir("UnitTest/backend/");
  11. //Check if there are any error for reading the file
  12. if (backendExamples == false){
  13. sendJSONResp(JSON.stringify({
  14. error: "Unable to list backend example library"
  15. }));
  16. }else{
  17. //Success. Return the file list of the folder
  18. sendJSONResp(backendExamples);
  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. }