diff options
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 |
