[UI] Redesigned "Install Content" window
- Added ID for each ImGui window - Added filesystem::CreateFolder function
This commit is contained in:
committed by
Radosław Gliński
parent
5d5eb03127
commit
56703e52e2
@@ -15,7 +15,8 @@
|
||||
namespace xe {
|
||||
namespace vfs {
|
||||
|
||||
std::unique_ptr<Device> XContentContainerDevice::CreateContentDevice(
|
||||
std::unique_ptr<XContentContainerDevice>
|
||||
XContentContainerDevice::CreateContentDevice(
|
||||
const std::string_view mount_path, const std::filesystem::path& host_path) {
|
||||
if (!std::filesystem::exists(host_path)) {
|
||||
XELOGE("Path to XContent container does not exist: {}", host_path);
|
||||
|
||||
@@ -31,7 +31,7 @@ class XContentContainerDevice : public Device {
|
||||
public:
|
||||
constexpr static uint32_t kBlockSize = 0x1000;
|
||||
|
||||
static std::unique_ptr<Device> CreateContentDevice(
|
||||
static std::unique_ptr<XContentContainerDevice> CreateContentDevice(
|
||||
const std::string_view mount_path,
|
||||
const std::filesystem::path& host_path);
|
||||
|
||||
@@ -74,6 +74,10 @@ class XContentContainerDevice : public Device {
|
||||
return final_license;
|
||||
}
|
||||
|
||||
const XContentContainerHeader* GetContainerHeader() const {
|
||||
return header_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
XContentContainerDevice(const std::string_view mount_path,
|
||||
const std::filesystem::path& host_path);
|
||||
@@ -106,10 +110,6 @@ class XContentContainerDevice : public Device {
|
||||
|
||||
const std::filesystem::path& GetHostPath() const { return host_path_; }
|
||||
|
||||
const XContentContainerHeader* GetContainerHeader() const {
|
||||
return header_.get();
|
||||
}
|
||||
|
||||
std::string name_;
|
||||
std::filesystem::path host_path_;
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ int vfs_dump_main(const std::vector<std::string>& args) {
|
||||
XELOGE("Failed to initialize device");
|
||||
return 1;
|
||||
}
|
||||
return VirtualFileSystem::ExtractContentFiles(device.get(), base_path);
|
||||
|
||||
uint64_t progress = 0;
|
||||
return VirtualFileSystem::ExtractContentFiles(device.get(), base_path,
|
||||
progress);
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
|
||||
@@ -335,6 +335,7 @@ X_STATUS VirtualFileSystem::OpenFile(Entry* root_entry,
|
||||
|
||||
X_STATUS VirtualFileSystem::ExtractContentFile(Entry* entry,
|
||||
std::filesystem::path base_path,
|
||||
uint64_t& progress,
|
||||
bool extract_to_root) {
|
||||
// Allocate a buffer when needed.
|
||||
size_t buffer_size = 0;
|
||||
@@ -369,27 +370,33 @@ X_STATUS VirtualFileSystem::ExtractContentFile(Entry* entry,
|
||||
in_file->Destroy();
|
||||
return 1;
|
||||
}
|
||||
constexpr size_t write_buffer_size = 4_MiB;
|
||||
|
||||
if (entry->can_map()) {
|
||||
auto map = entry->OpenMapped(xe::MappedMemory::Mode::kRead);
|
||||
fwrite(map->data(), map->size(), 1, file);
|
||||
|
||||
auto remaining_size = map->size();
|
||||
auto offset = 0;
|
||||
|
||||
while (remaining_size > 0) {
|
||||
fwrite(map->data() + offset, write_buffer_size, 1, file);
|
||||
offset += write_buffer_size;
|
||||
remaining_size -= write_buffer_size;
|
||||
}
|
||||
map->Close();
|
||||
} else {
|
||||
// Can't map the file into memory. Read it into a temporary buffer.
|
||||
if (!buffer || entry->size() > buffer_size) {
|
||||
// Resize the buffer.
|
||||
if (buffer) {
|
||||
delete[] buffer;
|
||||
}
|
||||
auto remaining_size = entry->size();
|
||||
size_t offset = 0;
|
||||
buffer = new uint8_t[write_buffer_size];
|
||||
|
||||
// Allocate a buffer rounded up to the nearest 512MB.
|
||||
buffer_size = xe::round_up(entry->size(), 512_MiB);
|
||||
buffer = new uint8_t[buffer_size];
|
||||
while (remaining_size > 0) {
|
||||
size_t bytes_read = 0;
|
||||
in_file->ReadSync(buffer, write_buffer_size, offset, &bytes_read);
|
||||
fwrite(buffer, bytes_read, 1, file);
|
||||
offset += bytes_read;
|
||||
remaining_size -= bytes_read;
|
||||
progress += bytes_read;
|
||||
}
|
||||
|
||||
size_t bytes_read = 0;
|
||||
in_file->ReadSync(buffer, entry->size(), 0, &bytes_read);
|
||||
fwrite(buffer, bytes_read, 1, file);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
@@ -401,8 +408,9 @@ X_STATUS VirtualFileSystem::ExtractContentFile(Entry* entry,
|
||||
return 0;
|
||||
}
|
||||
|
||||
X_STATUS VirtualFileSystem::ExtractContentFiles(
|
||||
Device* device, std::filesystem::path base_path) {
|
||||
X_STATUS VirtualFileSystem::ExtractContentFiles(Device* device,
|
||||
std::filesystem::path base_path,
|
||||
uint64_t& progress) {
|
||||
// Run through all the files, breadth-first style.
|
||||
std::queue<vfs::Entry*> queue;
|
||||
auto root = device->ResolvePath("/");
|
||||
@@ -415,7 +423,7 @@ X_STATUS VirtualFileSystem::ExtractContentFiles(
|
||||
queue.push(entry.get());
|
||||
}
|
||||
|
||||
ExtractContentFile(entry, base_path);
|
||||
ExtractContentFile(entry, base_path, progress);
|
||||
}
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,11 @@ class VirtualFileSystem {
|
||||
|
||||
static X_STATUS ExtractContentFile(Entry* entry,
|
||||
std::filesystem::path base_path,
|
||||
uint64_t& progress,
|
||||
bool extract_to_root = false);
|
||||
static X_STATUS ExtractContentFiles(Device* device,
|
||||
std::filesystem::path base_path);
|
||||
std::filesystem::path base_path,
|
||||
uint64_t& progress);
|
||||
static void ExtractContentHeader(Device* device,
|
||||
std::filesystem::path base_path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user