Stat.h
Go to the documentation of this file.
1 
22 #pragma once
23 
24 #include "NameBuffer.h"
25 #include "TimeStamp.h"
26 #include "Access.h"
27 #include "Compression.h"
28 #include "FileAttributes.h"
29 
30 namespace IFS
31 {
32 class IFileSystem;
33 
39 using FileHandle = int16_t;
40 
46 using FileID = uint32_t;
47 
51 struct Stat {
52  IFileSystem* fs{nullptr};
54  uint32_t size{0};
55  FileID id{0};
57  ACL acl{UserRole::None, UserRole::None};
59  Compression compression{};
60 
61  Stat()
62  {
63  }
64 
65  Stat(char* namebuf, uint16_t bufsize) : name(namebuf, bufsize)
66  {
67  }
68 
74  Stat& operator=(const Stat& rhs)
75  {
76  fs = rhs.fs;
77  name.copy(rhs.name);
78  size = rhs.size;
79  id = rhs.id;
81  attr = rhs.attr;
82  acl = rhs.acl;
83  mtime = rhs.mtime;
84  return *this;
85  }
86 
87  bool isDir() const
88  {
89  return attr[FileAttribute::Directory];
90  }
91 };
92 
97 struct NameStat : public Stat {
98 public:
99  NameStat() : Stat(buffer, sizeof(buffer))
100  {
101  }
102 
103  NameStat(const Stat& other) : NameStat()
104  {
105  *this = other;
106  }
107 
108  NameStat& operator=(const Stat& rhs)
109  {
110  *static_cast<Stat*>(this) = rhs;
111  return *this;
112  }
113 
114 private:
115  char buffer[256];
116 };
117 
118 } // namespace IFS
version of Stat with integrated name buffer
Definition: Stat.h:97
NameStat & operator=(const Stat &rhs)
Definition: Stat.h:108
Installable File System base class.
Definition: IFileSystem.h:95
FileAttributes attr
Definition: Stat.h:58
Compression compression
Definition: Stat.h:59
uint32_t size
Size of file in bytes.
Definition: Stat.h:54
int copy(const char *src, uint16_t srclen)
copies text from a source buffer into a name buffer
Definition: NameBuffer.h:95
Stat(char *namebuf, uint16_t bufsize)
Definition: Stat.h:65
FileID id
Internal file identifier.
Definition: Stat.h:55
ACL acl
Access Control.
Definition: Stat.h:57
int16_t FileHandle
File handle.
Definition: Stat.h:39
Definition: DirectoryTemplate.h:36
Stat()
Definition: Stat.h:61
Manage IFS timestamps stored as an unsigned 32-bit value.
Definition: TimeStamp.h:35
File Status structure.
Definition: Stat.h:51
uint32_t FileID
File identifier.
Definition: Stat.h:46
NameStat()
Definition: Stat.h:99
IFileSystem * fs
The filing system owning this file.
Definition: Stat.h:52
Stat & operator=(const Stat &rhs)
assign content from another Stat structure
Definition: Stat.h:74
Definition: Access.h:34
TimeStamp mtime
File modification time.
Definition: Stat.h:56
bool isDir() const
Definition: Stat.h:87
defines a &#39;safe&#39; name buffer
Definition: NameBuffer.h:44
NameStat(const Stat &other)
Definition: Stat.h:103
NameBuffer name
Name of file.
Definition: Stat.h:53