Advertisement
SteveGarman

DroidScript isPlugin function

Aug 1st, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // DroidScript
  2. // Check if a file has the structure of a plugin
  3.  
  4. var fil = "/storage/9016-4EF8/Download20160702/FileManager.zip";
  5. //fil="/storage/9016-4EF8/Download20160702/3Dumb.zip";
  6. function OnStart()
  7. {
  8.      var msg ="Invalid Plugin";
  9.      if(isPlugin( fil )) msg = "Looks OK"
  10.      app.ShowPopup( msg );
  11. }
  12.  
  13. function isPlugin(fil)
  14. {
  15.     return isPluginZip(fil) || isPluginApk(fil);
  16. }
  17.  
  18. function isPluginApk(fil)
  19. {
  20.    var temp = fil.split("/").pop();
  21.    if(temp.slice(-4)!=".apk") return false;
  22.    var plugName = temp.slice(0,-4);
  23.    var zip = app.CreateZipUtil(  );
  24.    zip.Open( fil );
  25.    var lst = zip.List( "/" ).split(",");
  26.    if(lst.indexOf("classes.dex")==-1) return false;
  27.    lst = zip.List( "/assets/" ).split(",");
  28.    if(lst.indexOf(plugName+".inc")==-1) return false;
  29.     if(lst.indexOf(plugName+".html")==-1) return false;
  30.    return true;
  31. }
  32.  
  33. function isPluginZip(fil)
  34. {
  35.    var temp = fil.split("/").pop();
  36.    if(temp.slice(-4)!=".zip") return false;
  37.    var plugName = temp.slice(0,-4);
  38.    var zip = app.CreateZipUtil(  );
  39.    zip.Open( fil );
  40.    var lst = zip.List( "/" ).split(",");
  41.    if(lst.indexOf(plugName+".jar")==-1) return false;
  42.    if(lst.indexOf(plugName+".inc")==-1) return false;
  43.     if(lst.indexOf(plugName+".html")==-1) return false;
  44.    return true;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement