-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.22-beta - iOS Path provider implementation
- Loading branch information
Showing
7 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
src/ReactorData.Maui/Platforms/Android/AndroidPathProvider.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Android.App; | ||
using System.IO; | ||
|
||
//NOTE: part of this code is freely taken from https://github.com/reactiveui/Akavache/blob/main/src/Akavache.Core/Platforms/android/AndroidFilesystemProvider.cs | ||
|
||
namespace ReactorData.Maui.Platforms.Android; | ||
|
||
|
||
/// <summary> | ||
/// The file system provider that understands the android. | ||
/// </summary> | ||
public class PathProvider : IPathProvider | ||
{ | ||
/// <inheritdoc /> | ||
public string? GetDefaultLocalMachineCacheDirectory() => Application.Context.CacheDir?.AbsolutePath; | ||
|
||
/// <inheritdoc /> | ||
public string? GetDefaultRoamingCacheDirectory() => Application.Context.FilesDir?.AbsolutePath; | ||
|
||
/// <inheritdoc /> | ||
public string? GetDefaultSecretCacheDirectory() | ||
{ | ||
var path = global::Android.App.Application.Context.FilesDir?.AbsolutePath; | ||
|
||
if (path is null) | ||
{ | ||
return null; | ||
} | ||
|
||
var di = new DirectoryInfo(Path.Combine(path, "Secret")); | ||
if (!di.Exists) | ||
{ | ||
di.CreateRecursive(); | ||
} | ||
|
||
return di.FullName; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Foundation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ReactorData.Maui.Platforms.iOS; | ||
|
||
internal class PathProvider : IPathProvider | ||
{ | ||
public string GetDefaultLocalMachineCacheDirectory() => CreateAppDirectory(NSSearchPathDirectory.CachesDirectory); | ||
|
||
/// <inheritdoc /> | ||
public string GetDefaultRoamingCacheDirectory() => CreateAppDirectory(NSSearchPathDirectory.ApplicationSupportDirectory); | ||
|
||
/// <inheritdoc /> | ||
public string GetDefaultSecretCacheDirectory() => CreateAppDirectory(NSSearchPathDirectory.ApplicationSupportDirectory, "SecretCache"); | ||
|
||
private string CreateAppDirectory(NSSearchPathDirectory targetDir, string subDir = "Cache") | ||
{ | ||
using var fm = new NSFileManager(); | ||
var url = fm.GetUrl(targetDir, NSSearchPathDomain.All, null, true, out _) ?? throw new DirectoryNotFoundException(); | ||
var rp = url.RelativePath ?? throw new DirectoryNotFoundException(); | ||
var ret = Path.Combine(rp, "ReactorData", subDir); | ||
if (!Directory.Exists(ret)) | ||
{ | ||
Directory.CreateDirectory(ret); | ||
} | ||
|
||
return ret; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters