From 63cb4784e7763be8829b349440f19a2a941f4ff6 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 2 May 2018 09:57:05 +1000 Subject: [PATCH] debug file not found --- .../java/com/boydti/fawe/util/MainUtil.java | 83 ++++++------------- .../worldedit/command/SchematicCommands.java | 4 + 2 files changed, 29 insertions(+), 58 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/util/MainUtil.java b/core/src/main/java/com/boydti/fawe/util/MainUtil.java index d2e8000f..40b7baf4 100644 --- a/core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -3,85 +3,36 @@ package com.boydti.fawe.util; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.FaweInputStream; -import com.boydti.fawe.object.FaweOutputStream; -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.RegionWrapper; -import com.boydti.fawe.object.RunnableVal; -import com.boydti.fawe.object.RunnableVal2; +import com.boydti.fawe.object.*; import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet; import com.boydti.fawe.object.changeset.FaweStreamChangeSet; import com.boydti.fawe.object.io.AbstractDelegateOutputStream; import com.github.luben.zstd.ZstdInputStream; import com.github.luben.zstd.ZstdOutputStream; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.DoubleTag; -import com.sk89q.jnbt.EndTag; -import com.sk89q.jnbt.IntTag; -import com.sk89q.jnbt.ListTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; +import com.sk89q.jnbt.*; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.util.Location; import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; +import java.io.*; import java.lang.reflect.Array; import java.lang.reflect.Method; import java.lang.reflect.Parameter; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLConnection; +import java.net.*; import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.nio.charset.StandardCharsets; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.StandardCopyOption; +import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Scanner; -import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; -import java.util.zip.DataFormatException; -import java.util.zip.Deflater; -import java.util.zip.GZIPInputStream; -import java.util.zip.Inflater; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; +import java.util.regex.Pattern; +import java.util.zip.*; import javax.imageio.ImageIO; -import net.jpountz.lz4.LZ4BlockInputStream; -import net.jpountz.lz4.LZ4BlockOutputStream; -import net.jpountz.lz4.LZ4Compressor; -import net.jpountz.lz4.LZ4Factory; -import net.jpountz.lz4.LZ4FastDecompressor; -import net.jpountz.lz4.LZ4InputStream; -import net.jpountz.lz4.LZ4Utils; +import net.jpountz.lz4.*; public class MainUtil { /* @@ -225,6 +176,22 @@ public class MainUtil { } } + public static String relativize(String path) { + String[] split = path.split(Pattern.quote(File.separator)); + StringBuilder out = new StringBuilder(); + int skip = 0; + int len = split.length - 1; + for (int i = len; i >= 0; i--) { + if (skip > 0) skip--; + else { + String arg = split[i]; + if (arg.equals("..")) skip++; + else out.insert(0, arg + (i == len ? "" : File.separator)); + } + } + return out.toString(); + } + public static void forEachFile(Path path, final RunnableVal2 onEach, Comparator comparator) { File dir = path.toFile(); if (!dir.exists()) return; diff --git a/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 322b1efb..c5885d3b 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -251,6 +251,10 @@ public class SchematicCommands extends MethodCommands { } if (!f.exists() || !MainUtil.isInSubDirectory(working, f)) { player.printError("Schematic " + filename + " does not exist! (" + f.exists() + "|" + f + "|" + (!MainUtil.isInSubDirectory(working, f)) + ")"); + File absolute = f.getAbsoluteFile(); + player.printError("TEST0 " + absolute + " = " + absolute.exists()); + player.printError("TEST1 " + MainUtil.relativize(absolute.getPath()) + " = " + new File(MainUtil.relativize(absolute.getPath())).exists()); + player.printError("TEST1 " + MainUtil.relativize(f.getPath()) + " = " + new File(MainUtil.relativize(f.getPath())).exists()); return; } in = new FileInputStream(f);