@@ -104,7 +104,7 @@ private final void viewDirTreeHelper(int indent, File file) {
104
104
105
105
private final void navPreviousDirectory ()throws Exception
106
106
{
107
- _presentWorkingDirectory = _presentWorkingDirectory .substring (0 , _presentWorkingDirectory .length () - 1 );
107
+ _presentWorkingDirectory = _presentWorkingDirectory .substring (0 , _presentWorkingDirectory .length () - 1 );
108
108
_presentWorkingDirectory = _presentWorkingDirectory .replace (_presentWorkingDirectory .substring (_presentWorkingDirectory .lastIndexOf ('/' ), _presentWorkingDirectory .length ()), "/" );
109
109
if (_presentWorkingDirectory .equals ("./Users/Cataphract/" ))
110
110
{
@@ -156,7 +156,7 @@ private final void copyMoveHelper(File source, File destination, boolean move)th
156
156
else
157
157
{
158
158
Files .copy (source .toPath (), destination .toPath (), StandardCopyOption .REPLACE_EXISTING );
159
- if (move )
159
+ if (move )
160
160
{
161
161
Files .delete (source .toPath ());
162
162
}
@@ -218,7 +218,7 @@ public void fileManagementLogic()throws Exception
218
218
String inputValue = "" ;
219
219
do
220
220
{
221
- inputValue = console .readLine (_name + "@" + _presentWorkingDirectory .replace (_username , _name ) + "> " );
221
+ inputValue = console .readLine (_name + "@" + _presentWorkingDirectory .replace (_username , _name ) + "> " );
222
222
grinchInterpreter (inputValue );
223
223
}
224
224
while (!inputValue .equalsIgnoreCase ("exit" ));
@@ -274,6 +274,17 @@ private void grinchInterpreter(String command)throws Exception
274
274
break ;
275
275
276
276
case "edit" :
277
+ if (commandArray .length < 2 )
278
+ IOStreams .printError ("Invalid Syntax." );
279
+ else
280
+ FileWrite .editFile (commandArray [1 ], _presentWorkingDirectory );
281
+ break ;
282
+
283
+ case "read" :
284
+ if (commandArray .length < 2 )
285
+ IOStreams .printError ("Invalid Syntax." );
286
+ else
287
+ new FileRead ().readUserFile (_presentWorkingDirectory + commandArray [1 ]);
277
288
break ;
278
289
279
290
case "pwd" :
@@ -301,10 +312,14 @@ private void grinchInterpreter(String command)throws Exception
301
312
break ;
302
313
303
314
case "download" :
315
+ if (commandArray .length < 3 )
316
+ IOStreams .printError ("Invalid Syntax." );
317
+ else
318
+ new FileDownload (_username ).downloadFile (commandArray [1 ], commandArray [2 ]);
304
319
break ;
305
320
306
321
case "home" :
307
- resetToHomeDirectory ();
322
+ resetToHomeDirectory ();
308
323
break ;
309
324
310
325
case "exit" :
@@ -315,5 +330,4 @@ private void grinchInterpreter(String command)throws Exception
315
330
Anvil .anvilInterpreter (commandArray );
316
331
}
317
332
}
318
-
319
333
}
0 commit comments