MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / SetupStandardFiles

Method SetupStandardFiles

src/filesystem/file_descriptor.cpp:159–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159auto FileDescriptorTable::SetupStandardFiles(vfs::File* stdin_file,
160 vfs::File* stdout_file,
161 vfs::File* stderr_file)
162 -> Expected<void> {
163 LockGuard guard(lock_);
164
165 // 仅对之前未占用的槽位增加计数
166 if (table_[kStdinFd] == nullptr && stdin_file != nullptr) {
167 ++open_count_;
168 }
169 if (table_[kStdoutFd] == nullptr && stdout_file != nullptr) {
170 ++open_count_;
171 }
172 if (table_[kStderrFd] == nullptr && stderr_file != nullptr) {
173 ++open_count_;
174 }
175
176 table_[kStdinFd] = stdin_file;
177 table_[kStdoutFd] = stdout_file;
178 table_[kStderrFd] = stderr_file;
179
180 return {};
181}
182
183auto FileDescriptorTable::GetOpenCount() const -> int { return open_count_; }
184

Callers 1

TEST_FFunction · 0.80

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.64