PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.72k stars 1.62k forks source link

[Feature Request]: HostFS create folders #6964

Open weirdbeardgame opened 2 years ago

weirdbeardgame commented 2 years ago

Description

HostFS when a path contains multiple folders like data/scene cannot create folders and would look to the user to manually create the folder structure themselves.

Would be a nice convenience feature to have HostFS auto create the missing folder structure

Reason

Examples

Most programs like video games with a hard-coded path with an external data folder, IE. Skyrim,

stenzek commented 2 years ago

Why would you not just mkdir() on the PS2 side? Or does that not work?

weirdbeardgame commented 2 years ago

Homebrew you probably could? Though I've no clue if it'd work or not. I have a debug copy of a game I've been slowly helping with reverse engineering on. It has the ability to save files in its debug menu scene viewer. Seems, it doesn't have a mkdir call or if it does it didn't make it through pcsx2 HostFS layer at least

F0bes commented 2 years ago

I feel like a better solution would be to just log failed hostfs opens.

weirdbeardgame commented 2 years ago

And that's a fair option as well. I guess the crux of this request is to have more inbuilt feedback from HostFS. Auto folder creation would be more convenient but even just more messaging feedback would be a benifit

F0bes commented 2 years ago

I'm opposed to it because I feel like it's adding more complexity to something that should be a thin HLE wrapper. Currently, we don't know why the open fails, we just pass an error code back to the guest. So now you'd have to know why it failed, possibly iterate through the path and see if the directories exists and then if not, pass the path to create_directories(const std::filesystem::path&). Also, I don't believe the aforementioned function is currently implemented by whatever filesystem implementation we use now.

! I'm not opposed to more logging, if that wasn't clear.

stenzek commented 2 years ago

I did write a recursive directory creator. But I still don't think it's appropriate here - there's potential for a misbehaving elf to accidentally create a ton of subdirectories, plus the aforementioned complexity issue.

Logging failed host file opens would be trivial and fine.