// This source code is released into the public domain. module; // Basic wrappers around stat() and fstat(). #include export module nihil.posix:stat; import nihil.std; import nihil.util; import :fd; namespace nihil { export [[nodiscard]] auto stat(std::filesystem::path const &path) -> std::expected { auto guard = save_errno(); struct ::stat sb{}; auto ret = ::stat(path.string().c_str(), &sb); if (ret == -1) return std::unexpected(error(sys_error())); return sb; } export [[nodiscard]] auto stat(fd const &fd) -> std::expected { auto guard = save_errno(); struct ::stat sb{}; auto ret = ::fstat(fd.get(), &sb); if (ret == -1) return std::unexpected(error(sys_error())); return sb; } } // namespace nihil