[Yellowstone] Use the file api to load the init file.
This commit is contained in:
parent
86ce0a68a3
commit
8ceab2ad23
6 changed files with 23 additions and 27 deletions
|
|
@ -13,6 +13,8 @@ VFSClient* gVfsClient = nullptr;
|
|||
|
||||
} // namespace
|
||||
|
||||
void SetVfsCap(z_cap_t vfs_cap) { gVfsClient = new VFSClient(vfs_cap); }
|
||||
|
||||
File File::Open(glcr::StringView path) {
|
||||
if (gVfsClient == 0) {
|
||||
YellowstoneClient client(gInitEndpointCap);
|
||||
|
|
@ -30,11 +32,11 @@ File File::Open(glcr::StringView path) {
|
|||
OpenFileResponse resp;
|
||||
check(gVfsClient->OpenFile(req, resp));
|
||||
|
||||
return File(OwnedMemoryRegion::FromCapability(resp.memory()));
|
||||
return File(OwnedMemoryRegion::FromCapability(resp.memory()), resp.size());
|
||||
}
|
||||
|
||||
glcr::StringView File::as_str() {
|
||||
return glcr::StringView((char*)raw_ptr(), file_data_.size());
|
||||
return glcr::StringView((char*)raw_ptr(), size_);
|
||||
}
|
||||
|
||||
void* File::raw_ptr() { return reinterpret_cast<void*>(file_data_.vaddr()); }
|
||||
|
|
|
|||
|
|
@ -7,10 +7,15 @@
|
|||
|
||||
namespace mmth {
|
||||
|
||||
// Intended for use in yellowstone since it already has the VFS cap.
|
||||
void SetVfsCap(z_cap_t vfs_cap);
|
||||
|
||||
class File {
|
||||
public:
|
||||
static File Open(glcr::StringView path);
|
||||
|
||||
uint64_t size() { return size_; }
|
||||
|
||||
glcr::StringView as_str();
|
||||
|
||||
void* raw_ptr();
|
||||
|
|
@ -18,8 +23,10 @@ class File {
|
|||
|
||||
private:
|
||||
OwnedMemoryRegion file_data_;
|
||||
uint64_t size_;
|
||||
|
||||
File(OwnedMemoryRegion&& file) : file_data_(glcr::Move(file)) {}
|
||||
File(OwnedMemoryRegion&& file, uint64_t size)
|
||||
: file_data_(glcr::Move(file)), size_(size) {}
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue