appdata.listDir.js 838 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. appdata.listDir.js
  3. This script test the appdata list dir function.
  4. */
  5. //Require the appdata library
  6. var succ = requirelib("appdata");
  7. function main(){
  8. //List all files within the UnitTest backend example library
  9. var backendExamples = appdata.listDir("UnitTest/backend/");
  10. //Check if there are any error for reading the file
  11. if (backendExamples == false){
  12. sendJSONResp(JSON.stringify({
  13. error: "Unable to list backend example library"
  14. }));
  15. }else{
  16. //Success. Return the file list of the folder
  17. sendJSONResp(backendExamples);
  18. }
  19. }
  20. if (!succ){
  21. //Library include failed.
  22. sendResp("Include Appdata lib failed. Is your ArozOS version too old?")
  23. }else{
  24. //Library include succeed. Start reading from webroot
  25. main();
  26. }