-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectoryItem.hpp
More file actions
107 lines (90 loc) · 2.55 KB
/
DirectoryItem.hpp
File metadata and controls
107 lines (90 loc) · 2.55 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
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
#ifndef SEMESTRALNIPRACE_DIRECTORYITEM_HPP
#define SEMESTRALNIPRACE_DIRECTORYITEM_HPP
#include <cstdint>
#include "Constants.hpp"
/**
* Class representing a directory item
*/
class DirectoryItem {
public:
/**
* Default constructor for directory item
*/
DirectoryItem(int32_t inodeId, const char* itemName);
/**
* Copy constructor
* @param other - other directory item
*/
DirectoryItem(const DirectoryItem& other); // Copy constructor
/**
* Copy assignment operator
* @param other - other directory item
* @return reference to this directory item
*/
DirectoryItem& operator=(const DirectoryItem& other); // Copy assignment operator
/**
* Destructor for directory item
*/
~DirectoryItem(); // Destructor
/**
* Gets the inode id of the item
* @return inode id of the item
*/
int32_t getInode() const;
/**
* Sets the inode id of the item
* @param inodeId - inode id of the item
*/
void setInode(int32_t inodeId);
/**
* Gets the name of the item
* @return name of the item
*/
const char* getItemName() const;
/**
* Sets the name of the item
* @param itemName - name of the item
*/
void setItemName(const char* itemName);
/**
* Gets the next item
* @return next item
*/
DirectoryItem* getNext() const;
/**
* Sets the next item
* @param nextItem - next item
*/
void setNext(DirectoryItem* nextItem);
/**
* Gets the reference to the next item
* @return reference to the next item
*/
DirectoryItem*& getNextRef();
private:
int32_t inode;
char itemName[12];
DirectoryItem* next;
};
/**
* Creates a new directory item
* @param inodeId - inode id of the item
* @param name - name of the item
* @return new directory item
*/
DirectoryItem* createDirectoryItem(int32_t inodeId, const char* name);
/**
* Finds an item in a linked list of directory items by name
* @param firstItem - first item in the linked list
* @param name - name of the item to find
* @return found item or nullptr if the item was not found
*/
DirectoryItem* findItem(DirectoryItem* firstItem, const char* name);
/**
* Finds an item in a linked list of directory items by inode id
* @param firstItem - first item in the linked list
* @param inodeId - inode id of the item to find
* @return found item or nullptr if the item was not found
*/
DirectoryItem* findItemByInodeId(DirectoryItem* firstItem, int32_t inodeId);
#endif //SEMESTRALNIPRACE_DIRECTORYITEM_HPP