-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuiltInCommands.h
executable file
·163 lines (142 loc) · 3.6 KB
/
BuiltInCommands.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#pragma once
#include "Commands.h"
#include "SmallShell.h"
#include "JobsList.h"
#include <iostream>
#include <string>
#include <fstream>
#include <sys/stat.h>
class BuiltInCommand : public Command
{
public:
std::string output_file;
BuiltInCommand(const char *cmd_line) : Command(cmd_line)
{
// handle > redirection
std::string cmd_str = std::string(cmd_line);
}
virtual ~BuiltInCommand() {}
};
class ChangeDirCommand : public BuiltInCommand
{
public:
std::string path;
public:
ChangeDirCommand(const char *cmd_line);
virtual ~ChangeDirCommand() {}
void execute() override;
};
class GetCurrDirCommand : public BuiltInCommand
{
public:
GetCurrDirCommand(const char *cmd_line);
virtual ~GetCurrDirCommand() {}
void execute() override;
};
class ShowPidCommand : public BuiltInCommand
{
public:
ShowPidCommand(const char *cmd_line);
virtual ~ShowPidCommand() {}
void execute() override;
};
class ChangePromptCommand : public BuiltInCommand
{
std::string prompt;
public:
ChangePromptCommand(const char *cmd_line) : BuiltInCommand(cmd_line) {}
// ChangePromptCommand(const std::vector<std::string> &cmd_v);
virtual ~ChangePromptCommand() {}
void execute() override;
};
class JobsList;
class QuitCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
QuitCommand(const char *cmd_line) : BuiltInCommand(cmd_line){};
virtual ~QuitCommand() {}
void execute() override;
};
class JobsCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
JobsCommand(const char *cmd_line);
virtual ~JobsCommand() {}
void execute() override;
};
class ForegroundCommand : public BuiltInCommand
{
// TODO: Add your data members
JobsList *jobs;
public:
ForegroundCommand(const char *cmd_line);
virtual ~ForegroundCommand() {}
void execute() override;
void MoveJobToForeground(JobsList::JobEntry &job);
};
class BackgroundCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
BackgroundCommand(const char *cmd_line) : BuiltInCommand(cmd_line) {}
virtual ~BackgroundCommand() {}
void execute() override;
};
class TimeoutCommand : public BuiltInCommand
{
/* Bonus */
// TODO: Add your data members
public:
explicit TimeoutCommand(const char *cmd_line);
virtual ~TimeoutCommand() {}
void execute() override;
};
class ChmodCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
ChmodCommand(const char *cmd_line);
virtual ~ChmodCommand() {}
void execute() override;
};
class GetFileTypeCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
GetFileTypeCommand(const char *cmd_line);
virtual ~GetFileTypeCommand() {}
void execute() override;
};
class SetcoreCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
SetcoreCommand(const char *cmd_line);
virtual ~SetcoreCommand() {}
void execute() override;
};
class KillCommand : public BuiltInCommand
{
// TODO: Add your data members
public:
KillCommand(const char *cmd_line) : BuiltInCommand(cmd_line){};
virtual ~KillCommand() {}
void execute() override;
};
// setcore <job_id> <core_num>
class SetCoreCommand : public BuiltInCommand
{
public:
SetCoreCommand(const char *cmd_line) : BuiltInCommand(cmd_line){};
virtual ~SetCoreCommand() {}
void execute() override;
};
class ChangeFileModeCommand : public BuiltInCommand
{
public:
ChangeFileModeCommand(const char *cmd_line) : BuiltInCommand(cmd_line){};
virtual ~ChangeFileModeCommand() {}
void execute() override;
};