More string swapping and cleaning up main().

This commit is contained in:
Ben Vanik
2014-08-16 16:34:04 -07:00
parent 18ee972b47
commit 7c5fa88661
41 changed files with 326 additions and 413 deletions

View File

@@ -17,19 +17,20 @@ using namespace xe::cpu;
using namespace xe::kernel;
XModule::XModule(KernelState* kernel_state, const char* path) :
XObject(kernel_state, kTypeModule) {
XEIGNORE(xestrcpya(path_, XECOUNT(path_), path));
const char* slash = xestrrchra(path, '/');
if (!slash) {
slash = xestrrchra(path, '\\');
XModule::XModule(KernelState* kernel_state, const std::string& path) :
XObject(kernel_state, kTypeModule), path_(path) {
auto last_slash = path.find_last_of('/');
if (last_slash == path.npos) {
last_slash = path.find_last_of('\\');
}
if (slash) {
XEIGNORE(xestrcpya(name_, XECOUNT(name_), slash + 1));
if (last_slash == path.npos) {
name_ = path_;
} else {
name_ = path_.substr(last_slash + 1);
}
char* dot = xestrrchra(name_, '.');
if (dot) {
*dot = 0;
auto dot = name_.find_last_of('.');
if (dot != name_.npos) {
name_ = name_.substr(0, dot);
}
}

View File

@@ -10,6 +10,8 @@
#ifndef XENIA_KERNEL_XBOXKRNL_XMODULE_H_
#define XENIA_KERNEL_XBOXKRNL_XMODULE_H_
#include <string>
#include <xenia/kernel/xobject.h>
#include <xenia/xbox.h>
@@ -21,11 +23,11 @@ namespace kernel {
class XModule : public XObject {
public:
XModule(KernelState* kernel_state, const char* path);
XModule(KernelState* kernel_state, const std::string& path);
virtual ~XModule();
const char* path() const { return path_; }
const char* name() const { return name_; }
const std::string& path() const { return path_; }
const std::string& name() const { return name_; }
virtual void* GetProcAddressByOrdinal(uint16_t ordinal) = 0;
virtual X_STATUS GetSection(
@@ -35,8 +37,8 @@ public:
protected:
void OnLoad();
char name_[256];
char path_[poly::max_path];
std::string name_;
std::string path_;
};