Sam
01/30/2023, 1:14 PMAndrei Salavei
01/30/2023, 1:15 PMSam
01/30/2023, 1:16 PMexpect/actual implementations easily enough, it's getting hold of the directory path to write to that I'm struggling withAndrei Salavei
01/30/2023, 1:19 PMexpect/actual method that returns cache directory path for each platform. Do you?Sam
01/30/2023, 1:20 PMandroidMain & iOSMain source sets?Sam
01/30/2023, 1:33 PMval paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, true);
val cacheDirectory = paths.first()Vidmantas Kerbelis
01/30/2023, 1:38 PMexpect/actual is your friend here.
If you want to get a File and do something with it in common code. So CRUD operations, or w/e.. Then you probably need something like Okio and use FileSystem to open the appropriate files from the cache.Sam
01/30/2023, 1:47 PMVidmantas Kerbelis
01/30/2023, 1:54 PMcontext.cacheDir (File), so for the path, it would be cacheDir.absolutePath (or relativePath)Sam
01/30/2023, 1:55 PMVidmantas Kerbelis
01/30/2023, 1:56 PMContext, so you must do it on the Android platform’s side sadlySam
01/30/2023, 1:58 PMJeff Lockhart
01/30/2023, 11:49 PMContext in common code. It embeds the Android Context within the coroutine context, which then can be used by Android actual suspend functions on file systems objects like cacheVfs. You just need to call withAndroidContext(context) from the Android code the calls the common code (example).