/**
   * It is possible to add several files with same name to the Trash. These files are distinguished
   * by _N appended to the name, where _N is rising int number. <br>
   * This method tries to find first empty <code>filename_N.ext</code>.
   *
   * @param file File to be deleted
   * @return Suitable filename in trash (without .trashinfo extension)
   */
  private String getUniqueFilename(AbstractFile file) throws IOException {
    // try if no previous file in trash exists
    if (!TRASH_FILES_SUBFOLDER.getChild(file.getName()).exists()) return file.getName();

    String rawName = file.getNameWithoutExtension();
    String extension = file.getExtension();

    // find first empty filename in format filename_N.ext
    String filename;
    int count = 1;
    while (true) {
      filename = rawName + "_" + count++;
      if (extension != null) {
        filename += "." + extension;
      }

      if (!TRASH_FILES_SUBFOLDER.getChild(filename).exists()) return filename;
    }
  }