hollyhock
file.hpp
Go to the documentation of this file.
1 
59 #pragma once
60 #include <stdint.h>
61 
67 const int ENOMEM = -1;
68 const int EINVAL = -2;
69 const int EDEVFAIL = -3;
70 const int EMOUNTED = -4;
71 const int EACCES = -5;
72 const int EBADFSID = -6;
73 const int ENOVOLUME = -7;
74 const int ENOPATH = -8;
75 const int EEXIST = -9;
76 const int ENAMETOOLONG = -10;
77 const int EOUTOFBOUND = -11;
78 const int EUNFORMAT = -12;
79 const int ENOSPC = -13;
80 const int ENOENT = -14;
81 const int EISDIRECTORY = -15;
82 const int ESHARE = -16;
83 const int EMFILE = -17;
84 const int EBADF = -18;
85 const int EEOF = -19;
86 const int ENOTEMPTY = -20;
87 const int ECLUSTERSIZEMISMATCH = -40;
88 const int ESYSTEM = -99;
90 
97 const int SEEK_SET = 0;
99 const int SEEK_CUR = 1;
101 const int SEEK_END = 2;
103 
111 const int OPEN_READ = 1 << 0;
113 const int OPEN_WRITE = 1 << 1;
115 const int OPEN_CREATE = 1 << 2;
117 const int OPEN_APPEND = 1 << 4;
119 
126 uint16_t constexpr statDateYear(uint16_t date) {
127  return ((date >> 9) & 0b1111111) + 1980;
128 }
129 
136 uint16_t constexpr statDateMonth(uint16_t date) {
137  return (date >> 5) & 0b1111;
138 }
139 
146 uint16_t constexpr statDateDay(uint16_t date) {
147  return date & 0b11111;
148 }
149 
156 uint16_t constexpr statTimeHour(uint16_t time) {
157  return (time >> 11) & 0b11111;
158 }
159 
166 uint16_t constexpr statTimeMinute(uint16_t time) {
167  return (time >> 5) & 0b111111;
168 }
169 
178 uint16_t constexpr statTimeSecond(uint16_t time) {
179  return (time & 0b11111) * 2;
180 }
181 
248 struct stat {
249  uint32_t unknown1;
250 
254  uint32_t fileSize;
255 
260  uint16_t creationDate;
261 
266  uint16_t creationTime;
267 
273 
279 
280  uint16_t unknown2;
281 
287 };
288 
293 struct findInfo {
294  uint8_t unknown0[4];
295 
297  enum : uint16_t {
298  EntryTypeFile = 0x1,
299  EntryTypeDirectory = 0x5
300  } type;
301 
302  uint8_t unknown1[2];
303 
308  uint32_t size;
309 
310  uint8_t unknown2[8];
311 };
312 
319 extern "C"
320 int close(int fd);
321 
330 extern "C"
331 int findClose(int findHandle);
332 
352 extern "C"
353 int findFirst(const wchar_t *path, int *findHandle, wchar_t *name, struct findInfo *findInfoBuf);
354 
364 extern "C"
365 int findNext(int findHandle, wchar_t *name, struct findInfo *findInfoBuf);
366 
374 extern "C"
375 int fstat(int fd, struct stat *buf);
376 
388 extern "C"
389 int getAddr(int fd, int offset, const void **addr);
390 
400 extern "C"
401 int lseek(int fd, int offset, int whence);
402 
409 extern "C"
410 int mkdir(const char *path);
411 
422 extern "C"
423 int open(const char *path, int flags);
424 
437 extern "C"
438 int read(int fd, void *buf, int count);
439 
446 extern "C"
447 int remove(const char *path);
448 
456 extern "C"
457 int rename(const char *oldPath, const char *newPath);
458 
466 extern "C"
467 int stat(const char *path, struct stat *buf);
468 
478 extern "C"
479 int write(int fd, const void *buf, int count);
int getAddr(int fd, int offset, const void **addr)
int findFirst(const wchar_t *path, int *findHandle, wchar_t *name, struct findInfo *findInfoBuf)
constexpr uint16_t statTimeSecond(uint16_t time)
Definition: file.hpp:178
int fstat(int fd, struct stat *buf)
int findNext(int findHandle, wchar_t *name, struct findInfo *findInfoBuf)
int remove(const char *path)
int write(int fd, const void *buf, int count)
int stat(const char *path, struct stat *buf)
int rename(const char *oldPath, const char *newPath)
constexpr uint16_t statDateYear(uint16_t date)
Definition: file.hpp:126
int findClose(int findHandle)
int close(int fd)
int open(const char *path, int flags)
constexpr uint16_t statDateDay(uint16_t date)
Definition: file.hpp:146
constexpr uint16_t statDateMonth(uint16_t date)
Definition: file.hpp:136
constexpr uint16_t statTimeHour(uint16_t time)
Definition: file.hpp:156
constexpr uint16_t statTimeMinute(uint16_t time)
Definition: file.hpp:166
int read(int fd, void *buf, int count)
int lseek(int fd, int offset, int whence)
int mkdir(const char *path)
const int SEEK_END
Set the file offset to the end of the file, plus offset bytes.
Definition: file.hpp:101
const int SEEK_CUR
Set the file offset to the current position, plus offset bytes.
Definition: file.hpp:99
const int SEEK_SET
Set the file offset to offset.
Definition: file.hpp:97
const int OPEN_CREATE
Create the file, if it does not already exist.
Definition: file.hpp:115
const int OPEN_WRITE
Open the file as writable.
Definition: file.hpp:113
const int OPEN_READ
Open the file as readable.
Definition: file.hpp:111
const int OPEN_APPEND
Opens the file with the file offset set to the end of the file.
Definition: file.hpp:117
Definition: file.hpp:293
uint32_t size
Definition: file.hpp:308
enum findInfo::@0 type
The type of entry which was located.
Definition: file.hpp:248
uint32_t fileSize
Definition: file.hpp:254
uint16_t lastModifiedDate
Definition: file.hpp:272
uint16_t creationTime
Definition: file.hpp:266
uint16_t creationDate
Definition: file.hpp:260
uint16_t lastModifiedTime
Definition: file.hpp:278
uint16_t lastAccessedDate
Definition: file.hpp:286