Assign XModule path on load rather than in the constructor

This commit is contained in:
Dr. Chat
2015-12-28 13:25:04 -06:00
committed by Ben Vanik
parent c242a01043
commit 4e7dfa477b
6 changed files with 17 additions and 13 deletions

View File

@@ -23,8 +23,8 @@
namespace xe {
namespace kernel {
UserModule::UserModule(KernelState* kernel_state, const char* path)
: XModule(kernel_state, ModuleType::kUserModule, path) {}
UserModule::UserModule(KernelState* kernel_state)
: XModule(kernel_state, ModuleType::kUserModule) {}
UserModule::~UserModule() { Unload(); }
@@ -39,6 +39,9 @@ X_STATUS UserModule::LoadFromFile(std::string path) {
return X_STATUS_NO_SUCH_FILE;
}
path_ = fs_entry->absolute_path();
name_ = NameFromPath(path_);
// If the FS supports mapping, map the file in and load from that.
if (fs_entry->can_map()) {
// Map.
@@ -320,7 +323,7 @@ bool UserModule::Save(ByteStream* stream) {
object_ref<UserModule> UserModule::Restore(KernelState* kernel_state,
ByteStream* stream,
std::string path) {
auto module = new UserModule(kernel_state, path.c_str());
auto module = new UserModule(kernel_state);
// XModule::Save took care of this earlier...
// TODO: Find a nicer way to represent that here.