civplayer33
King
- Joined
- Sep 11, 2017
- Messages
- 965
That's fixed in the repo...it just didn't make it to a new hotfix; that is, if there will be a new hotfix...it'll be fixed for the next beta at the latest.Indian War Elephant still has Anti-mounted I instead of the Siamese war elephant.
Also, "slightly" OT, but I "fixed" my earlier code to be more compact, if you wanna have a laugh...
Spoiler take THAT Python-nerds!!! :
Code:
// This program recursively walks through a folder and checks all the last modified times of the files contained therein
// and then prints the most recent one (and optionally all files found) and then gives the user the option of deleting the
// folder with all files (compact version with less lines of code...Python-style)
import java.util.*;
import java.util.stream.Stream;
import java.nio.file.*;
import java.nio.file.attribute.FileTime;
import java.io.*;
class EUIRemoverCompact {
public static void main(String... args) {
if (args.length == 1 && args[0].compareToIgnoreCase("help") == 0) System.out.println("\nSyntax: EUIRemoverCompact targetFolderPath [optional]debugflag (\"1\")\n\nThis program recursively walks through a folder and checks all the last modified times of the files contained therein and then prints the most recent one (and optionally all files found) and then gives the user the option of deleting the folder with all files. The optional debugflag will cause all files found to be printed along with their last modified times; by default the folder C:\\Program Files (x86)\\Steam is used, but a different folder can be specified. If \"default\" is entered as the targetFolderPath then the mentioned default folder is used.");
else new EUIRemoverCompact().processFiles((args.length == 0 || args[0].compareTo("default") == 0) ? "C:\\Program Files (x86)\\Steam" : args[0], (args.length > 1) ? args[1].compareTo("1") == 0 : false);}
void processFiles(String workingDir, boolean debug) {
ArrayDeque<FileTime> mostRecentTimes = new ArrayDeque<>();
try (Stream<Path> pathStream = Files.walk(Paths.get(workingDir))) { // by default Files.walk() does not follow symbolic links
pathStream.filter(e -> Files.isRegularFile(e, LinkOption.NOFOLLOW_LINKS)) .forEach(e -> processFile(e, debug, mostRecentTimes));}
catch (SecurityException | IOException e) { System.err.println("While trying to walk the filesystem from " + workingDir + " we encountered the following exception, which requires aborting this action:\n" + e.toString());}
if (!mostRecentTimes.isEmpty()) {
System.out.println("\n\nProcessed " + mostRecentTimes.size() + " files, of which the most recently modified was modified on: " + mostRecentTimes.pop().toString() + "\n\nDo you wish to (recursively) delete all files and folders inside of and including the targetFolderPath (" + workingDir + ")? (y/n)");
if (new Scanner(System.in).nextLine().compareToIgnoreCase("y") == 0) {
try (Stream<Path> pathStream = Files.walk(Paths.get(workingDir))){
pathStream.map(Path::toFile) .sorted(Comparator.reverseOrder()) .forEach(File::delete);}
catch (SecurityException | IOException e) { System.err.println("While trying to walk the filesystem from " + workingDir + " we encountered the following exception, which requires aborting this action:\n" + e.toString() + "\n\nYou need to manually delete the remaining files.");}}}
else System.out.println("We have found no files to check...exiting.");}
void processFile(Path p, boolean print, ArrayDeque<FileTime> mostRecentTimes) {
try { FileTime modTime = Files.getLastModifiedTime(p);
if (print) System.out.println(modTime.toString().substring(0, 16) + " " + p.toString());
if (mostRecentTimes.peek() != null && mostRecentTimes.peek().compareTo(modTime) < 0) mostRecentTimes.push(modTime);
else mostRecentTimes.offer(modTime);}
catch (SecurityException | IOException e) { System.err.println("While accessing the file " + p.toString() + " we caught the following exception:\n" + e.toString());}}}