Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions runtime-light/k2-platform/k2-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ inline auto canonicalize(std::string_view path) noexcept {
return return_type{{unique_ptr_type{resolved_path, std::invoke(deleter_creator, resolved_path_len, resolved_path_align)}, resolved_path_len}};
}

inline std::expected<void, int32_t> fstat(uint64_t fd, struct stat* stat) noexcept {
if (auto error_code{k2_fstat(fd, stat)}; error_code != k2::errno_ok) [[unlikely]] {
return std::unexpected{error_code};
}
return {};
}

inline std::expected<void, int32_t> stat(std::string_view path, struct stat* stat) noexcept {
if (auto error_code{k2_stat(path.data(), path.size(), stat)}; error_code != k2::errno_ok) [[unlikely]] {
return std::unexpected{error_code};
Expand Down
5 changes: 5 additions & 0 deletions runtime-light/k2-platform/k2-header.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ size_t k2_backtrace(void** buffer, size_t size);
*/
int32_t k2_canonicalize(const char* path, size_t pathlen, char* const* resolved_path, size_t* resolved_pathlen, size_t* resolved_path_align);

/**
* Semantically equivalent to libc's `fstat`.
*/
int32_t k2_fstat(uint64_t fd, struct stat* statbuf);

/**
* Semantically equivalent to libc's `stat`.
*
Expand Down
Loading