mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-21 21:15:19 +02:00
workingdir exists, print error if not, but continue. fixes #74
This commit is contained in:
@@ -880,12 +880,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
});
|
});
|
||||||
configSaveDirButton.addActionListener(arg0 -> {
|
configSaveDirButton.addActionListener(arg0 -> {
|
||||||
UIManager.put("FileChooser.useSystemExtensionHiding", false);
|
UIManager.put("FileChooser.useSystemExtensionHiding", false);
|
||||||
JFileChooser jfc = null;
|
JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory().toString());
|
||||||
try {
|
|
||||||
jfc = new JFileChooser(Utils.getWorkingDirectory().toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
int returnVal = jfc.showDialog(null, "select directory");
|
int returnVal = jfc.showDialog(null, "select directory");
|
||||||
if (returnVal != JFileChooser.APPROVE_OPTION) {
|
if (returnVal != JFileChooser.APPROVE_OPTION) {
|
||||||
@@ -904,12 +899,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
});
|
});
|
||||||
configUrlFileChooserButton.addActionListener(arg0 -> {
|
configUrlFileChooserButton.addActionListener(arg0 -> {
|
||||||
UIManager.put("FileChooser.useSystemExtensionHiding", false);
|
UIManager.put("FileChooser.useSystemExtensionHiding", false);
|
||||||
JFileChooser jfc = null;
|
JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory().toAbsolutePath().toString());
|
||||||
try {
|
|
||||||
jfc = new JFileChooser(Utils.getWorkingDirectory().toAbsolutePath().toString());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||||
int returnVal = jfc.showDialog(null, "Open");
|
int returnVal = jfc.showDialog(null, "Open");
|
||||||
if (returnVal != JFileChooser.APPROVE_OPTION) {
|
if (returnVal != JFileChooser.APPROVE_OPTION) {
|
||||||
|
@@ -109,7 +109,7 @@ public class Utils {
|
|||||||
*
|
*
|
||||||
* @return Root directory to save rips to.
|
* @return Root directory to save rips to.
|
||||||
*/
|
*/
|
||||||
public static Path getWorkingDirectory() throws IOException {
|
public static Path getWorkingDirectory() {
|
||||||
String currentDir = getJarDirectory() + File.separator + RIP_DIRECTORY + File.separator;
|
String currentDir = getJarDirectory() + File.separator + RIP_DIRECTORY + File.separator;
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
@@ -118,7 +118,12 @@ public class Utils {
|
|||||||
|
|
||||||
Path workingDir = Paths.get(currentDir);
|
Path workingDir = Paths.get(currentDir);
|
||||||
if (!Files.exists(workingDir)) {
|
if (!Files.exists(workingDir)) {
|
||||||
Files.createDirectory(workingDir);
|
try {
|
||||||
|
Files.createDirectory(workingDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.error("WorkingDir " + workingDir + " not exists, and could not be created. Set to user.home, continue.");
|
||||||
|
workingDir = Paths.get(System.getProperty("user.home"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return workingDir;
|
return workingDir;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user