Skip to content

Commit

Permalink
v4.4.14419.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed May 2, 2022
1 parent 35fa937 commit 6f53462
Show file tree
Hide file tree
Showing 74 changed files with 951 additions and 614 deletions.
2 changes: 1 addition & 1 deletion Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<RootNamespace>ITHit.FileSystem.Samples.Common</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem" Version="4.3.12907.0-Beta2" />
<PackageReference Include="ITHit.FileSystem" Version="4.4.14419.0" />
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions Common/FileSystemItemMetadataExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class FileSystemItemMetadataExt : IFileSystemItemMetadata
///<inheritdoc/>
public FileAttributes Attributes { get; set; }

///<inheritdoc/>
public byte[] CustomData { get; set; } = new byte[] { };

///<inheritdoc/>
public DateTimeOffset CreationTime { get; set; }

Expand Down
6 changes: 0 additions & 6 deletions Common/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ public class Settings
/// </summary>
public string UserFileSystemRootPath { get; set; }

/// <summary>
/// Network delay in milliseconds. When this parameter is > 0 the file download will be delayd to demonstrate file transfer progress.
/// Set this parameter to 0 to avoid any network simulation delays.
/// </summary>
public int NetworkSimulationDelayMs { get; set; }

/// <summary>
/// Path to the icons folder.
/// </summary>
Expand Down
8 changes: 5 additions & 3 deletions Common/StreamCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ITHit.FileSystem.Samples.Common
Expand All @@ -19,14 +20,15 @@ public static class StreamCopy
/// <param name="destination">The stream to which the contents of the current file stream will be copied.</param>
/// <param name="bufferSize">The size, in bytes, of the buffer. This value must be greater than zero.</param>
/// <param name="count">Number of bytes to copy.</param>
public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, long count)
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, long count, CancellationToken cancellationToken = default)
{
byte[] buffer = new byte[bufferSize];
int read;
while (count > 0
&& (read = await source.ReadAsync(buffer, 0, (int)Math.Min(buffer.LongLength, count))) > 0)
&& (read = await source.ReadAsync(buffer, 0, (int)Math.Min(buffer.LongLength, count), cancellationToken)) > 0)
{
await destination.WriteAsync(buffer, 0, read);
await destination.WriteAsync(buffer, 0, read, cancellationToken);
count -= read;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Windows/Common/Core/Common.Windows.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.4.14419.0" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
</ItemGroup>
</Project>
24 changes: 23 additions & 1 deletion Windows/Common/Core/Registrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Cryptography;
Expand Down Expand Up @@ -134,7 +135,7 @@ public static async Task<bool> IsRegisteredAsync(string path)
try
{
StorageProviderSyncRootManager.GetSyncRootInformationForFolder(storageFolder);
return true;
return FileSystem.Windows.PlaceholderItem.IsPlaceholder(path);
}
catch
{
Expand Down Expand Up @@ -164,5 +165,26 @@ public static async Task UnregisterAsync(string syncRootId)
{
StorageProviderSyncRootManager.Unregister(syncRootId);
}

/// <summary>
/// Helper method to determine if the process is running in a packaged context.
/// </summary>
/// <returns>True if the application is running in a packaged context, false otherwise.</returns>
public static bool IsRunningAsUwp()
{
const long APPMODEL_ERROR_NO_PACKAGE = 15700L;

int length = 0;
return GetCurrentPackageFullName(ref length, null) != APPMODEL_ERROR_NO_PACKAGE;
}

/// <summary>
/// Gets the package full name for the calling process.
/// </summary>
/// <param name="packageFullNameLength">On input, the size of the packageFullName buffer, in characters. On output, the size of the package full name returned, in characters, including the null terminator.</param>
/// <param name="packageFullName">The package full name.</param>
/// <returns>If the function succeeds it returns ERROR_SUCCESS. Otherwise, the function returns an error code.</returns>
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);
}
}
20 changes: 20 additions & 0 deletions Windows/Common/Rpc.Proto/ShellExtension.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ service ShellExtensionRpc {
rpc LogMessage (LogMessageRequest) returns (EmptyMessage) {}
rpc LogError (LogErrorRequest) returns (EmptyMessage) {}
rpc GetItemProperties (ItemPropertyRequest) returns (ItemsPropertyList) {}

rpc GetPathForContentUri (UriSourceRequest) returns (GetPathForContentUriResult) {}
rpc GetContentInfoForPath (UriSourceRequest) returns (GetContentInfoForPathResult) {}
}

message ItemsPathList {
Expand Down Expand Up @@ -59,3 +62,20 @@ message ItemsPropertyList {
message ItemPropertyRequest {
string path = 1;
}

message UriSourceRequest {
string pathOrUri = 1;
}

message GetPathForContentUriResult {
string path = 1;
int32 status = 2;
}

message GetContentInfoForPathResult {
string contentId = 1;
string contentUri = 2;
int32 status = 3;
}


Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.4.14419.0" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\Rpc.Proto\Common.Windows.Rpc.Proto.csproj" />
<ProjectReference Include="..\Rpc\Common.Windows.Rpc.csproj" />
Expand Down
68 changes: 0 additions & 68 deletions Windows/Common/ShellExtension/ShellExtensionInstaller.cs

This file was deleted.

43 changes: 43 additions & 0 deletions Windows/Common/ShellExtension/ShellExtensionRegistrar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Win32;
using System;

namespace ITHit.FileSystem.Samples.Common.Windows.ShellExtension
{
public class ShellExtensionRegistrar
{
private static readonly string ClsidKeyPathFormat = @"SOFTWARE\Classes\CLSID\{0:B}";
private static readonly string LocalServer32PathFormat = @$"{ClsidKeyPathFormat}\LocalServer32";
private static readonly string SyncRootPathFormat = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\{0}";

/// <summary>
/// Register shell service provider COM class and register it for sync root.
/// </summary>
/// <param name="syncRootId">Sync root identifier</param>
/// <param name="handlerName">Name of shell service provider</param>
/// <param name="handlerGuid">CLSID of shell service provider</param>
/// <param name="comServerPath">Absolute path to COM server executable</param>
public static void Register(string syncRootId, string handlerName, Guid handlerGuid, string comServerPath)
{
string handlerPath = handlerGuid.ToString("B").ToUpper();
string syncRootPath = string.Format(SyncRootPathFormat, syncRootId);

using RegistryKey syncRootKey = Registry.LocalMachine.OpenSubKey(syncRootPath, true);
syncRootKey.SetValue(handlerName, handlerPath);

string localServer32Path = string.Format(LocalServer32PathFormat, handlerPath);
using RegistryKey localServer32Key = Registry.CurrentUser.CreateSubKey(localServer32Path);
localServer32Key.SetValue(null, comServerPath);
}

/// <summary>
/// Unregister shell service provider COM class.
/// </summary>
/// <param name="handlerClsid"></param>
public static void Unregister(Guid handlerClsid)
{
string thumbnailProviderGuid = handlerClsid.ToString("B").ToUpper();
string clsidKeyPath = string.Format(ClsidKeyPathFormat, thumbnailProviderGuid);
Registry.CurrentUser.DeleteSubKeyTree(clsidKeyPath, false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.4.14419.0" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\Core\Common.Windows.Core.csproj" />
<ProjectReference Include="..\Rpc.Proto\Common.Windows.Rpc.Proto.csproj" />
Expand Down
93 changes: 0 additions & 93 deletions Windows/Common/VirtualDrive/FullSync/ClientToServerSync.cs

This file was deleted.

3 changes: 2 additions & 1 deletion Windows/Common/VirtualDrive/IVirtualFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ITHit.FileSystem.Samples.Common.Windows
{
public interface IVirtualFolder
{
public Task<IEnumerable<FileSystemItemMetadataExt>> EnumerateChildrenAsync(string pattern);
public Task<IEnumerable<FileSystemItemMetadataExt>> EnumerateChildrenAsync(string pattern, CancellationToken cancellationToken);
}
}
Loading

0 comments on commit 6f53462

Please sign in to comment.