Skip to content

Commit 8737096

Browse files
committed
Code upgrade
* Fix issues with FileUnzip * Activate functionality in FileManagement * Added an alert to recommend the user to restart the program * Activate FileManagement system * Replace the viewSycoraxInformation() with viewBuildInfo() for consistency * Activate debug method in Build class
1 parent 03f93ab commit 8737096

File tree

5 files changed

+54
-30
lines changed

5 files changed

+54
-30
lines changed

Source/Cataphract/API/Build.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public static void viewBuildInfo()
5959
IOStreams.println(_Branding + "\n");
6060
//new Build().debug();
6161
IOStreams.printWarning("Features disabled until integration tests are complete.\n\nIntegration test ongoing.\nCore features are almost complete.\n");
62+
63+
debug();
6264
}
6365

6466
/**
@@ -100,7 +102,7 @@ public static void clearScreen()
100102
}
101103
}
102104

103-
private void debug()
105+
private static void debug()
104106
{
105107
//int mb = 1024 * 1024;
106108
// get Runtime instance

Source/Cataphract/API/Wraith/Archive/FileUnzip.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package Cataphract.API.Wraith.Archive;
1717

18-
import java.io.FileInputStream;
18+
import java.io.FileInputStream;
1919
import java.io.FileNotFoundException;
2020
import java.io.FileOutputStream;
2121

@@ -121,7 +121,7 @@ private void unzipLogic(String zipFilePath, String outputDirectory)
121121
// Create directories for file entries and write the file content
122122
Files.createDirectories(entryPath.getParent());
123123
try
124-
{
124+
{
125125
if(updateMode)
126126
{
127127
IOStreams.printInfo("Installing File: " + entryName);
@@ -139,9 +139,14 @@ private void unzipLogic(String zipFilePath, String outputDirectory)
139139
IOStreams.printError("File Error: " + entryName);
140140
}
141141
}
142-
fos.close();
143-
zipIn.closeEntry();
144142
}
143+
zipIn.closeEntry();
144+
fos.close();
145+
}
146+
catch(Exception e)
147+
{
148+
IOStreams.println("Error: " + e);
149+
e.printStackTrace();
145150
}
146151
}
147152
catch (FileNotFoundException fnfe)

Source/Cataphract/API/Wraith/FileManagement.java

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public FileManagement(String username)throws Exception
2222
{
2323
_username = username;
2424
_name = new Cataphract.API.Dragon.Login(username).getNameLogic();
25-
_defaultPath = "./Users/Cataphract/" + _username;
25+
_defaultPath = "./Users/Cataphract/" + _username + "/ ";
2626
}
2727

2828
/*****************************************
2929
* AUTHENTICATION/LOGIN METHOD *
3030
*****************************************/
3131

32-
public final boolean login()throws Exception
32+
private final boolean login()throws Exception
3333
{
3434
IOStreams.println("Username: " + _username);
3535
return new Cataphract.API.Dragon.Login(_username).authenticationLogic(Cryptography.stringToSHA3_256(console.readLine("Password: ")), Cryptography.stringToSHA3_256(console.readLine("Security Key: ")));
@@ -157,14 +157,18 @@ private final void copyMoveHelper(File source, File destination, boolean move)th
157157
public void fileManagementLogic()throws Exception
158158
{
159159
// AUTHENTICATION LOGIC OMITTED FOR THE MOMENT.
160-
161-
String inputValue = "";
162-
do
160+
if(login())
163161
{
164-
inputValue = console.readLine(_name + "@" + _presentWorkingDirectory.replace(_username, _name));
165-
grinchInterpreter(inputValue);
162+
String inputValue = "";
163+
do
164+
{
165+
inputValue = console.readLine(_name + "@" + _presentWorkingDirectory.replace(_username, _name) + "> ");
166+
grinchInterpreter(inputValue);
167+
}
168+
while(!inputValue.equalsIgnoreCase("exit"));
166169
}
167-
while(!inputValue.equalsIgnoreCase("exit"));
170+
else
171+
IOStreams.printError("Invalid Credentials.");
168172
}
169173

170174
private void grinchInterpreter(String command)throws Exception
@@ -176,33 +180,55 @@ private void grinchInterpreter(String command)throws Exception
176180
case "move":
177181
case "mov":
178182
case "mv":
183+
if(commandArray.length < 3)
184+
IOStreams.printError("Invalid Syntax.");
185+
else
186+
copyMoveEntity(commandArray[1], commandArray[2], true);
179187
break;
180188

181189
case "copy":
182190
case "cp":
191+
if(commandArray.length < 3)
192+
IOStreams.printError("Invalid Syntax.");
193+
else
194+
copyMoveEntity(commandArray[1], commandArray[2], false);
183195
break;
184196

185197
case "delete":
186198
case "del":
187199
case "rm":
200+
if(commandArray.length < 2)
201+
IOStreams.printError("Invalid Syntax.");
202+
else
203+
deleteDirectoryFile(commandArray[1]);
188204
break;
189205

190206
case "rename":
207+
if(commandArray.length < 2)
208+
IOStreams.printError("Invalid Syntax.");
209+
else
210+
renameEntity(commandArray[1], commandArray[2]);
191211
break;
192212

193213
case "mkdir":
214+
if(commandArray.length < 2)
215+
IOStreams.printError("Invalid Syntax.");
216+
else
217+
makeDirectory(commandArray[1]);
194218
break;
195219

196220
case "edit":
197221
break;
198222

199223
case "pwd":
224+
IOStreams.println(_defaultPath + _presentWorkingDirectory);
200225
break;
201226

202227
case "cd":
203228
break;
204229

205230
case "tree":
231+
viewDirectoryTree();
206232
break;
207233

208234
case "dir":

Source/Cataphract/API/Wyvern/NionUpdate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void updater()throws Exception
6666

6767
downloadUpdate();
6868
installUpdate();
69+
IOStreams.printAttention("It is recommended to restart Cataphract for the updates to be reflected.");
6970
}
7071
else
7172
IOStreams.printError("Policy Configuration Error!");

Source/Cataphract/Core/SycoraxKernel.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void startSycoraxKernel() throws Exception
5454
IOStreams.printError("Incorrect Credentials! Please try again.");
5555
loginCounterLogic();
5656
}
57-
viewSycoraxInformation();
57+
Build.viewBuildInfo();
5858
IOStreams.printInfo("Login Successful. Loading Sycorax Kernel...");
5959
_loginAttemptsRemaining = 5;
6060
fetchUserDetails();
@@ -97,13 +97,9 @@ private void commandProcessor(String input)throws Exception
9797
case "grinch":
9898
case "filemanagement":
9999
case "files":
100-
//new Cataphract.API.Wraith.FileManagement(_username).fileManagerLogic();
100+
new Cataphract.API.Wraith.FileManagement(_username).fileManagementLogic();
101101
break;
102102

103-
// case "clear":
104-
// viewSycoraxInformation();
105-
// break;
106-
107103
case "exit":
108104
System.exit(0);
109105
break;
@@ -115,6 +111,7 @@ private void commandProcessor(String input)throws Exception
115111

116112
case "update":
117113
new Cataphract.API.Wyvern.NionUpdate(_username).updater();
114+
new File("./Update.zip").delete();
118115
break;
119116

120117
case "usermgmt":
@@ -136,7 +133,7 @@ private void commandProcessor(String input)throws Exception
136133
IOStreams.printError("Module Usermgmt: " + commandArray[1] + " - Command Not Found");
137134
break;
138135
}
139-
viewSycoraxInformation();
136+
Build.viewBuildInfo();
140137
break;
141138

142139
default:
@@ -147,7 +144,7 @@ private void commandProcessor(String input)throws Exception
147144

148145
private boolean login() throws Exception
149146
{
150-
viewSycoraxInformation();
147+
Build.viewBuildInfo();
151148
IOStreams.printInfo("Authentication Attempts Left: " + _loginAttemptsRemaining);
152149
_username = Cryptography.stringToSHA3_256(console.readLine("> Username: "));
153150
String password = Cryptography.stringToSHA3_256(String.valueOf(console.readPassword("> Password: ")));
@@ -176,16 +173,9 @@ private void fetchUserDetails()throws Exception
176173
_prompt = _isUserAdmin?'!':'*';
177174
}
178175

179-
private void viewSycoraxInformation()
180-
{
181-
Build.clearScreen();
182-
IOStreams.println(Build._Branding);
183-
IOStreams.println("Powered by Sycorax Kernel.\n");
184-
}
185-
186176
private void lockConsole() throws Exception
187177
{
188-
viewSycoraxInformation();
178+
Build.viewBuildInfo();
189179

190180
String input = "";
191181

@@ -202,7 +192,7 @@ private void lockConsole() throws Exception
202192
IOStreams.printError("Incorrect PIN.");
203193
loginCounterLogic();
204194
}
205-
viewSycoraxInformation();
195+
Build.viewBuildInfo();
206196
}
207197

208198
private boolean challengePIN() throws Exception

0 commit comments

Comments
 (0)