[Kernel] Add XSymbolicLink.
This commit is contained in:
parent
e72cacc986
commit
54b0e2aff6
|
@ -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> 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:
|
||||
|
|
|
@ -121,6 +121,7 @@ class XObject {
|
|||
kTypeSemaphore,
|
||||
kTypeSession,
|
||||
kTypeSocket,
|
||||
kTypeSymbolicLink,
|
||||
kTypeThread,
|
||||
kTypeTimer,
|
||||
};
|
||||
|
|
|
@ -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> 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<std::string>();
|
||||
auto target = stream->Read<std::string>();
|
||||
symlink->Initialize(path, target);
|
||||
|
||||
return object_ref<XSymbolicLink>(symlink);
|
||||
}
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
|
@ -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 <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#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<XSymbolicLink> 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_
|
Loading…
Reference in New Issue