-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathterm.cpp
More file actions
44 lines (37 loc) · 977 Bytes
/
Copy pathterm.cpp
File metadata and controls
44 lines (37 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// Created by Fish on 2020/12/26.
//
#ifndef FILE_SYSTEM_DESIGN_FS_TERM
#define FILE_SYSTEM_DESIGN_FS_TERM
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include "cmd.hpp"
#include "cpp_operator.h"
using namespace std;
vector<string> spilt_s(string in) {
string in_s;
stringstream ss(in);
vector<string> in_vec;
while(ss>>in_s) {
in_vec.push_back(in_s);
}
return in_vec;
}
command parse_commands(string cmd) {
if (cmd == "cd") return CD;
else if (cmd == "ls") return LS;
else if (cmd == "mkdir") return MKDIR;
else if (cmd == "rmdir") return RMDIR;
else if (cmd == "create") return CREATE;
else if (cmd == "rm") return RM;
else if (cmd == "open") return OPEN;
else if (cmd == "close") return CLOSE;
else if (cmd == "read") return READ;
else if (cmd == "write") return WRITE;
else if (cmd == "exit") return EXIT;
return UNKNOWN;
}
#endif