mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-09 03:30:40 +00:00
Fixed update of resource files in output directory. Closes #495
This commit is contained in:
parent
043b6e29b5
commit
7d1c127999
@ -14,10 +14,10 @@ import kickass.nonasm.c64.CharToPetsciiConverter;
|
|||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.FileAlreadyExistsException;
|
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.attribute.FileTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -405,12 +405,19 @@ public class KickC implements Callable<Integer> {
|
|||||||
if(!CFileDir.toAbsolutePath().equals(outputDir.toAbsolutePath())) {
|
if(!CFileDir.toAbsolutePath().equals(outputDir.toAbsolutePath())) {
|
||||||
for(Path resourcePath : program.getAsmResourceFiles()) {
|
for(Path resourcePath : program.getAsmResourceFiles()) {
|
||||||
Path outResourcePath = outputDir.resolve(resourcePath.getFileName().toString());
|
Path outResourcePath = outputDir.resolve(resourcePath.getFileName().toString());
|
||||||
System.out.println("Copying resource " + outResourcePath);
|
if(Files.exists(outResourcePath)) {
|
||||||
try {
|
FileTime resModified = Files.getLastModifiedTime(resourcePath);
|
||||||
Files.copy(resourcePath, outResourcePath);
|
FileTime outModified = Files.getLastModifiedTime(outResourcePath);
|
||||||
} catch(FileAlreadyExistsException e) {
|
if(outModified.toMillis()>resModified.toMillis()) {
|
||||||
// Ignore this
|
// Outfile is newer - move on to next file
|
||||||
|
System.out.println("Resource already copied " + outResourcePath);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Resource is newer than existing file - delete it
|
||||||
|
Files.delete(outResourcePath);
|
||||||
}
|
}
|
||||||
|
System.out.println("Copying resource " + outResourcePath);
|
||||||
|
Files.copy(resourcePath, outResourcePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user