diff --git a/src/me/macjuul/chfiles/Functions/copy_file.java b/src/me/macjuul/chfiles/Functions/copy_file.java index c408516..07b481b 100644 --- a/src/me/macjuul/chfiles/Functions/copy_file.java +++ b/src/me/macjuul/chfiles/Functions/copy_file.java @@ -4,7 +4,6 @@ import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.api; import com.laytonsmith.core.Security; -import com.laytonsmith.core.constructs.CBoolean; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; @@ -48,13 +47,13 @@ public Boolean runAsync() { public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File fromLoc = new File(t.file().getParentFile(), args[0].val()); File toLoc = new File(t.file().getParentFile(), args[1].val()); - if(!Security.CheckSecurity(fromLoc) || !Security.CheckSecurity(toLoc)) { + if (!Security.CheckSecurity(fromLoc) || !Security.CheckSecurity(toLoc)) { throw new CRESecurityException("You do not have access to some of the files", t); } try { - if(fromLoc.isDirectory()) { + if (fromLoc.isDirectory()) { FileUtils.copyDirectory(fromLoc, toLoc); - } else if(fromLoc.isFile()) { + } else if (fromLoc.isFile()) { FileUtils.copyFile(fromLoc, toLoc); } return CVoid.VOID; diff --git a/src/me/macjuul/chfiles/Functions/create_dir.java b/src/me/macjuul/chfiles/Functions/create_dir.java index 147d04b..b05d020 100644 --- a/src/me/macjuul/chfiles/Functions/create_dir.java +++ b/src/me/macjuul/chfiles/Functions/create_dir.java @@ -1,6 +1,5 @@ package me.macjuul.chfiles.Functions; -import com.laytonsmith.PureUtilities.Common.FileUtil; import com.laytonsmith.PureUtilities.SimpleVersion; import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.api; @@ -16,7 +15,6 @@ import com.laytonsmith.core.functions.AbstractFunction; import java.io.File; -import java.io.IOException; /** * Created by bexco on 2016-03-26. @@ -44,11 +42,11 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } try { - if(loc.exists()) { + if (loc.exists()) { throw new CREIOException(loc.getAbsolutePath() + "Already Exists", t); } loc.mkdir(); diff --git a/src/me/macjuul/chfiles/Functions/create_file.java b/src/me/macjuul/chfiles/Functions/create_file.java index ff6ff08..626fa3f 100644 --- a/src/me/macjuul/chfiles/Functions/create_file.java +++ b/src/me/macjuul/chfiles/Functions/create_file.java @@ -1,6 +1,5 @@ package me.macjuul.chfiles.Functions; -import com.laytonsmith.PureUtilities.Common.FileUtil; import com.laytonsmith.PureUtilities.SimpleVersion; import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.api; @@ -44,11 +43,11 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } try { - if(loc.exists()) { + if (loc.exists()) { throw new CREIOException(loc.getAbsolutePath() + "Already Exists", t); } loc.createNewFile(); diff --git a/src/me/macjuul/chfiles/Functions/delete_file.java b/src/me/macjuul/chfiles/Functions/delete_file.java index 84cbd78..ddf8238 100644 --- a/src/me/macjuul/chfiles/Functions/delete_file.java +++ b/src/me/macjuul/chfiles/Functions/delete_file.java @@ -1,6 +1,5 @@ package me.macjuul.chfiles.Functions; -import com.laytonsmith.PureUtilities.Common.FileUtil; import com.laytonsmith.PureUtilities.SimpleVersion; import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.api; @@ -45,16 +44,16 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } try { - if(!loc.exists()) { + if (!loc.exists()) { throw new CREIOException(loc.getAbsolutePath() + "Doesn't exists", t); } - if(loc.isDirectory()) { + if (loc.isDirectory()) { FileUtils.deleteDirectory(loc); - } else if(loc.isFile()) { + } else if (loc.isFile()) { FileUtils.forceDelete(loc); } return CVoid.VOID; diff --git a/src/me/macjuul/chfiles/Functions/file_exists.java b/src/me/macjuul/chfiles/Functions/file_exists.java index fc89d4d..5b58f41 100644 --- a/src/me/macjuul/chfiles/Functions/file_exists.java +++ b/src/me/macjuul/chfiles/Functions/file_exists.java @@ -5,20 +5,15 @@ import com.laytonsmith.annotations.api; import com.laytonsmith.core.Security; import com.laytonsmith.core.constructs.CBoolean; -import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.environments.Environment; -import com.laytonsmith.core.exceptions.CRE.CREIOException; import com.laytonsmith.core.exceptions.CRE.CRESecurityException; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.functions.AbstractFunction; -import com.laytonsmith.libs.org.apache.commons.io.FileUtils; -import org.bukkit.Bukkit; import java.io.File; -import java.io.IOException; /** * Created by bexco on 2016-03-16. @@ -45,7 +40,7 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } return CBoolean.get(loc.exists()); diff --git a/src/me/macjuul/chfiles/Functions/is_dir.java b/src/me/macjuul/chfiles/Functions/is_dir.java index 1733cef..6554cb5 100644 --- a/src/me/macjuul/chfiles/Functions/is_dir.java +++ b/src/me/macjuul/chfiles/Functions/is_dir.java @@ -40,7 +40,7 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } return CBoolean.get(loc.isDirectory()); diff --git a/src/me/macjuul/chfiles/Functions/is_file.java b/src/me/macjuul/chfiles/Functions/is_file.java index b8d0b7a..36c45e0 100644 --- a/src/me/macjuul/chfiles/Functions/is_file.java +++ b/src/me/macjuul/chfiles/Functions/is_file.java @@ -40,7 +40,7 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } return CBoolean.get(loc.isFile()); diff --git a/src/me/macjuul/chfiles/Functions/list_files.java b/src/me/macjuul/chfiles/Functions/list_files.java index 7b82a0c..091a35c 100644 --- a/src/me/macjuul/chfiles/Functions/list_files.java +++ b/src/me/macjuul/chfiles/Functions/list_files.java @@ -4,7 +4,10 @@ import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.api; import com.laytonsmith.core.Security; -import com.laytonsmith.core.constructs.*; +import com.laytonsmith.core.constructs.CArray; +import com.laytonsmith.core.constructs.CString; +import com.laytonsmith.core.constructs.Construct; +import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREIOException; import com.laytonsmith.core.exceptions.CRE.CRESecurityException; @@ -40,13 +43,13 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } CArray ret = new CArray(t); - if(loc.exists() && loc.isDirectory()) { + if (loc.exists() && loc.isDirectory()) { String[] list = loc.list(); - for(String file:list) { + for (String file : list) { ret.push(new CString(file, t), t); } } else { diff --git a/src/me/macjuul/chfiles/Functions/rename_file.java b/src/me/macjuul/chfiles/Functions/rename_file.java index 1340108..3cb9150 100644 --- a/src/me/macjuul/chfiles/Functions/rename_file.java +++ b/src/me/macjuul/chfiles/Functions/rename_file.java @@ -13,10 +13,8 @@ import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.functions.AbstractFunction; -import com.laytonsmith.libs.org.apache.commons.io.FileUtils; import java.io.File; -import java.io.IOException; /** * Created by bexco on 2016-03-16. @@ -44,15 +42,15 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } - if(!loc.exists()) { + if (!loc.exists()) { throw new CREIOException(loc.getAbsolutePath() + "Doesn't exists", t); } - if(loc.isDirectory()) { + if (loc.isDirectory()) { loc.renameTo(new File(loc.getParent() + File.pathSeparator + args[1].val() + File.pathSeparator)); - } else if(loc.isFile()) { + } else if (loc.isFile()) { loc.renameTo(new File(loc.getParent() + File.pathSeparator + args[1].val())); } return CVoid.VOID; diff --git a/src/me/macjuul/chfiles/Functions/write_file.java b/src/me/macjuul/chfiles/Functions/write_file.java index b973460..9bf84c3 100644 --- a/src/me/macjuul/chfiles/Functions/write_file.java +++ b/src/me/macjuul/chfiles/Functions/write_file.java @@ -44,18 +44,18 @@ public Boolean runAsync() { @Override public Construct exec(Target t, Environment env, Construct... args) throws ConfigRuntimeException { File loc = new File(t.file().getParentFile(), args[0].val()); - if(!Security.CheckSecurity(loc)) { + if (!Security.CheckSecurity(loc)) { throw new CRESecurityException("You do not have permission to access the file '" + loc.getAbsolutePath() + "'", t); } try { - if(!loc.exists()) { + if (!loc.exists()) { throw new CREIOException(loc.getAbsolutePath() + "Doesn't exists", t); } - if(args.length == 3 && args[2].val().toUpperCase().equals("OVERWRITE")) { - FileUtil.write(args[1].val(), loc, 0); - } else { - FileUtil.write(args[1].val(), loc, 1); - } + if (args.length == 3 && args[2].val().toUpperCase().equals("OVERWRITE")) { + FileUtil.write(args[1].val(), loc, 0); + } else { + FileUtil.write(args[1].val(), loc, 1); + } return CVoid.VOID; } catch (IOException e) {