/** Attempts to rename the specified file resource entry. */
 static void renameResource(FileResourceEntry entry) {
   String filename =
       JOptionPane.showInputDialog(
           NearInfinity.getInstance(),
           "Enter new filename",
           "Rename " + entry.toString(),
           JOptionPane.QUESTION_MESSAGE);
   if (filename == null) {
     return;
   }
   if (!filename.toUpperCase(Locale.ENGLISH).endsWith(entry.getExtension())) {
     filename = filename + '.' + entry.getExtension();
   }
   if (Files.exists(entry.getActualPath().getParent().resolve(filename))) {
     JOptionPane.showMessageDialog(
         NearInfinity.getInstance(), "File already exists!", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   try {
     entry.renameFile(filename, false);
   } catch (IOException e) {
     JOptionPane.showMessageDialog(
         NearInfinity.getInstance(),
         "Error renaming file \"" + filename + "\"!",
         "Error",
         JOptionPane.ERROR_MESSAGE);
     e.printStackTrace();
     return;
   }
   ResourceFactory.getResources().resourceEntryChanged(entry);
 }
 /** Attempts to delete the specified resource if it exists as a file in the game path. */
 static void deleteResource(ResourceEntry entry) {
   if (entry instanceof FileResourceEntry) {
     String options[] = {"Delete", "Cancel"};
     if (JOptionPane.showOptionDialog(
             NearInfinity.getInstance(),
             "Are you sure you want to delete " + entry + '?',
             "Delete file",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             options,
             options[0])
         != 0) return;
     NearInfinity.getInstance().removeViewable();
     ResourceFactory.getResources().removeResourceEntry(entry);
     Path bakFile = getBackupFile(entry);
     if (bakFile != null) {
       try {
         Files.delete(bakFile);
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
     try {
       ((FileResourceEntry) entry).deleteFile();
     } catch (IOException e) {
       JOptionPane.showMessageDialog(
           NearInfinity.getInstance(),
           "Error deleting file \"" + entry.getResourceName() + "\"!",
           "Error",
           JOptionPane.ERROR_MESSAGE);
       e.printStackTrace();
     }
   } else if (entry instanceof BIFFResourceEntry) {
     String options[] = {"Delete", "Cancel"};
     if (JOptionPane.showOptionDialog(
             NearInfinity.getInstance(),
             "Are you sure you want to delete the " + "override file " + entry + '?',
             "Delete file",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null,
             options,
             options[0])
         != 0) return;
     NearInfinity.getInstance().removeViewable();
     Path bakFile = getBackupFile(entry);
     if (bakFile != null) {
       try {
         Files.delete(bakFile);
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
     try {
       ((BIFFResourceEntry) entry).deleteOverride();
     } catch (IOException e) {
       JOptionPane.showMessageDialog(
           NearInfinity.getInstance(),
           "Error deleting file \"" + entry.getResourceName() + "\"!",
           "Error",
           JOptionPane.ERROR_MESSAGE);
       e.printStackTrace();
     }
   }
 }