Skip to content

Commit 6f53462

Browse files
committed
v4.4.14419.0
1 parent 35fa937 commit 6f53462

File tree

74 files changed

+951
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+951
-614
lines changed

Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<RootNamespace>ITHit.FileSystem.Samples.Common</RootNamespace>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="ITHit.FileSystem" Version="4.3.12907.0-Beta2" />
12+
<PackageReference Include="ITHit.FileSystem" Version="4.4.14419.0" />
1313
</ItemGroup>
1414
</Project>

Common/FileSystemItemMetadataExt.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ public class FileSystemItemMetadataExt : IFileSystemItemMetadata
2121
///<inheritdoc/>
2222
public FileAttributes Attributes { get; set; }
2323

24-
///<inheritdoc/>
25-
public byte[] CustomData { get; set; } = new byte[] { };
26-
2724
///<inheritdoc/>
2825
public DateTimeOffset CreationTime { get; set; }
2926

Common/Settings.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ public class Settings
3232
/// </summary>
3333
public string UserFileSystemRootPath { get; set; }
3434

35-
/// <summary>
36-
/// Network delay in milliseconds. When this parameter is > 0 the file download will be delayd to demonstrate file transfer progress.
37-
/// Set this parameter to 0 to avoid any network simulation delays.
38-
/// </summary>
39-
public int NetworkSimulationDelayMs { get; set; }
40-
4135
/// <summary>
4236
/// Path to the icons folder.
4337
/// </summary>

Common/StreamCopy.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Text;
5+
using System.Threading;
56
using System.Threading.Tasks;
67

78
namespace ITHit.FileSystem.Samples.Common
@@ -19,14 +20,15 @@ public static class StreamCopy
1920
/// <param name="destination">The stream to which the contents of the current file stream will be copied.</param>
2021
/// <param name="bufferSize">The size, in bytes, of the buffer. This value must be greater than zero.</param>
2122
/// <param name="count">Number of bytes to copy.</param>
22-
public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, long count)
23+
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
24+
public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, long count, CancellationToken cancellationToken = default)
2325
{
2426
byte[] buffer = new byte[bufferSize];
2527
int read;
2628
while (count > 0
27-
&& (read = await source.ReadAsync(buffer, 0, (int)Math.Min(buffer.LongLength, count))) > 0)
29+
&& (read = await source.ReadAsync(buffer, 0, (int)Math.Min(buffer.LongLength, count), cancellationToken)) > 0)
2830
{
29-
await destination.WriteAsync(buffer, 0, read);
31+
await destination.WriteAsync(buffer, 0, read, cancellationToken);
3032
count -= read;
3133
}
3234
}

Windows/Common/Core/Common.Windows.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
1515
</ItemGroup>
1616
<ItemGroup>
17-
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
17+
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.4.14419.0" />
1818
<ProjectReference Include="..\..\..\Common\Common.csproj" />
1919
</ItemGroup>
2020
</Project>

Windows/Common/Core/Registrar.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Runtime.InteropServices;
56
using System.Text;
67
using System.Threading.Tasks;
78
using Windows.Security.Cryptography;
@@ -134,7 +135,7 @@ public static async Task<bool> IsRegisteredAsync(string path)
134135
try
135136
{
136137
StorageProviderSyncRootManager.GetSyncRootInformationForFolder(storageFolder);
137-
return true;
138+
return FileSystem.Windows.PlaceholderItem.IsPlaceholder(path);
138139
}
139140
catch
140141
{
@@ -164,5 +165,26 @@ public static async Task UnregisterAsync(string syncRootId)
164165
{
165166
StorageProviderSyncRootManager.Unregister(syncRootId);
166167
}
168+
169+
/// <summary>
170+
/// Helper method to determine if the process is running in a packaged context.
171+
/// </summary>
172+
/// <returns>True if the application is running in a packaged context, false otherwise.</returns>
173+
public static bool IsRunningAsUwp()
174+
{
175+
const long APPMODEL_ERROR_NO_PACKAGE = 15700L;
176+
177+
int length = 0;
178+
return GetCurrentPackageFullName(ref length, null) != APPMODEL_ERROR_NO_PACKAGE;
179+
}
180+
181+
/// <summary>
182+
/// Gets the package full name for the calling process.
183+
/// </summary>
184+
/// <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>
185+
/// <param name="packageFullName">The package full name.</param>
186+
/// <returns>If the function succeeds it returns ERROR_SUCCESS. Otherwise, the function returns an error code.</returns>
187+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
188+
static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);
167189
}
168190
}

Windows/Common/Rpc.Proto/ShellExtension.proto

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ service ShellExtensionRpc {
99
rpc LogMessage (LogMessageRequest) returns (EmptyMessage) {}
1010
rpc LogError (LogErrorRequest) returns (EmptyMessage) {}
1111
rpc GetItemProperties (ItemPropertyRequest) returns (ItemsPropertyList) {}
12+
13+
rpc GetPathForContentUri (UriSourceRequest) returns (GetPathForContentUriResult) {}
14+
rpc GetContentInfoForPath (UriSourceRequest) returns (GetContentInfoForPathResult) {}
1215
}
1316

1417
message ItemsPathList {
@@ -59,3 +62,20 @@ message ItemsPropertyList {
5962
message ItemPropertyRequest {
6063
string path = 1;
6164
}
65+
66+
message UriSourceRequest {
67+
string pathOrUri = 1;
68+
}
69+
70+
message GetPathForContentUriResult {
71+
string path = 1;
72+
int32 status = 2;
73+
}
74+
75+
message GetContentInfoForPathResult {
76+
string contentId = 1;
77+
string contentUri = 2;
78+
int32 status = 3;
79+
}
80+
81+

Windows/Common/ShellExtension/Common.Windows.ShellExtension.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
2121
</ItemGroup>
2222
<ItemGroup>
23-
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
23+
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.4.14419.0" />
2424
<ProjectReference Include="..\..\..\Common\Common.csproj" />
2525
<ProjectReference Include="..\Rpc.Proto\Common.Windows.Rpc.Proto.csproj" />
2626
<ProjectReference Include="..\Rpc\Common.Windows.Rpc.csproj" />

Windows/Common/ShellExtension/ShellExtensionInstaller.cs

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Microsoft.Win32;
2+
using System;
3+
4+
namespace ITHit.FileSystem.Samples.Common.Windows.ShellExtension
5+
{
6+
public class ShellExtensionRegistrar
7+
{
8+
private static readonly string ClsidKeyPathFormat = @"SOFTWARE\Classes\CLSID\{0:B}";
9+
private static readonly string LocalServer32PathFormat = @$"{ClsidKeyPathFormat}\LocalServer32";
10+
private static readonly string SyncRootPathFormat = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\{0}";
11+
12+
/// <summary>
13+
/// Register shell service provider COM class and register it for sync root.
14+
/// </summary>
15+
/// <param name="syncRootId">Sync root identifier</param>
16+
/// <param name="handlerName">Name of shell service provider</param>
17+
/// <param name="handlerGuid">CLSID of shell service provider</param>
18+
/// <param name="comServerPath">Absolute path to COM server executable</param>
19+
public static void Register(string syncRootId, string handlerName, Guid handlerGuid, string comServerPath)
20+
{
21+
string handlerPath = handlerGuid.ToString("B").ToUpper();
22+
string syncRootPath = string.Format(SyncRootPathFormat, syncRootId);
23+
24+
using RegistryKey syncRootKey = Registry.LocalMachine.OpenSubKey(syncRootPath, true);
25+
syncRootKey.SetValue(handlerName, handlerPath);
26+
27+
string localServer32Path = string.Format(LocalServer32PathFormat, handlerPath);
28+
using RegistryKey localServer32Key = Registry.CurrentUser.CreateSubKey(localServer32Path);
29+
localServer32Key.SetValue(null, comServerPath);
30+
}
31+
32+
/// <summary>
33+
/// Unregister shell service provider COM class.
34+
/// </summary>
35+
/// <param name="handlerClsid"></param>
36+
public static void Unregister(Guid handlerClsid)
37+
{
38+
string thumbnailProviderGuid = handlerClsid.ToString("B").ToUpper();
39+
string clsidKeyPath = string.Format(ClsidKeyPathFormat, thumbnailProviderGuid);
40+
Registry.CurrentUser.DeleteSubKeyTree(clsidKeyPath, false);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)