diff options
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 10 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 39 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 13 |
4 files changed, 34 insertions, 30 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index ec528ef40..dffcdfbaf 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma optimize("", off) +#include <utility> #include "common/assert.h" #include "common/file_util.h" @@ -25,14 +25,14 @@ constexpr u64 EMULATED_SD_REPORTED_SIZE = 32000000000; static FileSys::VirtualDir GetDirectoryRelativeWrapped(FileSys::VirtualDir base, const std::string& dir_name) { - if (dir_name == "." || dir_name == "" || dir_name == "/" || dir_name == "\\") + if (dir_name.empty() || dir_name == "." || dir_name == "/" || dir_name == "\\") return base; return base->GetDirectoryRelative(dir_name); } VfsDirectoryServiceWrapper::VfsDirectoryServiceWrapper(FileSys::VirtualDir backing_) - : backing(backing_) {} + : backing(std::move(backing_)) {} std::string VfsDirectoryServiceWrapper::GetName() const { return backing->GetName(); @@ -193,6 +193,10 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType( if (dir == nullptr) return FileSys::ERROR_PATH_NOT_FOUND; auto filename = FileUtil::GetFilename(path); + // TODO(Subv): Some games use the '/' path, find out what this means. + if (filename.empty()) + return MakeResult(FileSys::EntryType::Directory); + if (dir->GetFile(filename) != nullptr) return MakeResult(FileSys::EntryType::File); if (dir->GetSubdirectory(filename) != nullptr) diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 1b003bd84..e7ffb6bd1 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -3,6 +3,14 @@ // Refer to the license.txt file included. #include <cinttypes> +#include <cstring> +#include <iterator> +#include <string> +#include <utility> +#include <vector> + +#include "common/assert.h" +#include "common/common_types.h" #include "common/logging/log.h" #include "common/string_util.h" #include "core/core.h" @@ -26,7 +34,7 @@ enum class StorageId : u8 { class IStorage final : public ServiceFramework<IStorage> { public: - IStorage(FileSys::VirtualFile backend_) + explicit IStorage(FileSys::VirtualFile backend_) : ServiceFramework("IStorage"), backend(std::move(backend_)) { static const FunctionInfo functions[] = { {0, &IStorage::Read, "Read"}, {1, nullptr, "Write"}, {2, nullptr, "Flush"}, @@ -133,19 +141,19 @@ private: return; } - std::vector<u8> data = ctx.ReadBuffer(); - std::vector<u8> actual_data(length); + const std::vector<u8> data = ctx.ReadBuffer(); ASSERT_MSG( - data.size() <= length, + static_cast<s64>(data.size()) <= length, "Attempting to write more data than requested (requested={:016X}, actual={:016X}).", length, data.size()); - std::copy(data.begin(), data.end(), actual_data.begin()); // Write the data to the Storage backend - auto written = backend->WriteBytes(data, offset); + const auto write_size = + static_cast<std::size_t>(std::distance(data.begin(), data.begin() + length)); + const std::size_t written = backend->Write(data.data(), write_size, offset); - ASSERT_MSG(written == length, + ASSERT_MSG(static_cast<s64>(written) == length, "Could not write all bytes to file (requested={:016X}, actual={:016X}).", length, written); @@ -223,23 +231,20 @@ private: LOG_DEBUG(Service_FS, "called, unk=0x{:X}", unk); // Calculate how many entries we can fit in the output buffer - u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry); + const u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry); // Cap at total number of entries. - u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index); + const u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index); - // Read the data from the Directory backend - std::vector<FileSys::Entry> entry_data(entries.begin() + next_entry_index, - entries.begin() + next_entry_index + actual_entries); + // Determine data start and end + const auto* begin = reinterpret_cast<u8*>(entries.data() + next_entry_index); + const auto* end = reinterpret_cast<u8*>(entries.data() + next_entry_index + actual_entries); + const auto range_size = static_cast<std::size_t>(std::distance(begin, end)); next_entry_index += actual_entries; - // Convert the data into a byte array - std::vector<u8> output(entry_data.size() * sizeof(FileSys::Entry)); - std::memcpy(output.data(), entry_data.data(), output.size()); - // Write the data to memory - ctx.WriteBuffer(output); + ctx.WriteBuffer(begin, range_size); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 579940817..35b2c65fc 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -30,7 +30,7 @@ public: /// Returns a pointer to one of the available devices, identified by its name. template <typename T> - std::shared_ptr<T> GetDevice(std::string name) { + std::shared_ptr<T> GetDevice(const std::string& name) { auto itr = devices.find(name); if (itr == devices.end()) return nullptr; diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index d580f779e..1fca1743d 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -23,15 +23,10 @@ constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREE NVFlinger::NVFlinger() { // Add the different displays to the list of displays. - Display default_{0, "Default"}; - Display external{1, "External"}; - Display edid{2, "Edid"}; - Display internal{3, "Internal"}; - - displays.emplace_back(default_); - displays.emplace_back(external); - displays.emplace_back(edid); - displays.emplace_back(internal); + displays.emplace_back(0, "Default"); + displays.emplace_back(1, "External"); + displays.emplace_back(2, "Edid"); + displays.emplace_back(3, "Internal"); // Schedule the screen composition events composition_event = |