pekko-connectors-sample-ftp-to-file/src/main/java/playground/filesystem/impl/JimfsFtpFile.java [263:342]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            LOG.error(t.getMessage());
        }

        if (filesStream == null) {
            return null;
        }

        List<Path> files = new ArrayList<>();
        for (Path path : filesStream) {
            files.add(path);
        }

        // make sure the files are returned in order
        Collections.sort(files, new Comparator<Path>() {
            public int compare(Path o1, Path o2) {
                return o1.getFileName().compareTo(o2.getFileName());
            }
        });

        // get the virtual name of the base directory
        final String virtualFileStr =
                getAbsolutePath().charAt(getAbsolutePath().length() - 1) != '/'
                        ? getAbsolutePath() + '/' : getAbsolutePath();

        // now return all the files under the directory
        List<FtpFile> virtualFiles = new ArrayList<>(files.size());
        for (Path file : files) {
            String fileName = virtualFileStr + file.getFileName();
            virtualFiles.add(new JimfsFtpFile(fileName, file, user));
        }
        return virtualFiles;
    }

    public OutputStream createOutputStream(long offset)
            throws IOException {

        // permission check
        if (!isWritable()) {
            throw new IOException("No write permission : " + path.getFileName());
        }

        // create output stream
        final RandomAccessFile raf = new RandomAccessFile(path.toFile(), "rw");
        raf.setLength(offset);
        raf.seek(offset);

        // The IBM jre needs to have both the stream and the random access file
        // objects closed to actually close the file
        return new FileOutputStream(raf.getFD()) {
            @Override
            public void close() throws IOException {
                super.close();
                raf.close();
            }
        };
    }

    public InputStream createInputStream(long offset)
            throws IOException {

        // permission check
        if (!isReadable()) {
            throw new IOException("No read permission : " + path.getFileName());
        }

        return Files.newInputStream(path, StandardOpenOption.READ);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof JimfsFtpFile) {
            Path otherPath = ((JimfsFtpFile) obj).path.normalize();
            return this.path.normalize().equals(otherPath);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return path.normalize().hashCode();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



pekko-connectors-sample-rotate-logs-to-ftp/src/main/java/playground/filesystem/impl/JimfsFtpFile.java [263:342]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      LOG.error(t.getMessage());
    }

    if (filesStream == null) {
      return null;
    }

    List<Path> files = new ArrayList<>();
    for (Path path : filesStream) {
      files.add(path);
    }

    // make sure the files are returned in order
    Collections.sort(files, new Comparator<Path>() {
      public int compare(Path o1, Path o2) {
        return o1.getFileName().compareTo(o2.getFileName());
      }
    });

    // get the virtual name of the base directory
    final String virtualFileStr =
        getAbsolutePath().charAt(getAbsolutePath().length() - 1) != '/'
            ? getAbsolutePath() + '/' : getAbsolutePath();

    // now return all the files under the directory
    List<FtpFile> virtualFiles = new ArrayList<>(files.size());
    for (Path file : files) {
      String fileName = virtualFileStr + file.getFileName();
      virtualFiles.add(new JimfsFtpFile(fileName, file, user));
    }
    return virtualFiles;
  }

  public OutputStream createOutputStream(long offset)
      throws IOException {

    // permission check
    if (!isWritable()) {
      throw new IOException("No write permission : " + path.getFileName());
    }

    // create output stream
    final RandomAccessFile raf = new RandomAccessFile(path.toFile(), "rw");
    raf.setLength(offset);
    raf.seek(offset);

    // The IBM jre needs to have both the stream and the random access file
    // objects closed to actually close the file
    return new FileOutputStream(raf.getFD()) {
      @Override
      public void close() throws IOException {
        super.close();
        raf.close();
      }
    };
  }

  public InputStream createInputStream(long offset)
      throws IOException {

    // permission check
    if (!isReadable()) {
      throw new IOException("No read permission : " + path.getFileName());
    }

    return Files.newInputStream(path, StandardOpenOption.READ);
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof JimfsFtpFile) {
      Path otherPath = ((JimfsFtpFile) obj).path.normalize();
      return this.path.normalize().equals(otherPath);
    }
    return false;
  }

  @Override
  public int hashCode() {
    return path.normalize().hashCode();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



