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) {
|
||||
wchar_t folder[kMaxPath] = {0};
|
||||
auto end = std::wcschr(path.c_str(), xe::kWPathSeparator);
|
||||
while (end) {
|
||||
wcsncpy(folder, path.c_str(), end - path.c_str() + 1);
|
||||
CreateDirectory(folder, NULL);
|
||||
end = wcschr(++end, xe::kWPathSeparator);
|
||||
}
|
||||
size_t pos = 0;
|
||||
do {
|
||||
pos = path.find_first_of(xe::kWPathSeparator, pos + 1);
|
||||
CreateDirectoryW(path.substr(0, pos).c_str(), nullptr);
|
||||
} while (pos != std::string::npos);
|
||||
return PathExists(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,9 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
|
|||
vfs::FileAction file_action;
|
||||
X_STATUS result = kernel_state()->file_system()->OpenFile(
|
||||
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;
|
||||
|
||||
X_HANDLE handle = X_INVALID_HANDLE_VALUE;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "xenia/kernel/xfile.h"
|
||||
#include "xenia/vfs/virtual_file_system.h"
|
||||
|
||||
#include "xenia/base/byte_stream.h"
|
||||
#include "xenia/base/logging.h"
|
||||
|
@ -178,6 +179,8 @@ bool XFile::Save(ByteStream* stream) {
|
|||
stream->Write(file_->entry()->absolute_path());
|
||||
stream->Write<uint64_t>(position_);
|
||||
stream->Write(file_access());
|
||||
stream->Write<bool>(
|
||||
(file_->entry()->attributes() & vfs::kFileAttributeDirectory) != 0);
|
||||
stream->Write<bool>(is_synchronous_);
|
||||
|
||||
return true;
|
||||
|
@ -195,6 +198,7 @@ object_ref<XFile> XFile::Restore(KernelState* kernel_state,
|
|||
auto abs_path = stream->Read<std::string>();
|
||||
uint64_t position = stream->Read<uint64_t>();
|
||||
auto access = stream->Read<uint32_t>();
|
||||
auto is_directory = stream->Read<bool>();
|
||||
auto is_synchronous = stream->Read<bool>();
|
||||
|
||||
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::FileAction action;
|
||||
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)) {
|
||||
XELOGE("Failed to open XFile: error %.8X", res);
|
||||
return object_ref<XFile>(file);
|
||||
|
|
|
@ -181,8 +181,11 @@ bool VirtualFileSystem::DeletePath(const std::string& path) {
|
|||
|
||||
X_STATUS VirtualFileSystem::OpenFile(const std::string& path,
|
||||
FileDisposition creation_disposition,
|
||||
uint32_t desired_access, File** out_file,
|
||||
FileAction* out_action) {
|
||||
uint32_t desired_access, bool is_directory,
|
||||
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.
|
||||
if (desired_access & FileAccess::kGenericRead) {
|
||||
desired_access |= FileAccess::kFileReadData;
|
||||
|
@ -285,7 +288,8 @@ X_STATUS VirtualFileSystem::OpenFile(const std::string& path,
|
|||
}
|
||||
if (!entry) {
|
||||
// Create if needed (either new or as a replacement).
|
||||
entry = CreatePath(path, kFileAttributeNormal);
|
||||
entry = CreatePath(
|
||||
path, !is_directory ? kFileAttributeNormal : kFileAttributeDirectory);
|
||||
if (!entry) {
|
||||
return X_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class VirtualFileSystem {
|
|||
|
||||
X_STATUS OpenFile(const std::string& path,
|
||||
FileDisposition creation_disposition,
|
||||
uint32_t desired_access, File** out_file,
|
||||
uint32_t desired_access, bool is_directory, File** out_file,
|
||||
FileAction* out_action);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue