-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.h
More file actions
51 lines (37 loc) · 1.17 KB
/
disk.h
File metadata and controls
51 lines (37 loc) · 1.17 KB
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
#ifndef __DISK_H__
#define __DISK_H__
#include <vector>
#include <string>
#include <memory>
#include "bitMap.h"
#include "inode.h"
using std::vector;
using std::string;
using std::make_shared;
using std::shared_ptr;
class Disk{
// Vector of bools used to mark the population/occupancy.
BitMap blocks;
unsigned int totalSize; // in KB
int blockSize; // in KB
// Hash table containing information about the files.
vector<shared_ptr<iNode>> index_nodes;
// Ensures file id supplied by a save action does not already exist.
bool validateFileID(string fileID);
public:
Disk(unsigned int totalSize = 0, int blockSize = 0);
~Disk() = default;
// Returns a vector of ints representing the blocks 'fileID' has been saved to.
vector<int> save(string fileID, unsigned int fileSize);
// Returns a vector of ints representing the blocks 'fileID' occupies.
vector<int> read(string fileID);
// Erases 'fileID' from the disk.
void del(string fileID);
// Returns the space available
int availableSpace() noexcept;
// Returns the totalSize
int getTotalSize() noexcept;
// Lists the available files
void listFiles() noexcept;
};
#endif