[Kernel] Fix bug with deleting StfsContentPackage & ensure instance gets
deleted
This commit is contained in:
parent
dcb45e800f
commit
7e2a163a51
|
@ -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() {
|
||||
|
|
|
@ -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<uint8_t>* 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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue