XFile: Track asynchronous/synchronous flag (and return appropriately in nt Read/Write file)

This commit is contained in:
Dr. Chat
2015-12-30 17:34:26 -06:00
parent cbc74c92f4
commit 2a590f31fe
3 changed files with 57 additions and 11 deletions

View File

@@ -18,8 +18,10 @@
namespace xe {
namespace kernel {
XFile::XFile(KernelState* kernel_state, vfs::File* file)
: XObject(kernel_state, kTypeFile), file_(file) {
XFile::XFile(KernelState* kernel_state, vfs::File* file, bool synchronous)
: XObject(kernel_state, kTypeFile),
file_(file),
is_synchronous_(synchronous) {
async_event_ = threading::Event::CreateAutoResetEvent(false);
}
@@ -174,6 +176,7 @@ bool XFile::Save(ByteStream* stream) {
stream->Write(file_->entry()->absolute_path());
stream->Write<uint64_t>(position_);
stream->Write(file_access());
stream->Write<bool>(is_synchronous_);
return true;
}
@@ -190,6 +193,7 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
auto abs_path = stream->Read<std::string>();
uint64_t position = stream->Read<uint64_t>();
auto access = stream->Read<uint32_t>();
auto is_synchronous = stream->Read<bool>();
XELOGD("XFile %.8X (%s)", file->handle(), abs_path.c_str());
@@ -204,6 +208,7 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
file->file_ = vfs_file;
file->position_ = position;
file->is_synchronous_ = is_synchronous;
return object_ref<XFile>(file);
}