diff --git a/src/xenia/kernel/xam/content_manager.cc b/src/xenia/kernel/xam/content_manager.cc index cdecaeddf..2b4056105 100644 --- a/src/xenia/kernel/xam/content_manager.cc +++ b/src/xenia/kernel/xam/content_manager.cc @@ -268,7 +268,17 @@ X_RESULT ContentManager::DeleteContent(const XCONTENT_DATA& data) { return X_ERROR_FILE_NOT_FOUND; } - return package->Delete(); + auto result = package->Delete(); + if (XSUCCEEDED(result)) { + auto it = std::find(open_packages_.begin(), open_packages_.end(), package); + if (it != open_packages_.end()) { + open_packages_.erase(it); + } + + delete package; + } + + return result; } std::wstring ContentManager::ResolveGameUserContentPath() { diff --git a/src/xenia/kernel/xam/content_package.cc b/src/xenia/kernel/xam/content_package.cc index 57b28cc3e..3fa04efd9 100644 --- a/src/xenia/kernel/xam/content_package.cc +++ b/src/xenia/kernel/xam/content_package.cc @@ -164,7 +164,7 @@ bool StfsContentPackage::Mount(std::string root_name) { return false; } - device_ = device.release(); + header_ = device->header(); device_inited_ = true; } @@ -172,12 +172,11 @@ bool StfsContentPackage::Mount(std::string root_name) { } X_RESULT StfsContentPackage::GetThumbnail(std::vector* buffer) { - if (!device_ || !device_inited_) { + if (!device_inited_) { return X_ERROR_DEVICE_NOT_CONNECTED; } - auto& header = device_->header(); - buffer->resize(header.thumbnail_image_size); - memcpy(buffer->data(), header.thumbnail_image, header.thumbnail_image_size); + buffer->resize(header_.thumbnail_image_size); + memcpy(buffer->data(), header_.thumbnail_image, header_.thumbnail_image_size); return X_ERROR_SUCCESS; } @@ -190,8 +189,8 @@ X_RESULT StfsContentPackage::Delete() { Unmount(); if (xe::filesystem::PathExists(package_path_)) { - xe::filesystem::DeleteFile(package_path_); - return X_ERROR_SUCCESS; + return xe::filesystem::DeleteFile(package_path_) ? X_ERROR_SUCCESS + : X_ERROR_FUNCTION_FAILED; } return X_ERROR_FILE_NOT_FOUND; } diff --git a/src/xenia/kernel/xam/content_package.h b/src/xenia/kernel/xam/content_package.h index c30862628..92fa10b4d 100644 --- a/src/xenia/kernel/xam/content_package.h +++ b/src/xenia/kernel/xam/content_package.h @@ -17,21 +17,9 @@ #include "xenia/base/memory.h" #include "xenia/base/mutex.h" +#include "xenia/vfs/devices/stfs_container_device.h" #include "xenia/xbox.h" -namespace xe { -namespace vfs { -class Device; -class StfsContainerDevice; -} // namespace vfs -} // namespace xe - -namespace xe { -namespace kernel { -class KernelState; -} // namespace kernel -} // namespace xe - namespace xe { namespace kernel { namespace xam { @@ -81,7 +69,7 @@ class StfsContentPackage : public ContentPackage { X_RESULT Delete(); private: - vfs::StfsContainerDevice* device_ = nullptr; + vfs::StfsHeader header_; }; class FolderContentPackage : public ContentPackage {