Skip to content

Commit cd9dddb

Browse files
author
jredfox
committed
backup
1 parent 1f6dd01 commit cd9dddb

16 files changed

+78
-1568
lines changed

src/jredfox/common/config/MapConfig.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.TreeMap;
99

1010
import jredfox.common.io.IOUtils;
11-
import jredfox.selfcmd.SelfCommandPrompt;
11+
import jredfox.common.utils.JavaUtil;
1212

1313
/**
1414
* a Config that will only support key=value
@@ -114,9 +114,9 @@ public void load()
114114

115115
public void parseLine(String line)
116116
{
117-
String[] reg = SelfCommandPrompt.splitFirst(line, ':', '"', '"');
117+
String[] reg = JavaUtil.splitFirst(line, ':', '"', '"');
118118
String type = reg[0].trim();
119-
reg = SelfCommandPrompt.splitFirst(reg[1], this.sep, '"', '"');
119+
reg = JavaUtil.splitFirst(reg[1], this.sep, '"', '"');
120120
String key = reg[0].trim();
121121
String value = reg[1].trim();
122122
Object parsed = this.parseObj(type, value);
@@ -166,7 +166,7 @@ else if(types[5].equals(type))
166166
else if(types[6].equals(type))
167167
return Boolean.parseBoolean(value);
168168
else if(types[7].equals(type))
169-
return SelfCommandPrompt.parseQuotes(value, '"', '"');
169+
return JavaUtil.parseQuotes(value, '"', '"');
170170

171171
return null;
172172
}

src/jredfox/common/os/OSUtil.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import java.util.List;
66

77
import jredfox.common.file.FileUtils;
8-
import jredfox.selfcmd.SelfCommandPrompt;
9-
import jredfox.selfcmd.thread.ShutdownThread;
8+
import jredfox.common.thread.ShutdownThread;
9+
import jredfox.common.utils.FileUtil;
10+
import jredfox.common.utils.JavaUtil;
1011

1112
public class OSUtil {
1213

@@ -159,9 +160,8 @@ public static boolean isUnsupported()
159160
public static File getAppData()
160161
{
161162
if(isWindows())
162-
{
163163
return new File(System.getenv("APPDATA"));
164-
}
164+
165165
String path = System.getProperty("user.home");
166166
if(isMac())
167167
path += "/Library/Application Support";
@@ -189,7 +189,7 @@ public static File toWinFile(File file)
189189
while(fpath != null)
190190
{
191191
String fileName = FileUtils.getTrueName(fpath);
192-
String filtered = isReserved(fileName) ? ( (fileName.contains(".") ? SelfCommandPrompt.inject(fileName, '.', '_') : fileName + "_") + SelfCommandPrompt.getExtensionFull(fpath)) : (fpath.getParent() != null ? fpath.getName() : fpath.getPath());
192+
String filtered = isReserved(fileName) ? ( (fileName.contains(".") ? JavaUtil.inject(fileName, '.', '_') : fileName + "_") + FileUtil.getExtensionFull(fpath)) : (fpath.getParent() != null ? fpath.getName() : fpath.getPath());
193193
paths.add(filtered);
194194
fpath = fpath.getParentFile();
195195
}
@@ -211,7 +211,7 @@ public static File toWinFile(File file)
211211
public static File toOSFile(File file)
212212
{
213213
String invalid = "*/<>?\":|'";//java replaces trailing "\" or "/" and you can't get a file name with "/\" in java so don't check it
214-
if(SelfCommandPrompt.containsAny(file.getPath(), invalid))
214+
if(JavaUtil.containsAny(file.getPath(), invalid))
215215
{
216216
file = filter(file, invalid);
217217
}

src/jredfox/common/utils/JREUtil.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
public class JREUtil {
1313

1414
public static final String INVALID = "\"'`,";
15+
16+
static
17+
{
18+
System.setProperty("runnables.jar", getFileFromClass(getMainClass()).getPath());
19+
20+
//patch macOs returning junk #untested before Big Sur
21+
String dir = System.getProperty("user.dir");
22+
String tmp = System.getProperty("java.io.tmpdir");
23+
if(dir.contains(tmp) && !dir.startsWith(tmp))
24+
JREUtil.syncUserDirWithJar();
25+
}
1526

1627
/**
1728
* Must be called before {@link SelfCommandPrompt#runWithCMD(String, String, Class, String[], boolean, boolean)}
@@ -21,7 +32,7 @@ public static void syncUserDirWithJar()
2132
{
2233
try
2334
{
24-
setUserDir(getFileFromClass(getMainClass()).getParentFile());
35+
setUserDir(new File(System.getProperty("runnables.jar")).getParentFile());
2536
}
2637
catch (Exception e)
2738
{
@@ -39,11 +50,11 @@ public static void setUserDir(File file)
3950
}
4051

4152
/**
42-
* checks if the jar is compiled based on the main class
53+
* optimized method for checking if the main executing jar isCompiled
4354
*/
4455
public static boolean isCompiled()
4556
{
46-
return isCompiled(getMainClass());
57+
return System.getProperty("runnables.jar").endsWith(".jar");
4758
}
4859

4960
/**

src/jredfox/selfcmd/ConsoleApp.java

-38
This file was deleted.

src/jredfox/selfcmd/ConsoleLauncher.java

-54
This file was deleted.

0 commit comments

Comments
 (0)