-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFileSys.h
79 lines (55 loc) · 1.8 KB
/
FileSys.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
// CPSC 3500: File System
// Implements the file system commands that are available to the shell.
#ifndef FILESYS_H
#define FILESYS_H
#include <sstream>
using namespace std;
#include "BasicFileSys.h"
class FileSys {
public:
// mounts the file system
void mount(int sock);
// unmounts the file system
void unmount();
// make a directory
void mkdir(const char *name);
// switch to a directory
void cd(const char *name);
// switch to home directory
void home();
// remove a directory
void rmdir(const char *name);
// list the contents of current directory
void ls();
// create an empty data file
void create(const char *name);
// append data to a data file
void append(const char *name, const char *data);
// display the contents of a data file
void cat(const char *name);
// display the first N bytes of the file
void head(const char *name, unsigned int n);
// delete a data file
void rm(const char *name);
// display stats about file or directory
void stat(const char *name);
// Executes the command. Returns true for quit and false otherwise.
bool execute_command(string command_str);
private:
BasicFileSys bfs; // basic file system
short curr_dir; // current directory
int fs_sock; // file server socket
// data structure for command
struct Command
{
string name; // name of command
string file_name; // name of file
string append_data; // append data (append only)
};
// Parses a command into a command struct. Returned name is blank
// for invalid command lines.
struct Command parse_command(string command_str);
// Additional private variables and Helper functions - if desired
const bool is_directory(short block_num);
};
#endif