mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-10 19:35:15 -05:00
Remove JDK 6 compatibility code
This commit is contained in:
parent
5cce75c0b9
commit
0892aed310
@ -1,6 +1,5 @@
|
|||||||
package net.filebot;
|
package net.filebot;
|
||||||
|
|
||||||
import static java.nio.file.Files.*;
|
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static java.util.stream.Collectors.*;
|
import static java.util.stream.Collectors.*;
|
||||||
import static net.filebot.Logging.*;
|
import static net.filebot.Logging.*;
|
||||||
@ -38,15 +37,11 @@ public enum StandardRenameAction implements RenameAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File rename(File from, File to) throws Exception {
|
public File rename(File from, File to) throws Exception {
|
||||||
File dest = resolveDestination(from, to);
|
// move file
|
||||||
|
File dest = MOVE.rename(from, to);
|
||||||
|
|
||||||
// move file and the create a symlink to the new location via NIO.2
|
// symlink file back into the original location
|
||||||
try {
|
SYMLINK.rename(dest, from);
|
||||||
move(from.toPath(), dest.toPath());
|
|
||||||
createRelativeSymlink(from, dest, true);
|
|
||||||
} catch (LinkageError e) {
|
|
||||||
throw new Exception("Unsupported Operation: move, createSymbolicLink");
|
|
||||||
}
|
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
@ -56,14 +51,7 @@ public enum StandardRenameAction implements RenameAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File rename(File from, File to) throws Exception {
|
public File rename(File from, File to) throws Exception {
|
||||||
File dest = resolveDestination(from, to);
|
return createRelativeSymlink(resolveDestination(from, to), from, true);
|
||||||
|
|
||||||
// create symlink via NIO.2
|
|
||||||
try {
|
|
||||||
return createRelativeSymlink(dest, from, true);
|
|
||||||
} catch (LinkageError e) {
|
|
||||||
throw new Exception("Unsupported Operation: createSymbolicLink");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -71,14 +59,7 @@ public enum StandardRenameAction implements RenameAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File rename(File from, File to) throws Exception {
|
public File rename(File from, File to) throws Exception {
|
||||||
File dest = resolveDestination(from, to);
|
return createHardLinkStructure(resolveDestination(from, to), from);
|
||||||
|
|
||||||
// create hardlink via NIO.2
|
|
||||||
try {
|
|
||||||
return createHardLinkStructure(dest, from);
|
|
||||||
} catch (LinkageError e) {
|
|
||||||
throw new Exception("Unsupported Operation: createLink");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -104,7 +85,7 @@ public enum StandardRenameAction implements RenameAction {
|
|||||||
|
|
||||||
int exitCode = process.start().waitFor();
|
int exitCode = process.start().waitFor();
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
throw new IOException(String.format("%s failed with exit code %d", process.command(), exitCode));
|
throw new IOException(String.format("%s failed (%d)", process.command(), exitCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
@ -120,7 +101,7 @@ public enum StandardRenameAction implements RenameAction {
|
|||||||
try {
|
try {
|
||||||
CLONE.rename(from, to);
|
CLONE.rename(from, to);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.finest(format("[%s] %s", CLONE, e));
|
debug.finest(cause(CLONE, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +109,7 @@ public enum StandardRenameAction implements RenameAction {
|
|||||||
try {
|
try {
|
||||||
return HARDLINK.rename(from, to);
|
return HARDLINK.rename(from, to);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.finest(format("[%s] %s", HARDLINK, e));
|
debug.finest(cause(HARDLINK, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy if necessary
|
// copy if necessary
|
||||||
|
Loading…
Reference in New Issue
Block a user