100 lines
3.0 KiB
Markdown
100 lines
3.0 KiB
Markdown
|
# Tesses.VirtualFilesystem.Saf
|
||
|
|
||
|
A library to use Tesses.VirtualFilesystem with Storage Access Framework (Android)
|
||
|
|
||
|
# Nuget
|
||
|
|
||
|
# License
|
||
|
|
||
|
![GPL3-only](https://www.gnu.org/graphics/gplv3-with-text-136x68.png)
|
||
|
Licensed under [GPL3](https://www.gnu.org/licenses/)
|
||
|
|
||
|
# How to use (not presistant)
|
||
|
```csharp
|
||
|
...
|
||
|
using Tesses.VirtualFilesystem;
|
||
|
using Tesses.VirtualFilesystem.Filesystems;
|
||
|
using Android.Content;
|
||
|
using AndroidX.DocumentFile.Provider;
|
||
|
using Tesses.VirtualFilesystem.Extensions;
|
||
|
...
|
||
|
|
||
|
void SomeActivityFunction()
|
||
|
{
|
||
|
SAFFileSystem.RequestDirectory(this,true);
|
||
|
}
|
||
|
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent? data)
|
||
|
{
|
||
|
if(requestCode == SAFFileSystem.RequestCode && resultCode == Result.Ok)
|
||
|
{
|
||
|
var res=SAFFileSystem.GetSAFFromResponse(this,data);
|
||
|
if(res != null)
|
||
|
HandleFilesystem(res);
|
||
|
}
|
||
|
}
|
||
|
void HandleFilesystem(SAFFileSystem fs)
|
||
|
{
|
||
|
fs.CreateDirectory(Special.Root/"My Special Folder");
|
||
|
//read https://gitea.site.tesses.net/tesses50/tesses-vfs to get up to speed
|
||
|
//root is relative to the folder the user chose
|
||
|
//so get subdir filesystem is not needed
|
||
|
}
|
||
|
```
|
||
|
|
||
|
# How to use (presistant)
|
||
|
```csharp
|
||
|
...
|
||
|
using Tesses.VirtualFilesystem;
|
||
|
using Tesses.VirtualFilesystem.Filesystems;
|
||
|
using Android.Content;
|
||
|
using AndroidX.DocumentFile.Provider;
|
||
|
using Tesses.VirtualFilesystem.Extensions;
|
||
|
...
|
||
|
const string MySAFKey = "MySafKey";
|
||
|
void SomethingWithContext()
|
||
|
{
|
||
|
var res= SAFFileSystem.GetSAFFromSharedStorage(this,MySAFKey);
|
||
|
if(res != null)
|
||
|
HandleFilesystem(res);
|
||
|
}
|
||
|
void SomeActivityFunction()
|
||
|
{
|
||
|
var res= SAFFileSystem.GetSAFFromSharedStorage(this,MySAFKey);
|
||
|
if(res != null)
|
||
|
HandleFilesystem(res);
|
||
|
else
|
||
|
SAFFileSystem.RequestDirectory(this,true,true);
|
||
|
}
|
||
|
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent? data)
|
||
|
{
|
||
|
if(requestCode == SAFFileSystem.RequestCode && resultCode == Result.Ok)
|
||
|
{
|
||
|
var res=SAFFileSystem.GetSAFFromResponsePresistant(this,data,MySAFKey);
|
||
|
if(res != null)
|
||
|
HandleFilesystem(res);
|
||
|
}
|
||
|
}
|
||
|
void HandleFilesystem(SAFFileSystem fs)
|
||
|
{
|
||
|
fs.CreateDirectory(Special.Root/"My Special Folder");
|
||
|
//read https://gitea.site.tesses.net/tesses50/tesses-vfs to get up to speed
|
||
|
//root is relative to the folder the user chose
|
||
|
//so get subdir filesystem is not needed
|
||
|
}
|
||
|
```
|
||
|
# How to revoke permissions
|
||
|
```csharp
|
||
|
...
|
||
|
using Tesses.VirtualFilesystem;
|
||
|
using Tesses.VirtualFilesystem.Filesystems;
|
||
|
using Android.Content;
|
||
|
using AndroidX.DocumentFile.Provider;
|
||
|
using Tesses.VirtualFilesystem.Extensions;
|
||
|
...
|
||
|
const string MySAFKey = "MySafKey";
|
||
|
void SomethingWithContext()
|
||
|
{
|
||
|
SAFFileSystem.Revoke(this,MySAFKey);
|
||
|
}
|
||
|
```
|