@@ -22,14 +22,14 @@ public FileManagement(String username)throws Exception
22
22
{
23
23
_username = username ;
24
24
_name = new Cataphract .API .Dragon .Login (username ).getNameLogic ();
25
- _defaultPath = "./Users/Cataphract/" + _username ;
25
+ _defaultPath = "./Users/Cataphract/" + _username + "/ " ;
26
26
}
27
27
28
28
/*****************************************
29
29
* AUTHENTICATION/LOGIN METHOD *
30
30
*****************************************/
31
31
32
- public final boolean login ()throws Exception
32
+ private final boolean login ()throws Exception
33
33
{
34
34
IOStreams .println ("Username: " + _username );
35
35
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
157
157
public void fileManagementLogic ()throws Exception
158
158
{
159
159
// AUTHENTICATION LOGIC OMITTED FOR THE MOMENT.
160
-
161
- String inputValue = "" ;
162
- do
160
+ if (login ())
163
161
{
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" ));
166
169
}
167
- while (!inputValue .equalsIgnoreCase ("exit" ));
170
+ else
171
+ IOStreams .printError ("Invalid Credentials." );
168
172
}
169
173
170
174
private void grinchInterpreter (String command )throws Exception
@@ -176,33 +180,55 @@ private void grinchInterpreter(String command)throws Exception
176
180
case "move" :
177
181
case "mov" :
178
182
case "mv" :
183
+ if (commandArray .length < 3 )
184
+ IOStreams .printError ("Invalid Syntax." );
185
+ else
186
+ copyMoveEntity (commandArray [1 ], commandArray [2 ], true );
179
187
break ;
180
188
181
189
case "copy" :
182
190
case "cp" :
191
+ if (commandArray .length < 3 )
192
+ IOStreams .printError ("Invalid Syntax." );
193
+ else
194
+ copyMoveEntity (commandArray [1 ], commandArray [2 ], false );
183
195
break ;
184
196
185
197
case "delete" :
186
198
case "del" :
187
199
case "rm" :
200
+ if (commandArray .length < 2 )
201
+ IOStreams .printError ("Invalid Syntax." );
202
+ else
203
+ deleteDirectoryFile (commandArray [1 ]);
188
204
break ;
189
205
190
206
case "rename" :
207
+ if (commandArray .length < 2 )
208
+ IOStreams .printError ("Invalid Syntax." );
209
+ else
210
+ renameEntity (commandArray [1 ], commandArray [2 ]);
191
211
break ;
192
212
193
213
case "mkdir" :
214
+ if (commandArray .length < 2 )
215
+ IOStreams .printError ("Invalid Syntax." );
216
+ else
217
+ makeDirectory (commandArray [1 ]);
194
218
break ;
195
219
196
220
case "edit" :
197
221
break ;
198
222
199
223
case "pwd" :
224
+ IOStreams .println (_defaultPath + _presentWorkingDirectory );
200
225
break ;
201
226
202
227
case "cd" :
203
228
break ;
204
229
205
230
case "tree" :
231
+ viewDirectoryTree ();
206
232
break ;
207
233
208
234
case "dir" :
0 commit comments