listFiles() private method

private listFiles ( ) : java.io.File[]
return java.io.File[]
        /// <summary>
        /// This Method is a javascript callable method.
        /// </summary>
        /// <param name="e">A parameter from javascript.</param>
        /// <param name="y">A callback to javascript.</param>
        public void listFiles(string dirPath, Action<string> y)
        {
            File f = new File(dirPath);
            File[] files = f.listFiles();


            if (files != null)
                for (int i = 0; i < files.Length; i++)
                {
                    File file = files[i];

                    if (!file.isHidden() && file.canRead())
                    {
                        //path.add(file.getPath());
                        if (file.isDirectory())
                        {
                            y(file.getName() + "/");
                        }
                        else
                        {
                            y(file.getName());
                        }
                    }
                }


         
        }
        private void getDir(string dirPath)
        {
            myPath.setText("Location: " + dirPath);
            item = new ArrayList();
            path = new ArrayList();
            File f = new File(dirPath);
            File[] files = f.listFiles();

            //if (!(root.StringEquals(dirPath)))
            //if (root != dirPath)
            {
                item.add(root);
                path.add(root);
                item.add("../");
                path.add(f.getParent());
            }


            if (files != null)
                for (int i = 0; i < files.Length; i++)
                {
                    File file = files[i];

                    if (!file.isHidden() && file.canRead())
                    {
                        path.add(file.getPath());
                        if (file.isDirectory())
                        {
                            item.add(file.getName() + "/");
                        }
                        else
                        {
                            item.add(file.getName());
                        }
                    }
                }

            var fileList =
              new ArrayAdapter(this, R.layout.row, item);
            //new ArrayAdapter<String>(this, R.layout.row, item);
            setListAdapter(fileList);
        }
Ejemplo n.º 3
0
 public List<string> getUnloadedLevelList()
 {
     List<string> levels = new List<string>();
     File levelList = new File("levels");
     File[] list = levelList.listFiles();
     foreach (File f in list)
     {
         string name = f.getName().Split('.')[0];
         if (name == "properties")
             continue;
         if (getServer().getLevelHandler().findLevel(name) == null)
             levels.Add(name);
     }
     return levels;
 }
        public void File_list(
            string path,
            ystring ydirectory,
            ystring yfile,
            string sskip = "0",
            string stake = "10",
            ystring done = null)
        {
#if Android
            var DIRECTORY_DCIM = global::android.os.Environment.DIRECTORY_DCIM;

            path = global::android.os.Environment.getExternalStoragePublicDirectory(DIRECTORY_DCIM).getAbsolutePath();
            path += "/Camera";

            var f = new File(path);

            //Caused by: java.lang.Runtim
            //eException: Implement IComparable for java.lang.Long vs java.lang.Long
            //       at ScriptCoreLibJava.BCLImplementation.System.Collections.__Comparer.Compare(__Comparer.java:136)

            var a = f.listFiles().Where(k => k.getName().EndsWith(".jpg")).OrderByDescending(k => (double)k.lastModified()).ToArray();

            //foreach (var item in a)
            //{
            //    if (new File(path + "/" + item).isDirectory())
            //        ydirectory(path + "/" + item);
            //}

            int skip = int.Parse(sskip);
            int take = int.Parse(stake);

            foreach (var item in a)
            {
                if (skip > 0)
                {
                    skip--;
                }
                else
                {
                    if (take > 0)
                    {
                        take--;


                        yfile(path + "/" + item.getName());

                    }
                    else
                    {
                        break;
                    }
                }
            }
#endif

            if (done != null)
                done("");
        }
Ejemplo n.º 5
0
    public static void findExtensions(ProgressMonitor monitor, int min, int max)
    {
      monitor.setNote("Loading Extensions");
      File file1 = new File("./extensions");
      File file2 = new File("./lib");
      File file3 = new File("./extensions/lib");
      URLClassLoader urlClassLoader1 = (URLClassLoader) ClassLoader.getSystemClassLoader(FileSniffer.__\u003CGetCallerID\u003E());
      Class class1 = (Class) ClassLiteral<URLClassLoader>.Value;
      Method declaredMethod;
      Exception exception1;
      try
      {
        Class class2 = class1;
        string str = "addURL";
        Class[] classArray = new Class[1];
        int index = 0;
        // ISSUE: variable of the null type
        __Null local = ClassLiteral<URL>.Value;
        classArray[index] = (Class) local;
        CallerID callerId = FileSniffer.__\u003CGetCallerID\u003E();
        declaredMethod = class2.getDeclaredMethod(str, classArray, callerId);
        ((AccessibleObject) declaredMethod).setAccessible(true);
        goto label_6;
      }
      catch (Exception ex)
      {
        int num = 0;
        M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
        if (m0 == null)
          throw;
        else
          exception1 = (Exception) m0;
      }
      Throwable.instancehelper_printStackTrace((Exception) exception1);
      monitor.setProgress(max);
      return;
label_6:
      File[] fileArray1 = new File[3];
      int index1 = 0;
      File file4 = file2;
      fileArray1[index1] = file4;
      int index2 = 1;
      File file5 = file3;
      fileArray1[index2] = file5;
      int index3 = 2;
      File file6 = file1;
      fileArray1[index3] = file6;
      File[] fileArray2 = fileArray1;
      int length1 = fileArray2.Length;
      for (int index4 = 0; index4 < length1; ++index4)
      {
        File file7 = fileArray2[index4];
        if (!file7.exists())
        {
          monitor.setProgress(min + (max - min) / 5);
        }
        else
        {
          System.get_out().println(new StringBuilder().append("Searching Folder:").append((object) file7).toString());
          monitor.setNote(new StringBuilder().append("Searching Folder:").append((object) file7).toString());
          File[] fileArray3 = file7.listFiles((FilenameFilter) new FileSniffer\u00241());
          if (fileArray3 == null)
          {
            monitor.setProgress(min + (max - min) / 5);
          }
          else
          {
            File[] fileArray4 = fileArray3;
            int length2 = fileArray4.Length;
            for (int index5 = 0; index5 < length2; ++index5)
            {
              File file8 = fileArray4[index5];
              System.get_out().println(new StringBuilder().append("Adding Jar:").append((object) file8).toString());
              Exception exception2;
              try
              {
                Method method = declaredMethod;
                URLClassLoader urlClassLoader2 = urlClassLoader1;
                object[] objArray = new object[1];
                int index6 = 0;
                URL url = file8.toURI().toURL();
                objArray[index6] = (object) url;
                CallerID callerId = FileSniffer.__\u003CGetCallerID\u003E();
                method.invoke((object) urlClassLoader2, objArray, callerId);
                continue;
              }
              catch (Exception ex)
              {
                int num = 0;
                M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
                if (m0 == null)
                  throw;
                else
                  exception2 = (Exception) m0;
              }
              Throwable.instancehelper_printStackTrace((Exception) exception2);
            }
            monitor.setProgress(min + (max - min) / 5);
          }
        }
      }
      if (!file1.exists())
      {
        System.get_out().println("No Extension Folder");
        monitor.setProgress(max);
      }
      else
      {
        File[] fileArray3 = file1.listFiles((FilenameFilter) new FileSniffer\u00242());
        double num1 = 0.0;
        File[] fileArray4 = fileArray3;
        int length2 = fileArray4.Length;
label_26:
        for (int index4 = 0; index4 < length2; ++index4)
        {
          File file7 = fileArray4[index4];
          System.get_out().println(new StringBuilder().append("Searching Jar:").append((object) file7).toString());
          monitor.setProgress(ByteCodeHelper.d2i((double) (min + max) / 2.0 * (1.0 + num1++ / (double) fileArray3.Length)));
          monitor.setNote(new StringBuilder().append("Searching Jar:").append((object) file7).toString());
          Enumeration enumeration;
          Exception exception2;
          try
          {
            enumeration = new JarFile(file7).entries();
            goto label_31;
          }
          catch (Exception ex)
          {
            int num2 = 0;
            exception2 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
          }
          Exception exception3 = exception2;
          goto label_52;
label_31:
          Exception exception4;
          Exception exception5;
          while (true)
          {
            Class class2;
            try
            {
              string name;
              do
              {
                if (enumeration.hasMoreElements())
                  name = ((ZipEntry) enumeration.nextElement()).getName();
                else
                  goto label_26;
              }
              while (!String.instancehelper_endsWith(name, ".class"));
              class2 = (Class) null;
              try
              {
                try
                {
                  try
                  {
                    class2 = Class.forName(String.instancehelper_replaceAll(String.instancehelper_substring(name, 0, String.instancehelper_length(name) - 6), "/", "."), false, (ClassLoader) urlClassLoader1, FileSniffer.__\u003CGetCallerID\u003E());
                    DisplayElementRegistry.registerWidget(class2.asSubclass((Class) ClassLiteral<Widget>.Value));
                    System.get_out().println(new StringBuilder().append("Custom Widget:").append(class2.getSimpleName()).toString());
                    continue;
                  }
                  catch (Exception ex)
                  {
                    int num2 = 2;
                    if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num2) == null)
                      throw;
                  }
                }
                catch (ClassNotFoundException ex)
                {
                  goto label_42;
                }
              }
              catch (Exception ex)
              {
                int num2 = 2;
                if (ByteCodeHelper.MapException<NoClassDefFoundError>(ex, (ByteCodeHelper.MapFlags) num2) == null)
                  throw;
                else
                  goto label_43;
              }
            }
            catch (Exception ex)
            {
              int num2 = 0;
              exception4 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
              break;
            }
            try
            {
              try
              {
                DisplayElementRegistry.registerStaticWidget(class2.asSubclass((Class) ClassLiteral<StaticWidget>.Value));
                System.get_out().println(new StringBuilder().append("Custom Static Widget:").append(class2.getSimpleName()).toString());
              }
              catch (Exception ex)
              {
                int num2 = 2;
                if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num2) == null)
                  throw;
              }
            }
            catch (Exception ex)
            {
              int num2 = 0;
              exception5 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
              goto label_51;
            }
            continue;
label_42:
            continue;
label_43:;
          }
          exception3 = exception4;
          goto label_52;
label_51:
          exception3 = exception5;
label_52:
          Throwable.instancehelper_printStackTrace(exception3);
          System.get_out().println("Error, could not add URL to system classloader");
        }
        monitor.setProgress(max);
      }
    }