mirror of
https://github.com/wiiu-env/homebrew_on_menu_plugin.git
synced 2024-11-22 02:29:15 +01:00
FileReaderWUHB: Fix unmounting when opening the file fails
This commit is contained in:
parent
11e89b04ce
commit
622dff63c6
@ -28,6 +28,9 @@ FileReaderWUHB::FileReaderWUHB(const std::shared_ptr<FileInfos> &info, const std
|
||||
WUHBUtilsStatus status;
|
||||
if ((status = WUHBUtils_FileOpen(filepath.c_str(), &this->fileHandle)) != WUHB_UTILS_RESULT_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE("Failed to open file in bundle: %s error: %d", filepath.c_str(), status);
|
||||
|
||||
UnmountBundle();
|
||||
|
||||
return;
|
||||
}
|
||||
this->info->fileCount++;
|
||||
@ -51,13 +54,7 @@ FileReaderWUHB::~FileReaderWUHB() {
|
||||
info->fileCount--;
|
||||
}
|
||||
|
||||
if (autoUnmount && info->fileCount <= 0) {
|
||||
if (!info->UnmountBundle()) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to unmount");
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Filecount is %d, we don't want to unmount yet", info->fileCount);
|
||||
}
|
||||
UnmountBundle();
|
||||
OSMemoryBarrier();
|
||||
}
|
||||
|
||||
@ -77,3 +74,12 @@ int64_t FileReaderWUHB::read(uint8_t *buffer, uint32_t size) {
|
||||
bool FileReaderWUHB::isReady() {
|
||||
return this->initDone;
|
||||
}
|
||||
void FileReaderWUHB::UnmountBundle() {
|
||||
if (autoUnmount && info->fileCount <= 0) {
|
||||
if (!info->UnmountBundle()) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to unmount");
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Filecount is %d, we don't want to unmount yet", info->fileCount);
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,5 @@ public:
|
||||
~FileReaderWUHB() override;
|
||||
int64_t read(uint8_t *buffer, uint32_t size) override;
|
||||
bool isReady() override;
|
||||
void UnmountBundle();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user