The Pedigree Project 0.1
FileHandle.h
1/* Copyright (c) 2026, Pedigree Developers. */
2#ifndef PEDIGREE_VFS_FILEHANDLE_H
3#define PEDIGREE_VFS_FILEHANDLE_H
4
5#include "pedigree/kernel/compiler.h"
6#include "pedigree/kernel/process/TerminationDeferral.h"
7#include "pedigree/kernel/processor/types.h"
8
9class File;
10
11struct FileHandle {
12 uint32_t length = 0;
13 int32_t type = 0;
14 uint8_t bytes[128] = {};
15};
16
18 uint32_t words[2] = {};
19};
20
21enum class FileHandleStatus { Success, Unsupported, Stale, Invalid, NoMemory, IoError };
22
24class EXPORTED_PUBLIC RetainedFile {
25 public:
27 RetainedFile(RetainedFile&& other) noexcept;
29 RetainedFile& operator=(RetainedFile&& other) noexcept;
30 File* get() const {
31 return m_File;
32 }
33 explicit operator bool() const {
34 return m_File != nullptr;
35 }
36 void adopt(File* file);
37 void reset();
38
39 private:
40 RetainedFile(const RetainedFile&) = delete;
41 RetainedFile& operator=(const RetainedFile&) = delete;
42 TerminationDeferral m_Lifetime;
43 File* m_File = nullptr;
44};
45
46#endif
Definition File.h:74