Skip to content

Commit

Permalink
v1.4.4298.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed Mar 7, 2021
1 parent 717ab0f commit 1b0e419
Show file tree
Hide file tree
Showing 116 changed files with 2,268 additions and 0 deletions.
22 changes: 22 additions & 0 deletions VirtualFileSystemMac/FileProviderExtension/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(TeamIdentifierPrefix)group.com.ithit.virtualfilesystem</string>
</array>
<key>com.apple.security.files.downloads.read-write</key>
<true/>
<key>com.apple.security.assets.pictures.read-write</key>
<true/>
<key>com.apple.security.assets.music.read-write</key>
<true/>
<key>com.apple.security.assets.movies.read-write</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{30EDD98F-A449-4A9F-A718-EE480181C619}</ProjectGuid>
<ProjectTypeGuids>{10CE9E57-9141-4DF0-916A-2C4FD4EE2A73};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>FileProviderExtension</RootNamespace>
<AssemblyName>FileProviderExtension</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
<ReleaseVersion>0.5</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>true</EnableCodeSigning>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<HttpClientHandler></HttpClientHandler>
<LinkMode>None</LinkMode>
<AOTMode>None</AOTMode>
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
<CodeSignProvision>ITHit Profile</CodeSignProvision>
<LangVersion>9.0</LangVersion>
<UseHardenedRuntime>true</UseHardenedRuntime>
<XamMacArch>x86_64</XamMacArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>true</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<CodeSignEntitlements>Entitlements.plist</CodeSignEntitlements>
<LinkMode>SdkOnly</LinkMode>
<HttpClientHandler></HttpClientHandler>
<AOTMode>None</AOTMode>
<LangVersion>9.0</LangVersion>
<UseHardenedRuntime>true</UseHardenedRuntime>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
<Reference Include="ITHit.FileSystem">
<HintPath>..\packages\ITHit.FileSystem.1.4.4298\lib\netstandard2.1\ITHit.FileSystem.dll</HintPath>
</Reference>
<Reference Include="ITHit.FileSystem.Mac">
<HintPath>..\packages\ITHit.FileSystem.Mac.1.4.4298-Alpha\lib\xamarinmac74\ITHit.FileSystem.Mac.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="VfsFolder.cs" />
<Compile Include="VfsEngine.cs" />
<Compile Include="VfsFile.cs" />
<Compile Include="VfsFileSystemItem.cs" />
<Compile Include="Mapping.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtualFilesystemCommon\VirtualFilesystemCommon.csproj">
<Project>{8A146BCC-DE6F-436F-9C25-67AD964E473F}</Project>
<Name>VirtualFilesystemCommon</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.AppExtension.CSharp.targets" />
</Project>
41 changes: 41 additions & 0 deletions VirtualFileSystemMac/FileProviderExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>FileProviderExtension</string>
<key>CFBundleIdentifier</key>
<string>com.ithit.virtualfilesystem.app.extension</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>FileProviderExtension</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>LSUIElement</key>
<true/>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict/>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.fileprovider-nonui</string>
<key>NSExtensionPrincipalClass</key>
<string>VfsEngine</string>
<key>NSExtensionFileProviderSupportsEnumeration</key>
<true/>
</dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
90 changes: 90 additions & 0 deletions VirtualFileSystemMac/FileProviderExtension/Mapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System.IO;
using ITHit.FileSystem;
using VirtualFilesystemCommon;

namespace FileProviderExtension
{
/// <summary>
/// Maps a user file system path to the remote storage path and back.
/// </summary>
/// <remarks>You will change methods of this class to map the user file system path to your remote storage path.</remarks>
internal static class Mapping
{
/// <summary>
/// Returns a remote storage URI that corresponds to the user file system path.
/// </summary>
/// <param name="userFileSystemPath">Full path in the user file system.</param>
/// <returns>Remote storage URI that corresponds to the <paramref name="userFileSystemPath"/>.</returns>
public static string MapPath(string userFileSystemPath)
{
// Get path relative to the virtual root.
string relativePath = userFileSystemPath.TrimEnd(Path.DirectorySeparatorChar).Substring(
AppGroupSettings.GetUserRootPath().TrimEnd(Path.DirectorySeparatorChar).Length);

string path = $"{AppGroupSettings.GetRemoteRootPath().TrimEnd(Path.DirectorySeparatorChar)}{relativePath}";
return path;
}

/// <summary>
/// Returns a user file system path that corresponds to the remote storage URI.
/// </summary>
/// <param name="remoteStorageUri">Remote storage URI.</param>
/// <returns>Path in the user file system that corresponds to the <paramref name="remoteStorageUri"/>.</returns>
public static string ReverseMapPath(string remoteStorageUri)
{
// Get path relative to the virtual root.
string relativePath = remoteStorageUri.TrimEnd(Path.DirectorySeparatorChar).Substring(
AppGroupSettings.GetRemoteRootPath().TrimEnd(Path.DirectorySeparatorChar).Length);

string path = $"{AppGroupSettings.GetUserRootPath().TrimEnd(Path.DirectorySeparatorChar)}{relativePath}";
return path;
}

/// <summary>
/// Gets a user file system item info from the remote storage data.
/// </summary>
/// <param name="remoteStorageItem">Remote storage item info.</param>
/// <returns>User file system item info.</returns>
public static IFileSystemItemBasicInfo GetUserFileSysteItemBasicInfo(FileSystemInfo remoteStorageItem)
{
VfsFileSystemItem userFileSystemItem;

if (remoteStorageItem is FileInfo)
{
FileInfo remoteStorageFile = (FileInfo)remoteStorageItem;
userFileSystemItem = new VfsFile(remoteStorageFile.FullName, remoteStorageFile.Attributes, remoteStorageFile.CreationTime,
remoteStorageFile.LastWriteTime, remoteStorageFile.LastAccessTime, remoteStorageFile.Length);
}
else
{
userFileSystemItem = new VfsFolder(remoteStorageItem.FullName, remoteStorageItem.Attributes, remoteStorageItem.CreationTime,
remoteStorageItem.LastWriteTime, remoteStorageItem.LastAccessTime);
}

userFileSystemItem.Name = remoteStorageItem.FullName;
userFileSystemItem.Attributes = remoteStorageItem.Attributes;
userFileSystemItem.CreationTime = remoteStorageItem.CreationTime;
userFileSystemItem.LastWriteTime = remoteStorageItem.LastWriteTime;
userFileSystemItem.LastAccessTime = remoteStorageItem.LastAccessTime;
userFileSystemItem.ChangeTime = remoteStorageItem.LastWriteTime;

// You will send the ETag to
// the server inside If-Match header togeter with updated content from client.
// This will make sure the changes on the server is not overwritten.
//
// In this sample, for the sake of simplicity, we use file last write time instead of ETag.
userFileSystemItem.ETag = remoteStorageItem.LastWriteTime.ToBinary().ToString();

// If the item is locked by another user, set the LockedByAnotherUser to true.
// Here we just use the read-only attribute from remote storage item for demo purposes.
userFileSystemItem.LockedByAnotherUser = (remoteStorageItem.Attributes & FileAttributes.ReadOnly) != 0;

if (remoteStorageItem is FileInfo)
{
((VfsFile)userFileSystemItem).Length = ((FileInfo)remoteStorageItem).Length;
};

return userFileSystemItem;
}
}
}
61 changes: 61 additions & 0 deletions VirtualFileSystemMac/FileProviderExtension/VfsEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.IO;
using System.Threading.Tasks;
using FileProvider;
using Foundation;
using ITHit.FileSystem;
using ITHit.FileSystem.Mac;
using VirtualFilesystemCommon;

namespace FileProviderExtension
{
[Register(nameof(VfsEngine))]
public class VfsEngine : EngineMac
{
[Export("initWithDomain:")]
public VfsEngine(NSFileProviderDomain domain)
: base(domain)
{
License = AppGroupSettings.GetLicense();
}

public override async Task<IFileSystemItem> GetFileSystemItemAsync(string path)
{
string remotePath = Mapping.MapPath(path);

if (File.Exists(remotePath))
{
FileInfo fileInfo = new FileInfo(remotePath);
return new VfsFile(Mapping.ReverseMapPath(fileInfo.FullName), fileInfo.Attributes, fileInfo.CreationTime, fileInfo.LastWriteTime, fileInfo.LastAccessTime, fileInfo.Length);
}

if (Directory.Exists(remotePath))
{
DirectoryInfo dirInfo = new DirectoryInfo(remotePath);
return new VfsFolder(Mapping.ReverseMapPath(dirInfo.FullName), dirInfo.Attributes, dirInfo.CreationTime, dirInfo.LastWriteTime, dirInfo.LastAccessTime);
}

return null;
}

public override void LogError(string message, string sourcePath = null, string targetPath = null, Exception ex = null)
{
throw new NotImplementedException();
}

public override void LogMessage(string message, string sourcePath = null, string targetPath = null)
{
throw new NotImplementedException();
}

public override void RiseError(string message, string sourcePath = null, string targetPath = null, Exception ex = null)
{
throw new NotImplementedException();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
}
}
54 changes: 54 additions & 0 deletions VirtualFileSystemMac/FileProviderExtension/VfsFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.IO;
using System.Threading.Tasks;
using ITHit.FileSystem;

namespace FileProviderExtension
{
public class VfsFile : VfsFileSystemItem, IFile, IFileBasicInfo
{
public long Length { get; set; }

public VfsFile(string name, FileAttributes attributes,
DateTimeOffset creationTime, DateTimeOffset lastWriteTime, DateTimeOffset lastAccessTime, long length)
: base(name)
{
Name = name;
Attributes = attributes;
CreationTime = creationTime;
LastWriteTime = lastWriteTime;
LastAccessTime = lastAccessTime;
Length = length;
}

public async Task CloseAsync(IOperationContext operationContext, IResultContext context)
{
throw new NotImplementedException();
}

public async Task DeleteAsync(IOperationContext operationContext, IConfirmationResultContext resultContext)
{
throw new NotImplementedException();
}

public async Task MoveToAsync(string targetPath, IOperationContext operationContext, IConfirmationResultContext resultContext)
{
throw new NotImplementedException();
}

public async Task OpenAsync(IOperationContext operationContext, IResultContext context)
{
throw new NotImplementedException();
}

public async Task TransferDataAsync(long offset, long length, ITransferDataOperationContext operationContext, ITransferDataResultContext resultContext)
{
throw new NotImplementedException();
}

public async Task ValidateDataAsync(long offset, long length, IValidateDataOperationContext operationContext, IValidateDataResultContext resultContext)
{
throw new NotImplementedException();
}
}
}
Loading

0 comments on commit 1b0e419

Please sign in to comment.