diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 11:49:13 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:44:35 +0100 |
| commit | 5801be615a50bf465a9663b7f75cafbcf0870f5c (patch) | |
| tree | e3a6df2863ba9b6b24c76219bc685975be5e69d3 /kernel/filesystem/src/file_descriptor_table.cpp | |
| parent | 471888c64ed490b1f1dbaa2c2f67a1e8d315905a (diff) | |
| download | teachos-5801be615a50bf465a9663b7f75cafbcf0870f5c.tar.xz teachos-5801be615a50bf465a9663b7f75cafbcf0870f5c.zip | |
use kstd::vector instead of std::array and replace plain-pointers with kstd::shared_ptr
Diffstat (limited to 'kernel/filesystem/src/file_descriptor_table.cpp')
| -rw-r--r-- | kernel/filesystem/src/file_descriptor_table.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/filesystem/src/file_descriptor_table.cpp b/kernel/filesystem/src/file_descriptor_table.cpp index eb9a281..64fad0c 100644 --- a/kernel/filesystem/src/file_descriptor_table.cpp +++ b/kernel/filesystem/src/file_descriptor_table.cpp @@ -44,7 +44,8 @@ namespace filesystem return static_cast<int>(it - m_open_files.begin()); } - return -1; + m_open_files.push_back(file_description); + return static_cast<int>(m_open_files.size() - 1); } auto file_descriptor_table::get_file(int fd) const -> std::optional<open_file_description> @@ -55,12 +56,12 @@ namespace filesystem } auto const index = static_cast<size_t>(fd); - if (index >= m_open_files.size() || !m_open_files[index].has_value()) + if (index >= m_open_files.size() || !m_open_files.at(fd).has_value()) { return std::nullopt; } - return *m_open_files[index]; + return m_open_files.at(fd); } auto file_descriptor_table::remove_file(int fd) -> void @@ -76,6 +77,6 @@ namespace filesystem return; } - m_open_files[index].reset(); + m_open_files.at(fd).reset(); } } // namespace filesystem
\ No newline at end of file |
