-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFolder.cpp
More file actions
38 lines (29 loc) · 826 Bytes
/
Folder.cpp
File metadata and controls
38 lines (29 loc) · 826 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
#include "Folder.h"
Folder::Folder() : _parent(nullptr) {}
Folder::~Folder() {
for (Item* item : _contents) {
delete item;
}
}
Folder* Folder::getParent() const {
return _parent;
}
void Folder::setParent(Folder* parent) {
this->_parent = parent;
}
void Folder::printDetails() const {
std::cout << this->getTime() << " <DIR> " << this->getName() << std::endl;
}
// Used when generating all the vectors of objects
void Folder::addItem(Item* item) {
_contents.push_back(item);
}
// Read only version to use with dir command
const std::vector<Item*>& Folder::getContents() const {
return _contents;
}
// A function with write access for commands such as sort
std::vector<Item*>& Folder::editContents() {
return _contents;
}
bool Folder::isFile() const { return false; }