Skip to content

Commit

Permalink
USB: Store unique disk images for MSD and PictureParadise
Browse files Browse the repository at this point in the history
  • Loading branch information
Florin9doi authored and lightningterror committed Aug 18, 2024
1 parent 5217ec3 commit 4f405ad
Showing 1 changed file with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions pcsx2/USB/usb-msd/usb-msd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,27 +1108,14 @@ namespace usb_msd
{
MSDState* s = new MSDState();

std::string path(USB::GetConfigString(si, port, TypeName(), "ImagePath"));
if (path.empty() || !(s->file = FileSystem::OpenCFile(path.c_str(), "r+b")))
{
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("USB", "usb-msd: Could not open image file '{}'"), path),
Host::OSD_ERROR_DURATION);
goto fail;
}

FILESYSTEM_STAT_DATA sd;
if (!FileSystem::StatFile(s->file, &sd))
goto fail;

s->file_size = sd.Size;
s->f.mtime = sd.ModificationTime;
s->f.last_cmd = -1;
std::string path;
s->dev.speed = USB_SPEED_FULL;
s->desc.full = &s->desc_dev;

switch (type)
{
case IOMEGA_ZIP_100:
path = USB::GetConfigString(si, port, TypeName(), "ImagePathMsd");
s->desc.str = zip100_desc_strings;
if (usb_desc_parse_dev(zip100_dev_descriptor, sizeof(zip100_dev_descriptor), s->desc, s->desc_dev) < 0)
goto fail;
Expand All @@ -1138,6 +1125,7 @@ namespace usb_msd
s->dev.klass.handle_data = usb_msd_handle_data;
break;
case SONY_MSAC_US1:
path = USB::GetConfigString(si, port, TypeName(), "ImagePathMsac");
s->desc.str = sony_msac_desc_strings;
if (usb_desc_parse_dev(sony_msac_dev_descriptor, sizeof(sony_msac_dev_descriptor), s->desc, s->desc_dev) < 0)
goto fail;
Expand All @@ -1151,6 +1139,21 @@ namespace usb_msd
break;
}

if (path.empty() || !(s->file = FileSystem::OpenCFile(path.c_str(), "r+b")))
{
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("USB", "usb-msd: Could not open image file '{}'"), path),
Host::OSD_ERROR_DURATION);
goto fail;
}

FILESYSTEM_STAT_DATA sd;
if (!FileSystem::StatFile(s->file, &sd))
goto fail;

s->file_size = sd.Size;
s->f.mtime = sd.ModificationTime;
s->f.last_cmd = -1;

s->dev.klass.cancel_packet = usb_msd_cancel_io;
s->dev.klass.handle_attach = usb_desc_attach;
s->dev.klass.handle_reset = usb_msd_handle_reset;
Expand Down Expand Up @@ -1221,10 +1224,26 @@ namespace usb_msd

std::span<const SettingInfo> MsdDevice::Settings(u32 subtype) const
{
static constexpr const SettingInfo settings[] = {
{SettingInfo::Type::Path, "ImagePath", TRANSLATE_NOOP("USB", "Image Path"),
TRANSLATE_NOOP("USB", "Sets the path to image which will back the virtual mass storage device.")},
};
return settings;
switch (subtype)
{
case IOMEGA_ZIP_100:
{
static constexpr const SettingInfo settings[] = {
{SettingInfo::Type::Path, "ImagePathMsd", TRANSLATE_NOOP("USB", "Image Path"),
TRANSLATE_NOOP("USB", "Sets the path to image which will back the virtual mass storage device.")},
};
return settings;
}
case SONY_MSAC_US1:
{
static constexpr const SettingInfo settings[] = {
{SettingInfo::Type::Path, "ImagePathMsac", TRANSLATE_NOOP("USB", "Image Path"),
TRANSLATE_NOOP("USB", "Sets the path to image which will back the virtual mass storage device.")},
};
return settings;
}
default:
return {};
}
}
} // namespace usb_msd

0 comments on commit 4f405ad

Please sign in to comment.