Ejemplo n.º 1
0
  private void showDirectoryContentsUI() {
    // Fijamos el directorio actual.

    iCurrentPath = iLoadingPathname;

    // Visualizamos el nombre del directorio actual.

    iFolderNameText.setText(iCurrentPath + "/");

    // Eliminamos la lista de ficheros antiguos.

    iFilesList.clear();

    // Si no estamos en el directorio raíz, añadimos como primer elemento
    // ir al directorio anterior.

    if (!iCurrentPath.equals("")) {
      iFilesList.add(
          createListViewItem(getResources().getString(R.string.folder_up), R.drawable.folder_up));
    }

    // Inicializamos la lista de ficheros.

    for (MyFile child : iChilds)
      iFilesList.add(
          createListViewItem(
              child.getName(), child.isDirectory() ? R.drawable.folder : R.drawable.file));

    // Visualizamos la lista.

    iAdapterList.notifyDataSetChanged();
    iListView.setAdapter(iAdapterList);
  }
Ejemplo n.º 2
0
 public int compare(MyFile left, MyFile right) {
   if (left.isDirectory()) {
     if (right.isDirectory()) {
       return left.compareTo(right);
     }
     return -1;
   }
   return right.isDirectory() ? 1 : left.compareTo(right);
 }
Ejemplo n.º 3
0
  public void testMapCount() throws Exception {
    String namenode = null;
    MiniDFSCluster dfs = null;
    MiniDFSCluster mr = null;
    try {
      Configuration conf = new Configuration();

      dfs = new MiniDFSCluster.Builder(conf).numDataNodes(3).format(true).build();

      FileSystem fs = dfs.getFileSystem();
      final FsShell shell = new FsShell(conf);
      namenode = fs.getUri().toString();
      MyFile[] files = createFiles(fs.getUri(), "/srcdat");
      long totsize = 0;
      for (MyFile f : files) {
        totsize += f.getSize();
      }

      Configuration job = new JobConf(conf);
      job.setLong("distcp.bytes.per.map", totsize / 3);
      ToolRunner.run(
          new DistCpV1(job),
          new String[] {
            "-m", "100", "-log", namenode + "/logs", namenode + "/srcdat", namenode + "/destdat"
          });
      assertTrue(
          "Source and destination directories do not match.", checkFiles(fs, "/destdat", files));

      String logdir = namenode + "/logs";
      System.out.println(execCmd(shell, "-lsr", logdir));
      FileStatus[] logs = fs.listStatus(new Path(logdir));
      // rare case where splits are exact, logs.length can be 4
      assertTrue(logs.length == 2);

      deldir(fs, "/destdat");
      deldir(fs, "/logs");
      ToolRunner.run(
          new DistCpV1(job),
          new String[] {
            "-m", "1", "-log", namenode + "/logs", namenode + "/srcdat", namenode + "/destdat"
          });

      System.out.println(execCmd(shell, "-lsr", logdir));
      logs = fs.globStatus(new Path(namenode + "/logs/part*"));
      assertTrue("Unexpected map count, logs.length=" + logs.length, logs.length == 1);
    } finally {
      if (dfs != null) {
        dfs.shutdown();
      }
      if (mr != null) {
        mr.shutdown();
      }
    }
  }
Ejemplo n.º 4
0
 static MyFile createFile(Path root, FileSystem fs, int levels) throws IOException {
   MyFile f = levels < 0 ? new MyFile() : new MyFile(levels);
   Path p = new Path(root, f.getName());
   FSDataOutputStream out = fs.create(p);
   byte[] toWrite = new byte[f.getSize()];
   new Random(f.getSeed()).nextBytes(toWrite);
   out.write(toWrite);
   out.close();
   FileSystem.LOG.info("created: " + p + ", size=" + f.getSize());
   return f;
 }
Ejemplo n.º 5
0
 private void dirlist() {
   listFilesModel.removeAllElements();
   listToConvertModel.removeAllElements();
   MyFile dir = new MyFile(textField.getText());
   MyFile[] chld = dir.listFiles();
   for (int i = 0; i < chld.length; i++) {
     if (chld[i].isFile()) listFilesModel.addElement((MyFile) chld[i]);
   }
   if (chld.length > 0) {
     listFiles.setSelectionInterval(0, 0);
   }
 }
 public void insertImage(String identification, int i) {
   try {
     files.extractZip(identification);
     ((TTAirButton) buttons.get(i)).setImage(converterTB.conversion(identification, files));
     ((TTAirButton) buttons.get(i)).setInsertedPicture(true);
   } catch (Exception erro) {
     System.out.println("error: Insert Image");
   }
 }
Ejemplo n.º 7
0
  private int _showDirectoryContents() {
    // Obtenemos los ficheros del directorio recibido como parámetro.

    if (iShellExecutor.execute("ls -l " + iLoadingPathname + "/")) {
      List<String> output = iShellExecutor.getStandardOutput();
      if (output == null) {
        // No podemos visualizar el mensaje de error aquí.
        // Sólo en el flujo principal...

        return 1;
      }

      // Mostramos el contenido.
      // Mostraremos los directorios siempre y los ficheros sólo si "iShowPlainFiles" es true
      // (es decir, si no estamos en la pantalla de selección del directorio raíz)...

      iChilds.clear();
      for (String line : output) {
        MyFile child = new MyFile(line);
        if ((iShowPlainFiles) || (child.isDirectory())) iChilds.add(child);
      }

      // Ordenamos la lista de ficheros.
      // teniendo en cuenta cómo quiere verlos el usuario (si primero los directorios o no)...

      if (PreferenceManager.getDefaultSharedPreferences(this)
          .getBoolean("list_folders_first", true)) {
        Collections.sort(iChilds, iComparatorFoldersUp);
        iFoldersUp = true;
      } else {
        Collections.sort(iChilds, iComparatorFoldersNotUp);
        iFoldersUp = false;
      }
    }

    // Devolvemos 0 para indicar que el directorio debe visualizarse...

    return 0;
  }
Ejemplo n.º 8
0
  /**
   * Reads the previous learned RB from a input file
   *
   * @param fichero String The name of the file containing the learned RB
   */
  public void leer_BR(String fichero) {
    int i, j;
    String cadena;

    cadena = MyFile.ReadMyFile(fichero);

    StringTokenizer sT = new StringTokenizer(cadena, "\n\r\t ", false);
    sT.nextToken();
    sT.nextToken();
    sT.nextToken();

    n_reglas = Integer.parseInt(sT.nextToken());

    BaseReglas = new Rule[n_reglas];
    for (i = 0; i < n_reglas; i++) {
      BaseReglas[i] = new Rule(tabla.n_inputs, tabla.nClasses);
    }

    for (i = 0; i < n_reglas; i++) {
      for (j = 0; j < tabla.n_inputs; j++) {
        BaseReglas[i].Ant[j].Etiqueta = sT.nextToken();
        BaseReglas[i].Ant[j].x0 = Double.parseDouble(sT.nextToken());
        BaseReglas[i].Ant[j].x1 = Double.parseDouble(sT.nextToken());
        BaseReglas[i].Ant[j].x2 = BaseReglas[i].Ant[j].x1;
        BaseReglas[i].Ant[j].x3 = Double.parseDouble(sT.nextToken());
        BaseReglas[i].Ant[j].y = 1.0;
      }

      switch (tipo_reglas) {
        case 1:
          sT.nextToken();
          BaseReglas[i].Cons[0].clase = Integer.parseInt(sT.nextToken());
          break;
        case 2:
          sT.nextToken();
          BaseReglas[i].Cons[0].clase = Integer.parseInt(sT.nextToken());
          sT.nextToken();
          BaseReglas[i].Cons[0].gcerteza = Double.parseDouble(sT.nextToken());
          break;
        case 3:
          for (j = 0; j < tabla.nClasses; j++) {
            sT.nextToken();
            BaseReglas[i].Cons[j].clase = Integer.parseInt(sT.nextToken());
            sT.nextToken();
            BaseReglas[i].Cons[j].gcerteza = Double.parseDouble(sT.nextToken());
          }
      }
    }
  }
 public ManagerButton(MyscreenPanel msp) {
   if (!files.directoryExists()) {
     files.createDirectory();
   }
   this.msp = msp;
 }
Ejemplo n.º 10
0
 public int compareTo(MyFile file) {
   return iName.compareTo(file.getName());
 }
Ejemplo n.º 11
0
 public int compare(MyFile left, MyFile right) {
   return left.compareTo(right);
 }