diff --git a/src/xenia/kernel/xobject.cc b/src/xenia/kernel/xobject.cc index 19434d97a..546d7a3a9 100644 --- a/src/xenia/kernel/xobject.cc +++ b/src/xenia/kernel/xobject.cc @@ -22,6 +22,7 @@ #include "xenia/kernel/xmutant.h" #include "xenia/kernel/xnotifylistener.h" #include "xenia/kernel/xsemaphore.h" +#include "xenia/kernel/xsymboliclink.h" #include "xenia/kernel/xthread.h" namespace xe { @@ -146,6 +147,8 @@ object_ref XObject::Restore(KernelState* kernel_state, Type type, break; case kTypeSocket: break; + case kTypeSymbolicLink: + return XSymbolicLink::Restore(kernel_state, stream); case kTypeThread: return XThread::Restore(kernel_state, stream); case kTypeTimer: diff --git a/src/xenia/kernel/xobject.h b/src/xenia/kernel/xobject.h index 3ecb908c8..280250ca5 100644 --- a/src/xenia/kernel/xobject.h +++ b/src/xenia/kernel/xobject.h @@ -121,6 +121,7 @@ class XObject { kTypeSemaphore, kTypeSession, kTypeSocket, + kTypeSymbolicLink, kTypeThread, kTypeTimer, }; diff --git a/src/xenia/kernel/xsymboliclink.cc b/src/xenia/kernel/xsymboliclink.cc new file mode 100644 index 000000000..0908375ca --- /dev/null +++ b/src/xenia/kernel/xsymboliclink.cc @@ -0,0 +1,58 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/kernel/xsymboliclink.h" + +#include "xenia/base/byte_stream.h" +#include "xenia/kernel/kernel_state.h" + +namespace xe { +namespace kernel { + +XSymbolicLink::XSymbolicLink(KernelState* kernel_state) + : XObject(kernel_state, kType), path_(), target_() {} + +XSymbolicLink::XSymbolicLink() : XObject(kType), path_(), target_() {} + +XSymbolicLink::~XSymbolicLink() {} + +void XSymbolicLink::Initialize(const std::string& path, + const std::string& target) { + path_ = path; + target_ = target; + // TODO(gibbed): kernel_state_->RegisterSymbolicLink(this); +} + +bool XSymbolicLink::Save(ByteStream* stream) { + if (!SaveObject(stream)) { + return false; + } + stream->Write(path_); + stream->Write(target_); + return true; +} + +object_ref XSymbolicLink::Restore(KernelState* kernel_state, + ByteStream* stream) { + auto symlink = new XSymbolicLink(); + symlink->kernel_state_ = kernel_state; + if (!symlink->RestoreObject(stream)) { + delete symlink; + return nullptr; + } + + auto path = stream->Read(); + auto target = stream->Read(); + symlink->Initialize(path, target); + + return object_ref(symlink); +} + +} // namespace kernel +} // namespace xe diff --git a/src/xenia/kernel/xsymboliclink.h b/src/xenia/kernel/xsymboliclink.h new file mode 100644 index 000000000..7ca5dc58e --- /dev/null +++ b/src/xenia/kernel/xsymboliclink.h @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_KERNEL_XSYMBOLICLINK_H_ +#define XENIA_KERNEL_XSYMBOLICLINK_H_ + +#include +#include + +#include "xenia/base/mutex.h" +#include "xenia/base/threading.h" +#include "xenia/kernel/xobject.h" +#include "xenia/xbox.h" + +namespace xe { +namespace kernel { + +class XSymbolicLink : public XObject { + public: + static const Type kType = kTypeSymbolicLink; + + explicit XSymbolicLink(KernelState* kernel_state); + ~XSymbolicLink() override; + + void Initialize(const std::string& path, const std::string& target); + + bool Save(ByteStream* stream) override; + static object_ref Restore(KernelState* kernel_state, + ByteStream* stream); + + const std ::string& path() const { return path_; } + const std ::string& target() const { return target_; } + + private: + XSymbolicLink(); + + std::string path_; + std::string target_; +}; + +} // namespace kernel +} // namespace xe + +#endif // XENIA_KERNEL_XSYMBOLICLINK_H_