Closed delynith closed 7 months ago
Thank you for pull request! The implementation looks interesting, I didn't know that Mac fully encrypts the file, unlike Windows and Android :)
But now I don't have Mac OS on device or virtual machine, that's why I can't check it now.
Can you make a small .dat up to 4 KB from mac and add this file to the data folder for tests?
Here: https://github.com/Folleach/GeometryDashAPI/tree/master/GeometryDashAPI.Tests/data/saves
It would be good if there were several tests:
Tests can be added here: https://github.com/Folleach/GeometryDashAPI/blob/master/GeometryDashAPI.Tests/GameDataTests.cs
If you can't do it, I can check it myself and write tests a little later, I think in the next week
The library also implies execution on any operating system with any types of files.
So, for example, someone can write an application for Linux on which they would like to process files for Mac OS
In this regard, the code
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
...
in methods GetFileContent
and LoadAsync
is looks suspicious.
Because applications on Mac will not be able to unpack .dat files for windows and vice versa.
But this code is okay for ResolveFileName
method.
I would recommend choosing the type of file reading/saving depending on its content.
Often there are headers and magic bytes at the beginning of files for this purpose
But we probably won't be able to find any magic bytes in the encrypted file, because it's just a mountain of random bytes.
So, I think we can rely on the knowledge of magic bytes for gzip. If there are any, perform reading using XOR, if not, using AES.
To save, we can make an enum, which will allow the library user to choose which option he wants to write the file.
Was bored last night and tried to make this API work with MacOS devices too.
With this change, the API will now also be able to decrypt MacOS GD save files