Andrew Gan opened merge request !3: Added 'addline', 'delline', 'source' cmd and reverted command parsing back to if-else structure at Chok Yip Lau / ece469_...

Andrew Gan
2020-05-18T18:14:59Z

Changes were mostly made in ostests.c

Changes to parse_cmd:
All cmd parsing reverted to if-else to make it easier for expanding available cmds.

Changes to 'cat' cmd:
An extra read_char call has been removed. Previously the first char was omitted.

Changes to FileRead():
Instead of returning FILE_EOF when remaining bytes is less than requested bytes, the remaining bytes are read and number of read bytes is returned.
This allows the user to read files of unknown size.
The EOF flag is set during this read attempt and returned in the next read attempt.

Changes to 'help' cmd:
Cmds now listed in alphabetic order.

Three new commands introduced and documented in 'help':

'addline' cmd:
addline [filename] < [newline]

'delline' cmd:
delline [filename]
delline doesnt delete the last line if only one line is left, but that is negligible as user might as well delete the file.

'source' cmd: source [filename]
Each line in the file is passed into the parse_cmd() through recursive call.

illustration:

lau:/ touch test
lau:/ addline test < mkdir a
lau:/ addline test < cd a
lau:/ addline test < mkdir b
lau:/ addline test < cd b
lau:/ addline test < touch c
lau:/ addline test < addline c < this file should be in /a/b with another file 'hi'
lau:/ addline test < touch hi
lau:/ addline test < addline hi < pwd
lau:/ addline test < source hi

lau:/ source test
/a/b/
lau:/a/b/ ls
./ ../ c hi
lau:/a/b/ cat c
this file should be in /a/b with another file 'hi'
lau:/a/b/ source hi
/a/b/