Exemplo n.º 1
0
  private String getCreated() {
    String[] daytime =
        fileInfo.getTime().split(((fileInfo.getTime().indexOf(":") > -1) ? ":" : " "));

    if (daytime.length < 2) {
      return fileInfo.getDate() + ", " + fileInfo.getTime();
    }

    int hour = new Integer(daytime[0]).intValue();
    int minutes = new Integer(daytime[1]).intValue();
    int seconds = daytime.length > 2 ? new Integer(daytime[2]).intValue() : -1;
    String meridian = " AM";
    if (hour > 12) {
      hour -= 12;
      meridian = " PM";
    }

    return fileInfo.getDate()
        + ", "
        + hour
        + ":"
        + minutes
        + ((seconds > -1) ? ":" + seconds : "")
        + meridian;
  }
Exemplo n.º 2
0
  private GridFile createGridFile(Object obj) throws FileResourceException, IOException {

    GridFile gridFile = new GridFileImpl();

    FileInfo fileInfo = (FileInfo) obj;

    String directory = getCurrentDirectory();
    if (directory.endsWith("/")) {
      gridFile.setAbsolutePathName(directory + fileInfo.getName());
    } else {
      gridFile.setAbsolutePathName(directory + "/" + fileInfo.getName());
    }
    try {
      gridFile.setLastModified(new SimpleDateFormat().parse(fileInfo.getDate()));
    } catch (ParseException e) {
      gridFile.setLastModified(new Date(0));
    }

    if (fileInfo.isFile() == true) {
      gridFile.setFileType(GridFile.FILE);
    }
    if (fileInfo.isDirectory() == true) {
      gridFile.setFileType(GridFile.DIRECTORY);
    }
    if (fileInfo.isDevice() == true) {
      gridFile.setFileType(GridFile.DEVICE);
    }
    if (fileInfo.isSoftLink() == true) {
      gridFile.setFileType(GridFile.SOFTLINK);
    }

    gridFile.setMode(fileInfo.getModeAsString());
    gridFile.setName(fileInfo.getName());
    gridFile.setSize(fileInfo.getSize());

    gridFile.setUserPermissions(
        PermissionsImpl.instance(
            fileInfo.userCanRead(), fileInfo.userCanWrite(), fileInfo.userCanExecute()));
    gridFile.setGroupPermissions(
        PermissionsImpl.instance(
            fileInfo.groupCanRead(), fileInfo.groupCanWrite(), fileInfo.groupCanExecute()));
    gridFile.setWorldPermissions(
        PermissionsImpl.instance(
            fileInfo.allCanRead(), fileInfo.allCanWrite(), fileInfo.allCanExecute()));

    return gridFile;
  }