tesses-vfs/Tesses.VirtualFilesystem.Saf
Mike Nolan 1f3f1c9b89 Added Storage access framework, DiscUtils More of Zio, Fixed Dispose and internal function UnixPath.SetPath 2024-07-22 18:44:49 -05:00
..
Class1.cs Added Storage access framework, DiscUtils More of Zio, Fixed Dispose and internal function UnixPath.SetPath 2024-07-22 18:44:49 -05:00
README.md Added Storage access framework, DiscUtils More of Zio, Fixed Dispose and internal function UnixPath.SetPath 2024-07-22 18:44:49 -05:00
Tesses.VirtualFilesystem.Saf.csproj Added Storage access framework, DiscUtils More of Zio, Fixed Dispose and internal function UnixPath.SetPath 2024-07-22 18:44:49 -05:00

README.md

Tesses.VirtualFilesystem.Saf

A library to use Tesses.VirtualFilesystem with Storage Access Framework (Android)

Nuget

License

GPL3-only Licensed under GPL3

How to use (not presistant)

   ...
   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)

   ...
   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

   ...
   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);
    }