mirror of
https://github.com/ME1312/SubServers-2.git
synced 2025-01-05 23:48:12 +01:00
Fix /sub delete permission error on windows
This commit is contained in:
parent
bddbb692cd
commit
bb7cfa9e57
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1459,8 +1459,6 @@
|
||||
</dd>
|
||||
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Host/Library/Log/Logger.html#message">message</a></span> - Variable in class net.ME1312.SubServers.Host.Library.Log.<a href="net/ME1312/SubServers/Host/Library/Log/Logger.html" title="class in net.ME1312.SubServers.Host.Library.Log">Logger</a></dt>
|
||||
<dd> </dd>
|
||||
<dt><span class="memberNameLink"><a href="net/ME1312/SubServers/Host/Network/Packet/PacketExDeleteServer.html#move-java.io.File-java.io.File-">move(File, File)</a></span> - Method in class net.ME1312.SubServers.Host.Network.Packet.<a href="net/ME1312/SubServers/Host/Network/Packet/PacketExDeleteServer.html" title="class in net.ME1312.SubServers.Host.Network.Packet">PacketExDeleteServer</a></dt>
|
||||
<dd> </dd>
|
||||
</dl>
|
||||
<a name="I:N">
|
||||
<!-- -->
|
||||
|
@ -17,7 +17,7 @@
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
var methods = {"i0":10,"i1":10,"i2":10,"i3":10};
|
||||
var methods = {"i0":10,"i1":10,"i2":10};
|
||||
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
|
||||
var altColor = "altColor";
|
||||
var rowColor = "rowColor";
|
||||
@ -177,11 +177,6 @@ implements <a href="../../../../../../net/ME1312/SubServers/Host/Network/PacketI
|
||||
<div class="block">Get Packet Version</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="i3" class="rowColor">
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../net/ME1312/SubServers/Host/Network/Packet/PacketExDeleteServer.html#move-java.io.File-java.io.File-">move</a></span>(java.io.File from,
|
||||
java.io.File to)</code> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
|
||||
@ -288,7 +283,7 @@ implements <a href="../../../../../../net/ME1312/SubServers/Host/Network/PacketI
|
||||
<a name="getVersion--">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<ul class="blockListLast">
|
||||
<li class="blockList">
|
||||
<h4>getVersion</h4>
|
||||
<pre>public <a href="../../../../../../net/ME1312/SubServers/Host/Library/Version/Version.html" title="class in net.ME1312.SubServers.Host.Library.Version">Version</a> getVersion()</pre>
|
||||
@ -304,16 +299,6 @@ implements <a href="../../../../../../net/ME1312/SubServers/Host/Network/PacketI
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="move-java.io.File-java.io.File-">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockListLast">
|
||||
<li class="blockList">
|
||||
<h4>move</h4>
|
||||
<pre>public void move(java.io.File from,
|
||||
java.io.File to)</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
Binary file not shown.
Binary file not shown.
@ -151,7 +151,8 @@ public class InternalHost extends Host {
|
||||
else to.delete();
|
||||
}
|
||||
to.mkdirs();
|
||||
Files.move(from, to);
|
||||
Util.copyDirectory(from, to);
|
||||
Util.deleteDirectory(from);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -195,7 +196,8 @@ public class InternalHost extends Host {
|
||||
else to.delete();
|
||||
}
|
||||
to.mkdirs();
|
||||
Files.move(from, to);
|
||||
Util.copyDirectory(from, to);
|
||||
Util.deleteDirectory(from);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -387,47 +387,4 @@ public class InternalSubCreator extends SubCreator {
|
||||
writer.write(content);
|
||||
writer.close();
|
||||
}
|
||||
private void copyFolder(File source, File destination) {
|
||||
if (source.isDirectory()) {
|
||||
if (!destination.exists()) {
|
||||
destination.mkdirs();
|
||||
}
|
||||
|
||||
String files[] = source.list();
|
||||
|
||||
for (String file : files) {
|
||||
File srcFile = new File(source, file);
|
||||
File destFile = new File(destination, file);
|
||||
|
||||
copyFolder(srcFile, destFile);
|
||||
}
|
||||
} else {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
|
||||
try {
|
||||
in = new FileInputStream(source);
|
||||
out = new FileOutputStream(destination);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
int length;
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -199,6 +199,9 @@ public final class Util {
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
if (in != null) in.close();
|
||||
|
@ -128,10 +128,10 @@ public class Version implements Serializable, Comparable<Version> {
|
||||
/*
|
||||
* The internal toString() method
|
||||
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
|
||||
* 5 1.0.0 0 7 9
|
||||
* 5 1.0.0 0 7
|
||||
*/
|
||||
private String toInternalString() {
|
||||
String str = type.id + ' ' + string + ' ' + '9';
|
||||
String str = type.id + ' ' + string;
|
||||
if (parent != null) str = parent.toInternalString()+' '+str;
|
||||
return str;
|
||||
}
|
||||
|
@ -138,7 +138,9 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
try {
|
||||
if (file.isDirectory()) {
|
||||
if (new UniversalFile(dir, "Recently Deleted:" + file.getName() + ":info.json").exists()) {
|
||||
JSONObject json = new JSONObject(Util.readAll(new FileReader(new UniversalFile(dir, "Recently Deleted:" + file.getName() + ":info.json"))));
|
||||
FileReader reader = new FileReader(new UniversalFile(dir, "Recently Deleted:" + file.getName() + ":info.json"));
|
||||
JSONObject json = new JSONObject(Util.readAll(reader));
|
||||
reader.close();
|
||||
if (json.keySet().contains("Timestamp")) {
|
||||
if (TimeUnit.MILLISECONDS.toDays(Calendar.getInstance().getTime().getTime() - json.getLong("Timestamp")) >= 7) {
|
||||
Util.deleteDirectory(file);
|
||||
|
Binary file not shown.
@ -195,6 +195,9 @@ public final class Util {
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
if (in != null) in.close();
|
||||
|
@ -128,10 +128,10 @@ public class Version implements Serializable, Comparable<Version> {
|
||||
/*
|
||||
* The internal toString() method
|
||||
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
|
||||
* 5 1.0.0 0 7 9
|
||||
* 5 1.0.0 0 7
|
||||
*/
|
||||
private String toInternalString() {
|
||||
String str = type.id + ' ' + string + ' ' + '9';
|
||||
String str = type.id + ' ' + string;
|
||||
if (parent != null) str = parent.toInternalString()+' '+str;
|
||||
return str;
|
||||
}
|
||||
|
Binary file not shown.
@ -126,7 +126,8 @@ public final class ExHost {
|
||||
try {
|
||||
if (file.isDirectory()) {
|
||||
if (new UniversalFile(dir, "Recently Deleted:" + file.getName() + ":info.json").exists()) {
|
||||
JSONObject json = new JSONObject(Util.readAll(new FileReader(new UniversalFile(dir, "Recently Deleted:" + file.getName() + ":info.json"))));
|
||||
FileReader reader = new FileReader(new UniversalFile(dir, "Recently Deleted:" + file.getName() + ":info.json"));
|
||||
JSONObject json = new JSONObject(Util.readAll(reader));
|
||||
if (json.keySet().contains("Timestamp")) {
|
||||
if (TimeUnit.MILLISECONDS.toDays(Calendar.getInstance().getTime().getTime() - json.getLong("Timestamp")) >= 7) {
|
||||
Util.deleteDirectory(file);
|
||||
|
@ -402,7 +402,9 @@ public class SubCreator {
|
||||
private void generateProperties(File dir, int port) throws IOException {
|
||||
File file = new File(dir, "server.properties");
|
||||
if (!file.exists()) file.createNewFile();
|
||||
String content = Util.readAll(new BufferedReader(new InputStreamReader(new FileInputStream(file)))).replace("server-port=", "server-port=" + port).replace("server-ip=", "server-ip=" + host.config.get().getSection("Settings").getRawString("Server-Bind"));
|
||||
FileInputStream is = new FileInputStream(file);
|
||||
String content = Util.readAll(new BufferedReader(new InputStreamReader(is))).replace("server-port=", "server-port=" + port).replace("server-ip=", "server-ip=" + host.config.get().getSection("Settings").getRawString("Server-Bind"));
|
||||
is.close();
|
||||
file.delete();
|
||||
PrintWriter writer = new PrintWriter(file, "UTF-8");
|
||||
writer.write(content);
|
||||
|
@ -196,6 +196,9 @@ public final class Util {
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
if (in != null) in.close();
|
||||
|
@ -128,10 +128,10 @@ public class Version implements Serializable, Comparable<Version> {
|
||||
/*
|
||||
* The internal toString() method
|
||||
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
|
||||
* 5 1.0.0 0 7 9
|
||||
* 5 1.0.0 0 7
|
||||
*/
|
||||
private String toInternalString() {
|
||||
String str = type.id + ' ' + string + ' ' + '9';
|
||||
String str = type.id + ' ' + string;
|
||||
if (parent != null) str = parent.toInternalString()+' '+str;
|
||||
return str;
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ public class PacketExDeleteServer implements PacketIn, PacketOut {
|
||||
else to.delete();
|
||||
}
|
||||
to.mkdirs();
|
||||
move(from, to);
|
||||
Util.copyDirectory(from, to);
|
||||
Util.deleteDirectory(from);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -116,18 +117,4 @@ public class PacketExDeleteServer implements PacketIn, PacketOut {
|
||||
public Version getVersion() {
|
||||
return new Version("2.11.0a");
|
||||
}
|
||||
|
||||
public void move(File from, File to) {
|
||||
if (from.isDirectory()) {
|
||||
to.mkdir();
|
||||
for (File file : from.listFiles()) move(file, new File(to, file.getName()));
|
||||
from.delete();
|
||||
} else {
|
||||
try {
|
||||
Files.move(from.toPath(), to.toPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@ -193,6 +193,9 @@ public final class Util {
|
||||
while ((length = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
if (in != null) in.close();
|
||||
|
@ -128,10 +128,10 @@ public class Version implements Serializable, Comparable<Version> {
|
||||
/*
|
||||
* The internal toString() method
|
||||
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
|
||||
* 5 1.0.0 0 7 9
|
||||
* 5 1.0.0 0 7
|
||||
*/
|
||||
private String toInternalString() {
|
||||
String str = type.id + ' ' + string + ' ' + '9';
|
||||
String str = type.id + ' ' + string;
|
||||
if (parent != null) str = parent.toInternalString()+' '+str;
|
||||
return str;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user