* create temporary folder when creating the first temporary file

* use absolute file for relative files used in arguments
This commit is contained in:
Reinhard Pointner 2008-03-20 20:11:08 +00:00
parent a2beab245f
commit 414ab43cc3
3 changed files with 19 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
@ -35,12 +36,17 @@ public class FileTransferableMessageHandler implements MessageHandler {
List<File> files = new ArrayList<File>(messages.length);
for (String filename : messages) {
File file = new File(filename);
if (file.exists()) {
files.add(file);
} else {
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, String.format("Invalid File: %s", filename));
try {
File file = new File(filename);
if (file.exists()) {
// file might be relative, use absolute file
files.add(file.getCanonicalFile());
} else {
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, String.format("Invalid File: %s", filename));
}
} catch (IOException e) {
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
}
}

View File

@ -25,8 +25,8 @@ import net.sourceforge.filebot.FileBotUtil;
import net.sourceforge.filebot.resources.ResourceManager;
import net.sourceforge.filebot.ui.FileBotList;
import net.sourceforge.filebot.ui.FileBotPanel;
import net.sourceforge.filebot.ui.MessageManager;
import net.sourceforge.filebot.ui.FileTransferableMessageHandler;
import net.sourceforge.filebot.ui.MessageManager;
import net.sourceforge.filebot.ui.transfer.LoadAction;
import net.sourceforge.filebot.ui.transfer.SaveAction;
import net.sourceforge.tuned.MessageBus;
@ -129,7 +129,7 @@ public class ListPanel extends FileBotPanel {
Matcher titleMatcher = Pattern.compile("^([\\w\\s]+).*(\\s+\\w*" + Pattern.quote(INDEX_VARIABLE) + ").*").matcher(pattern);
if (titleMatcher.matches()) {
list.setTitle(titleMatcher.group(1));
list.setTitle(titleMatcher.group(1).trim());
}
ArrayList<String> entries = new ArrayList<String>();

View File

@ -32,7 +32,7 @@ public class TemporaryFolder {
* Delete all temporary folders on shutdown
*/
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
Runtime.getRuntime().addShutdownHook(new Thread("TemporaryFolder ShutdownHook") {
@Override
public void run() {
@ -52,13 +52,16 @@ public class TemporaryFolder {
private TemporaryFolder(File root) {
this.root = root;
this.root.mkdir();
}
public File createFile(String name) throws IOException {
if (!root.exists())
root.mkdir();
File file = new File(root, name);
file.createNewFile();
return file;
}