mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	file_sys: Add support for the BOSS ext save data archive. (#7231)
This commit is contained in:
		
							parent
							
								
									ea9f522c0c
								
							
						
					
					
						commit
						875f5eaad5
					
				
					 7 changed files with 36 additions and 17 deletions
				
			
		|  | @ -41,6 +41,7 @@ class Path { | |||
| public: | ||||
|     Path() : type(LowPathType::Invalid) {} | ||||
|     Path(const char* path) : type(LowPathType::Char), string(path) {} | ||||
|     Path(std::string path) : type(LowPathType::Char), string(std::move(path)) {} | ||||
|     Path(std::vector<u8> binary_data) : type(LowPathType::Binary), binary(std::move(binary_data)) {} | ||||
|     template <std::size_t size> | ||||
|     Path(const std::array<u8, size>& binary_data) | ||||
|  |  | |||
|  | @ -216,14 +216,16 @@ Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low) { | |||
| } | ||||
| 
 | ||||
| ArchiveFactory_ExtSaveData::ArchiveFactory_ExtSaveData(const std::string& mount_location, | ||||
|                                                        bool shared) | ||||
|     : shared(shared), mount_point(GetExtDataContainerPath(mount_location, shared)) { | ||||
|                                                        ExtSaveDataType type_) | ||||
|     : type(type_), | ||||
|       mount_point(GetExtDataContainerPath(mount_location, type_ == ExtSaveDataType::Shared)) { | ||||
|     LOG_DEBUG(Service_FS, "Directory {} set as base for ExtSaveData.", mount_point); | ||||
| } | ||||
| 
 | ||||
| Path ArchiveFactory_ExtSaveData::GetCorrectedPath(const Path& path) { | ||||
|     if (!shared) | ||||
|     if (type != ExtSaveDataType::Shared) { | ||||
|         return path; | ||||
|     } | ||||
| 
 | ||||
|     static constexpr u32 SharedExtDataHigh = 0x48000; | ||||
| 
 | ||||
|  | @ -242,11 +244,12 @@ Path ArchiveFactory_ExtSaveData::GetCorrectedPath(const Path& path) { | |||
| 
 | ||||
| ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(const Path& path, | ||||
|                                                                             u64 program_id) { | ||||
|     std::string fullpath = GetExtSaveDataPath(mount_point, GetCorrectedPath(path)) + "user/"; | ||||
|     const auto directory = type == ExtSaveDataType::Boss ? "boss/" : "user/"; | ||||
|     const auto fullpath = GetExtSaveDataPath(mount_point, GetCorrectedPath(path)) + directory; | ||||
|     if (!FileUtil::Exists(fullpath)) { | ||||
|         // TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData.
 | ||||
|         // ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist.
 | ||||
|         if (!shared) { | ||||
|         if (type != ExtSaveDataType::Shared) { | ||||
|             return ERR_NOT_FOUND_INVALID_STATE; | ||||
|         } else { | ||||
|             return ERR_NOT_FORMATTED; | ||||
|  |  | |||
|  | @ -15,10 +15,16 @@ | |||
| 
 | ||||
| namespace FileSys { | ||||
| 
 | ||||
| enum class ExtSaveDataType { | ||||
|     Normal, ///< Regular non-shared ext save data
 | ||||
|     Shared, ///< Shared ext save data
 | ||||
|     Boss,   ///< SpotPass ext save data
 | ||||
| }; | ||||
| 
 | ||||
| /// File system interface to the ExtSaveData archive
 | ||||
| class ArchiveFactory_ExtSaveData final : public ArchiveFactory { | ||||
| public: | ||||
|     ArchiveFactory_ExtSaveData(const std::string& mount_point, bool shared); | ||||
|     ArchiveFactory_ExtSaveData(const std::string& mount_point, ExtSaveDataType type_); | ||||
| 
 | ||||
|     std::string GetName() const override { | ||||
|         return "ExtSaveData"; | ||||
|  | @ -42,8 +48,8 @@ public: | |||
|     void WriteIcon(const Path& path, std::span<const u8> icon); | ||||
| 
 | ||||
| private: | ||||
|     bool shared; ///< Whether this archive represents an ExtSaveData archive or a SharedExtSaveData
 | ||||
|                  /// archive
 | ||||
|     /// Type of ext save data archive being accessed.
 | ||||
|     ExtSaveDataType type; | ||||
| 
 | ||||
|     /**
 | ||||
|      * This holds the full directory path for this archive, it is only set after a successful call | ||||
|  | @ -59,7 +65,7 @@ private: | |||
|     template <class Archive> | ||||
|     void serialize(Archive& ar, const unsigned int) { | ||||
|         ar& boost::serialization::base_object<ArchiveFactory>(*this); | ||||
|         ar& shared; | ||||
|         ar& type; | ||||
|         ar& mount_point; | ||||
|     } | ||||
|     friend class boost::serialization::access; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue