Merge remote-tracking branch 'origin/master' into d3d12
This commit is contained in:
commit
48b04d186b
|
@ -45,13 +45,11 @@ bool PathExists(const std::wstring& path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateFolder(const std::wstring& path) {
|
bool CreateFolder(const std::wstring& path) {
|
||||||
wchar_t folder[kMaxPath] = {0};
|
size_t pos = 0;
|
||||||
auto end = std::wcschr(path.c_str(), xe::kWPathSeparator);
|
do {
|
||||||
while (end) {
|
pos = path.find_first_of(xe::kWPathSeparator, pos + 1);
|
||||||
wcsncpy(folder, path.c_str(), end - path.c_str() + 1);
|
CreateDirectoryW(path.substr(0, pos).c_str(), nullptr);
|
||||||
CreateDirectory(folder, NULL);
|
} while (pos != std::string::npos);
|
||||||
end = wcschr(++end, xe::kWPathSeparator);
|
|
||||||
}
|
|
||||||
return PathExists(path);
|
return PathExists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,9 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
|
||||||
vfs::FileAction file_action;
|
vfs::FileAction file_action;
|
||||||
X_STATUS result = kernel_state()->file_system()->OpenFile(
|
X_STATUS result = kernel_state()->file_system()->OpenFile(
|
||||||
target_path, vfs::FileDisposition((uint32_t)creation_disposition),
|
target_path, vfs::FileDisposition((uint32_t)creation_disposition),
|
||||||
desired_access, &vfs_file, &file_action);
|
desired_access,
|
||||||
|
(create_options & CreateOptions::FILE_DIRECTORY_FILE) != 0, &vfs_file,
|
||||||
|
&file_action);
|
||||||
object_ref<XFile> file = nullptr;
|
object_ref<XFile> file = nullptr;
|
||||||
|
|
||||||
X_HANDLE handle = X_INVALID_HANDLE_VALUE;
|
X_HANDLE handle = X_INVALID_HANDLE_VALUE;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xenia/kernel/xfile.h"
|
#include "xenia/kernel/xfile.h"
|
||||||
|
#include "xenia/vfs/virtual_file_system.h"
|
||||||
|
|
||||||
#include "xenia/base/byte_stream.h"
|
#include "xenia/base/byte_stream.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
|
@ -178,6 +179,8 @@ bool XFile::Save(ByteStream* stream) {
|
||||||
stream->Write(file_->entry()->absolute_path());
|
stream->Write(file_->entry()->absolute_path());
|
||||||
stream->Write<uint64_t>(position_);
|
stream->Write<uint64_t>(position_);
|
||||||
stream->Write(file_access());
|
stream->Write(file_access());
|
||||||
|
stream->Write<bool>(
|
||||||
|
(file_->entry()->attributes() & vfs::kFileAttributeDirectory) != 0);
|
||||||
stream->Write<bool>(is_synchronous_);
|
stream->Write<bool>(is_synchronous_);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -195,6 +198,7 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
|
||||||
auto abs_path = stream->Read<std::string>();
|
auto abs_path = stream->Read<std::string>();
|
||||||
uint64_t position = stream->Read<uint64_t>();
|
uint64_t position = stream->Read<uint64_t>();
|
||||||
auto access = stream->Read<uint32_t>();
|
auto access = stream->Read<uint32_t>();
|
||||||
|
auto is_directory = stream->Read<bool>();
|
||||||
auto is_synchronous = stream->Read<bool>();
|
auto is_synchronous = stream->Read<bool>();
|
||||||
|
|
||||||
XELOGD("XFile %.8X (%s)", file->handle(), abs_path.c_str());
|
XELOGD("XFile %.8X (%s)", file->handle(), abs_path.c_str());
|
||||||
|
@ -202,7 +206,8 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
|
||||||
vfs::File* vfs_file = nullptr;
|
vfs::File* vfs_file = nullptr;
|
||||||
vfs::FileAction action;
|
vfs::FileAction action;
|
||||||
auto res = kernel_state->file_system()->OpenFile(
|
auto res = kernel_state->file_system()->OpenFile(
|
||||||
abs_path, vfs::FileDisposition::kOpen, access, &vfs_file, &action);
|
abs_path, vfs::FileDisposition::kOpen, access, is_directory, &vfs_file,
|
||||||
|
&action);
|
||||||
if (XFAILED(res)) {
|
if (XFAILED(res)) {
|
||||||
XELOGE("Failed to open XFile: error %.8X", res);
|
XELOGE("Failed to open XFile: error %.8X", res);
|
||||||
return object_ref<XFile>(file);
|
return object_ref<XFile>(file);
|
||||||
|
|
|
@ -181,8 +181,11 @@ bool VirtualFileSystem::DeletePath(const std::string& path) {
|
||||||
|
|
||||||
X_STATUS VirtualFileSystem::OpenFile(const std::string& path,
|
X_STATUS VirtualFileSystem::OpenFile(const std::string& path,
|
||||||
FileDisposition creation_disposition,
|
FileDisposition creation_disposition,
|
||||||
uint32_t desired_access, File** out_file,
|
uint32_t desired_access, bool is_directory,
|
||||||
FileAction* out_action) {
|
File** out_file, FileAction* out_action) {
|
||||||
|
// TODO(gibbed): should 'is_directory' remain as a bool or should it be
|
||||||
|
// flipped to a generic FileAttributeFlags?
|
||||||
|
|
||||||
// Cleanup access.
|
// Cleanup access.
|
||||||
if (desired_access & FileAccess::kGenericRead) {
|
if (desired_access & FileAccess::kGenericRead) {
|
||||||
desired_access |= FileAccess::kFileReadData;
|
desired_access |= FileAccess::kFileReadData;
|
||||||
|
@ -285,7 +288,8 @@ X_STATUS VirtualFileSystem::OpenFile(const std::string& path,
|
||||||
}
|
}
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
// Create if needed (either new or as a replacement).
|
// Create if needed (either new or as a replacement).
|
||||||
entry = CreatePath(path, kFileAttributeNormal);
|
entry = CreatePath(
|
||||||
|
path, !is_directory ? kFileAttributeNormal : kFileAttributeDirectory);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return X_STATUS_ACCESS_DENIED;
|
return X_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class VirtualFileSystem {
|
||||||
|
|
||||||
X_STATUS OpenFile(const std::string& path,
|
X_STATUS OpenFile(const std::string& path,
|
||||||
FileDisposition creation_disposition,
|
FileDisposition creation_disposition,
|
||||||
uint32_t desired_access, File** out_file,
|
uint32_t desired_access, bool is_directory, File** out_file,
|
||||||
FileAction* out_action);
|
FileAction* out_action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue