More string conversion.

This commit is contained in:
Ben Vanik
2014-08-16 02:50:08 -07:00
parent a4dfc23abc
commit 66d2336e38
11 changed files with 94 additions and 121 deletions

View File

@@ -36,19 +36,16 @@ private:
}
HostPathEntry::HostPathEntry(Type type, Device* device, const char* path,
const xechar_t* local_path) :
Entry(type, device, path),
find_file_(INVALID_HANDLE_VALUE) {
local_path_ = xestrdup(local_path);
}
const std::wstring& local_path)
: Entry(type, device, path),
local_path_(local_path),
find_file_(INVALID_HANDLE_VALUE) {}
HostPathEntry::~HostPathEntry() {
if (find_file_ != INVALID_HANDLE_VALUE) {
FindClose(find_file_);
}
xe_free(local_path_);
}
#define COMBINE_TIME(t) (((uint64_t)t.dwHighDateTime << 32) | t.dwLowDateTime)
@@ -58,7 +55,7 @@ X_STATUS HostPathEntry::QueryInfo(XFileInfo* out_info) {
WIN32_FILE_ATTRIBUTE_DATA data;
if (!GetFileAttributesEx(
local_path_, GetFileExInfoStandard, &data)) {
local_path_.c_str(), GetFileExInfoStandard, &data)) {
return X_STATUS_ACCESS_DENIED;
}
@@ -87,16 +84,13 @@ X_STATUS HostPathEntry::QueryDirectory(
}
if (handle == INVALID_HANDLE_VALUE) {
xechar_t target_path[poly::max_path];
xestrcpy(target_path, poly::max_path, local_path_);
if (file_name == NULL) {
xestrcat(target_path, poly::max_path, L"*");
std::wstring target_path = local_path_;
if (!file_name) {
target_path += L"*";
} else {
target_path += poly::to_wstring(file_name);
}
else {
auto target_length = xestrlen(local_path_);
xestrwiden(target_path + target_length, XECOUNT(target_path) - target_length, file_name);
}
handle = find_file_ = FindFirstFile(target_path, &ffd);
handle = find_file_ = FindFirstFile(target_path.c_str(), &ffd);
if (handle == INVALID_HANDLE_VALUE) {
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
return X_STATUS_NO_MORE_FILES;
@@ -140,9 +134,11 @@ X_STATUS HostPathEntry::QueryDirectory(
return X_STATUS_SUCCESS;
}
MemoryMapping* HostPathEntry::CreateMemoryMapping(
xe_file_mode file_mode, const size_t offset, const size_t length) {
xe_mmap_ref mmap = xe_mmap_open(file_mode, local_path_, offset, length);
MemoryMapping* HostPathEntry::CreateMemoryMapping(xe_file_mode file_mode,
const size_t offset,
const size_t length) {
xe_mmap_ref mmap =
xe_mmap_open(file_mode, local_path_.c_str(), offset, length);
if (!mmap) {
return NULL;
}
@@ -163,7 +159,7 @@ X_STATUS HostPathEntry::Open(
DWORD creation_disposition = OPEN_EXISTING;
DWORD flags_and_attributes = async ? FILE_FLAG_OVERLAPPED : 0;
HANDLE file = CreateFile(
local_path_,
local_path_.c_str(),
desired_access,
share_mode,
NULL,

View File

@@ -15,42 +15,37 @@
#include <xenia/kernel/fs/entry.h>
namespace xe {
namespace kernel {
namespace fs {
class HostPathEntry : public Entry {
public:
public:
HostPathEntry(Type type, Device* device, const char* path,
const xechar_t* local_path);
const std::wstring& local_path);
virtual ~HostPathEntry();
const xechar_t* local_path() { return local_path_; }
const std::wstring& local_path() { return local_path_; }
virtual X_STATUS QueryInfo(XFileInfo* out_info);
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info,
size_t length, const char* file_name, bool restart);
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length,
const char* file_name, bool restart);
virtual bool can_map() { return true; }
virtual MemoryMapping* CreateMemoryMapping(
xe_file_mode file_mode, const size_t offset, const size_t length);
virtual MemoryMapping* CreateMemoryMapping(xe_file_mode file_mode,
const size_t offset,
const size_t length);
virtual X_STATUS Open(
KernelState* kernel_state,
uint32_t desired_access, bool async,
XFile** out_file);
virtual X_STATUS Open(KernelState* kernel_state, uint32_t desired_access,
bool async, XFile** out_file);
private:
xechar_t* local_path_;
HANDLE find_file_;
private:
std::wstring local_path_;
HANDLE find_file_;
};
} // namespace fs
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_FS_DEVICES_HOST_PATH_ENTRY_H_

View File

@@ -72,9 +72,8 @@ SHIM_CALL NtCreateFile_shim(
assert_true(root_file->type() == XObject::Type::kTypeFile);
auto root_path = root_file->absolute_path();
auto target_path = xestrdupa((std::string(root_path) + std::string(object_name)).c_str());
auto target_path = root_path + object_name;
entry = fs->ResolvePath(target_path);
xe_free(target_path);
}
else {
// Resolve the file using the virtual file system.