Skip to content

Commit 0329171

Browse files
committed
v5.6.16382.0
1 parent 73080a6 commit 0329171

32 files changed

+220
-214
lines changed

Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<Platforms>AnyCPU;x64</Platforms>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="ITHit.FileSystem" Version="5.6.16274.0-Beta2" />
13+
<PackageReference Include="ITHit.FileSystem" Version="5.6.16382.0" />
1414
</ItemGroup>
1515
</Project>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
2121
</ItemGroup>
2222
<ItemGroup>
23-
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="5.6.16274.0-Beta2" />
24-
<PackageReference Include="ITHit.FileSystem.Windows" Version="5.6.16274.0-Beta2" />
23+
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="5.6.16382.0" />
24+
<PackageReference Include="ITHit.FileSystem.Windows" Version="5.6.16382.0" />
2525
<ProjectReference Include="..\..\..\Common\Common.csproj" />
2626
</ItemGroup>
2727
</Project>

Windows/Common/Core/FsPath.cs

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@ namespace ITHit.FileSystem.Samples.Common.Windows
1414
/// </summary>
1515
public static class FsPath
1616
{
17-
/// <summary>
18-
/// Returns true if the path points to a file. False - otherwise.
19-
/// </summary>
20-
/// <remarks>Throws exception if the file/folder does not exists.</remarks>
21-
/// <param name="path">Path to the file or folder.</param>
22-
/// <returns>True if the path is file. False - otherwise.</returns>
23-
public static bool IsFile(string path)
24-
{
25-
return !IsFolder(path);
26-
}
27-
2817
/// <summary>
2918
/// Returns true if the path points to a folder. False - otherwise.
3019
/// </summary>
@@ -48,32 +37,6 @@ public static bool Exists(string path)
4837
return File.Exists(path) || Directory.Exists(path);
4938
}
5039

51-
public static FileSystemItemType GetItemType(string path)
52-
{
53-
return FsPath.IsFile(path) ? FileSystemItemType.File : FileSystemItemType.Folder;
54-
}
55-
56-
/// <summary>
57-
/// Returns storage item or null if item does not eists.
58-
/// </summary>
59-
/// <param name="path">Path to the file or folder.</param>
60-
/// <returns>
61-
/// Instance of <see cref="Windows.Storage.StorageFile"/> or <see cref="Windows.Storage.StorageFolder"/>
62-
/// that corresponds to path or null if item does not exists.
63-
/// </returns>
64-
public static async Task<IStorageItem> GetStorageItemAsync(string path)
65-
{
66-
if (File.Exists(path))
67-
{
68-
return await StorageFile.GetFileFromPathAsync(path);
69-
}
70-
if (Directory.Exists(path))
71-
{
72-
return await StorageFolder.GetFolderFromPathAsync(path);
73-
}
74-
return null;
75-
}
76-
7740
/// <summary>
7841
/// Returns folder or file item or null if the item does not exists.
7942
/// </summary>
@@ -94,64 +57,5 @@ public static FileSystemInfo GetFileSystemItem(string path)
9457
}
9558
return null;
9659
}
97-
98-
/// <summary>
99-
/// Gets file or folder attributes in a human-readable form.
100-
/// </summary>
101-
/// <param name="path">Path to the file or folder.</param>
102-
/// <returns>String that represents file or folder attributes or null if the file/folder is not found.</returns>
103-
public static string GetAttString(string path)
104-
{
105-
if (WindowsFileSystemItem.TryGetAttributes(path, out FileAttributes? attributes))
106-
{
107-
return WindowsFileSystemItem.GetFileAttributesString(attributes.Value);
108-
}
109-
else
110-
{
111-
return null;
112-
}
113-
}
114-
115-
/// <summary>
116-
/// Gets formatted file size or null for folders or if the file is not found.
117-
/// </summary>
118-
/// <param name="path">Path to a file or folder.</param>
119-
public static string Size(string path)
120-
{
121-
if (!File.Exists(path))
122-
{
123-
return null;
124-
}
125-
126-
long length;
127-
try
128-
{
129-
length = new FileInfo(path).Length;
130-
}
131-
catch
132-
{
133-
return null;
134-
}
135-
136-
return FormatBytes(length);
137-
}
138-
139-
/// <summary>
140-
/// Formats bytes to string.
141-
/// </summary>
142-
/// <param name="length">Bytes to format.</param>
143-
/// <returns>Human readable bytes string.</returns>
144-
public static string FormatBytes(long length)
145-
{
146-
string[] suf = { "b ", "KB", "MB", "GB", "TB", "PB", "EB" };
147-
if (length == 0)
148-
{
149-
return "0" + suf[0];
150-
}
151-
long bytes = Math.Abs(length);
152-
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
153-
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
154-
return (Math.Sign(length) * num).ToString() + suf[place];
155-
}
15660
}
15761
}

Windows/Common/Core/LogFormatter.cs

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void LogDebug(IEngine sender, EngineMessageEventArgs e)
196196
/// <param name="level">Log level.</param>
197197
private void WriteLog(IEngine sender, EngineMessageEventArgs e, log4net.Core.Level level)
198198
{
199-
string att = FsPath.GetAttString(e.TargetPath ?? e.SourcePath);
199+
string att = GetAttString(e.TargetPath ?? e.SourcePath);
200200
string process = null;
201201
byte? priorityHint = null;
202202
string fileId = null;
@@ -207,7 +207,7 @@ private void WriteLog(IEngine sender, EngineMessageEventArgs e, log4net.Core.Lev
207207
process = System.IO.Path.GetFileName(e.OperationContext.ProcessInfo?.ImagePath);
208208
priorityHint = e.OperationContext.PriorityHint;
209209
fileId = (e.OperationContext as IWindowsOperationContext).FileId.ToString();
210-
size = FsPath.FormatBytes((e.OperationContext as IWindowsOperationContext).FileSize);
210+
size = FormatBytes((e.OperationContext as IWindowsOperationContext).FileSize);
211211
}
212212

213213
string sourcePath = e.SourcePath?.FitString(sourcePathWidth, 6);
@@ -221,8 +221,8 @@ private void WriteLog(IEngine sender, EngineMessageEventArgs e, log4net.Core.Lev
221221
if (ex != null)
222222
{
223223
message += Environment.NewLine;
224-
log.Error(message, ex);
225224
}
225+
log.Error(message, ex);
226226
}
227227
else if (level == log4net.Core.Level.Info)
228228
{
@@ -250,6 +250,65 @@ private void PrintHeader()
250250
log.Info(Format("Time", "Process Name", "Prty", "FS ID", "RS ID", "Component", "Line", "Caller Member Name", "Caller File Path", "Message", "Source Path", "Attributes", "Target Path"));
251251
log.Info(Format("----", "------------", "----", "_____", "_____", "---------", "____", "------------------", "----------------", "-------", "-----------", "----------", "-----------"));
252252
}
253+
254+
/// <summary>
255+
/// Gets file or folder attributes in a human-readable form.
256+
/// </summary>
257+
/// <param name="path">Path to the file or folder.</param>
258+
/// <returns>String that represents file or folder attributes or null if the file/folder is not found.</returns>
259+
public static string GetAttString(string path)
260+
{
261+
if (WindowsFileSystemItem.TryGetAttributes(path, out System.IO.FileAttributes? attributes))
262+
{
263+
return WindowsFileSystemItem.GetFileAttributesString(attributes.Value);
264+
}
265+
else
266+
{
267+
return null;
268+
}
269+
}
270+
271+
/// <summary>
272+
/// Gets formatted file size or null for folders or if the file is not found.
273+
/// </summary>
274+
/// <param name="path">Path to a file or folder.</param>
275+
public static string Size(string path)
276+
{
277+
if (!File.Exists(path))
278+
{
279+
return null;
280+
}
281+
282+
long length;
283+
try
284+
{
285+
length = new FileInfo(path).Length;
286+
}
287+
catch
288+
{
289+
return null;
290+
}
291+
292+
return FormatBytes(length);
293+
}
294+
295+
/// <summary>
296+
/// Formats bytes to string.
297+
/// </summary>
298+
/// <param name="length">Bytes to format.</param>
299+
/// <returns>Human readable bytes string.</returns>
300+
public static string FormatBytes(long length)
301+
{
302+
string[] suf = { "b ", "KB", "MB", "GB", "TB", "PB", "EB" };
303+
if (length == 0)
304+
{
305+
return "0" + suf[0];
306+
}
307+
long bytes = Math.Abs(length);
308+
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
309+
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
310+
return (Math.Sign(length) * num).ToString() + suf[place];
311+
}
253312
}
254313

255314
static class StringExtensions

Windows/Common/Core/Registrar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static async Task<bool> IsRegisteredAsync(string path)
137137
try
138138
{
139139
StorageProviderSyncRootManager.GetSyncRootInformationForFolder(storageFolder);
140-
return FileSystem.Windows.PlaceholderItem.IsPlaceholder(path);
140+
return true;
141141
}
142142
catch
143143
{

Windows/Common/VirtualDrive/Common.Windows.VirtualDrive.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Platforms>AnyCPU;x64</Platforms>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="ITHit.FileSystem.Windows" Version="5.6.16274.0-Beta2" />
12+
<PackageReference Include="ITHit.FileSystem.Windows" Version="5.6.16382.0" />
1313
<ProjectReference Include="..\..\..\Common\Common.csproj" />
1414
<ProjectReference Include="..\Core\Common.Windows.Core.csproj" />
1515
</ItemGroup>

Windows/Common/VirtualDrive/VirtualEngineBase.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,22 @@ public VirtualEngineBase(
6363
}
6464

6565
/// <inheritdoc/>
66-
public override async Task<bool> FilterAsync(SyncDirection direction, OperationType operationType, string path, FileSystemItemType itemType, string newPath = null, FileAttributes? attributes = null, IOperationContext operationContext = null)
66+
public override async Task<bool> FilterAsync(SyncDirection direction, OperationType operationType, string path, FileSystemItemType itemType, string newPath = null, IOperationContext operationContext = null)
6767
{
68-
// Use the code below to filter based on files and folders attributes.
69-
//if (await new AttributesFilter(FileAttributes.Hidden | FileAttributes.Temporary).FilterAsync(direction, operationType, path, itemType, newPath, attributes))
70-
//{
71-
// LogDebug($"{nameof(AttributesFilter)} filtered {operationType}", path, newPath, operationContext);
72-
// return true;
73-
//}
74-
75-
if (await new ZipFilter().FilterAsync(direction, operationType, path, itemType, newPath, attributes))
68+
69+
if (await new ZipFilter().FilterAsync(direction, operationType, path, itemType, newPath))
7670
{
7771
LogDebug($"{nameof(ZipFilter)} filtered {operationType}", path, newPath, operationContext);
7872
return true;
7973
}
8074

81-
if (await new MsOfficeFilter().FilterAsync(direction, operationType, path, itemType, newPath, attributes))
75+
if (await new MsOfficeFilter().FilterAsync(direction, operationType, path, itemType, newPath))
8276
{
8377
LogDebug($"{nameof(MsOfficeFilter)} filtered {operationType}", path, newPath, operationContext);
8478
return true;
8579
}
8680

87-
if (await new AutoCadFilter().FilterAsync(direction, operationType, path, itemType, newPath, attributes))
81+
if (await new AutoCadFilter().FilterAsync(direction, operationType, path, itemType, newPath))
8882
{
8983
LogDebug($"{nameof(AutoCadFilter)} filtered {operationType}", path, newPath, operationContext);
9084
return true;

Windows/VirtualDrive/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<li>NTFS file system.</li>
1313
</ul>
1414
<h2 class="heading-link" id="nav_configuringthesample">Configuring the Sample<a class="list-link d-inline" href="https://www.userfilesystem.com/examples/virtual_file_system/#nav_configuringthesample"></a></h2>
15-
<p>By default, the sample will use the&nbsp;<span class="code">\RemoteStorage\</span>&nbsp;folder, located under the project root, to simulate the remote storage file structure. It will mount the user file system under the&nbsp;<span class="code">%USERPROFILE%\VFS\</span>&nbsp;folder (typically&nbsp;<span class="code">C:\Users\&lt;username&gt;\VirtualDrive\</span>).</p>
16-
<p>To specify the folder that will be used for remote storage simulation edit the&nbsp;<span class="code">"RemoteStorageRootPath"</span>&nbsp;parameter in&nbsp;<span class="code">appsettings.json</span>. This could be either an absolute path or a path relative to the application root.</p>
17-
<p>To specify the user file system folder edit the&nbsp;<span class="code">"UserFileSystemRootPath"</span>&nbsp;parameter&nbsp;in&nbsp;<span class="code">appsettings.json</span>.</p>
15+
<p>By default, the sample will use the&nbsp;<code class="code">\RemoteStorage\</code>&nbsp;folder, located under the project root, to simulate the remote storage file structure. It will mount the user file system under the&nbsp;<code class="code">%USERPROFILE%\VFS\</code>&nbsp;folder (typically&nbsp;<code class="code">C:\Users\&lt;username&gt;\VirtualDrive\</code>).</p>
16+
<p>To specify the folder that will be used for remote storage simulation edit the&nbsp;<code class="code">"RemoteStorageRootPath"</code>&nbsp;parameter in&nbsp;<code class="code">appsettings.json</code>. This could be either an absolute path or a path relative to the application root.</p>
17+
<p>To specify the user file system folder edit the&nbsp;<code class="code">"UserFileSystemRootPath"</code>&nbsp;parameter&nbsp;in&nbsp;<code class="code">appsettings.json</code>.</p>
1818
<h2 class="heading-link" id="nav_settingthelicense">Setting the License<a class="list-link d-inline" href="https://www.userfilesystem.com/examples/virtual_file_system/#nav_settingthelicense"></a></h2>
19-
<p>To run the example, you will need a valid IT Hit User File System Engine for .NET License. You can download the license in&nbsp;the&nbsp;<a title="IT Hit User File System for .NET Download" href="https://www.userfilesystem.com/download/">product download area</a>.&nbsp;Note that the Engine is fully functional with a trial license and does not have any limitations. The trial license is valid for one month and the engine will stop working after this. You can check the expiration date inside the license file.&nbsp;Download the license file and specify its content in the&nbsp;<span class="code">UserFileSystemLicense</span>&nbsp;field in&nbsp;<span class="code">appsettings.json</span>&nbsp;file.&nbsp;Set the license content directly as a value (NOT as a path to the license file). Do not forget to escape quotes: \":</p>
19+
<p>To run the example, you will need a valid IT Hit User File System Engine for .NET License. You can download the license in&nbsp;the&nbsp;<a title="IT Hit User File System for .NET Download" href="https://www.userfilesystem.com/download/">product download area</a>.&nbsp;Note that the Engine is fully functional with a trial license and does not have any limitations. The trial license is valid for one month and the engine will stop working after this. You can check the expiration date inside the license file.&nbsp;Download the license file and specify its content in the&nbsp;<code class="code">UserFileSystemLicense</code>&nbsp;field in&nbsp;<code class="code">appsettings.json</code>&nbsp;file.&nbsp;Set the license content directly as a value (NOT as a path to the license file). Do not forget to escape quotes: \":</p>
2020
<pre class="brush:xml;auto-links:false;toolbar:false">"UserFileSystemLicense": "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;&lt;License…</pre>
21-
<p>You can also run the sample&nbsp;without explicitly specifying a license&nbsp;for 5 days. In this case,&nbsp;the&nbsp;Engine will automatically request the trial license from the IT Hit website https://www.userfilesystem.com. Make sure it is accessible via firewalls if any. After 5 days the Engine will stop working. To extend the trial period you will need to download a license in a&nbsp;<a title="IT Hit User File System for .NET Download" href="https://www.userfilesystem.com/download/">product download area</a>&nbsp;and specify it in&nbsp;<span class="code">appsettings.json</span></p>
21+
<p>You can also run the sample&nbsp;without explicitly specifying a license&nbsp;for 5 days. In this case,&nbsp;the&nbsp;Engine will automatically request the trial license from the IT Hit website https://www.userfilesystem.com. Make sure it is accessible via firewalls if any. After 5 days the Engine will stop working. To extend the trial period you will need to download a license in a&nbsp;<a title="IT Hit User File System for .NET Download" href="https://www.userfilesystem.com/download/">product download area</a>&nbsp;and specify it in&nbsp;<code class="code">appsettings.json</code></p>
2222
<h2 class="heading-link" id="nav_runningthesample">Running the Sample<a class="list-link d-inline" href="https://www.userfilesystem.com/examples/virtual_file_system/#nav_runningthesample"></a></h2>
2323
<p>To run the sample open the project in Visual Studio and run the project in debug mode. When starting in the debug mode, it will automatically create a folder in which the virtual file system will reside, register the virtual drive with the platform and then open&nbsp;two instances of Windows File Manager, one of which will show a virtual drive and another a folder simulating remote storage.&nbsp;</p>
2424
<p>You can find more about running and stopping the sample as well as about basic synchronization features in the&nbsp;<a title="Virtual File System Sample for Windows" href="https://www.userfilesystem.com/examples/virtual_file_system/">Virtual File System</a>&nbsp;sample description.&nbsp;</p>

Windows/VirtualDrive/VirtualDrive.ShellExtension/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
using ITHit.FileSystem.Windows.ShellExtension;
12
using System;
23
using System.Diagnostics;
34
using System.Threading.Tasks;
45
using Windows.Storage.Provider;
56

6-
using ITHit.FileSystem.Windows.ShellExtension.ComInfrastructure;
7-
8-
97
namespace VirtualDrive.ShellExtension
108
{
119
class Program

Windows/VirtualDrive/VirtualDrive.ShellExtension/VirtualDrive.ShellExtension.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
2020
</ItemGroup>
2121
<ItemGroup>
22-
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="5.6.16274.0-Beta2" />
22+
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="5.6.16382.0" />
2323
</ItemGroup>
2424
<ItemGroup>
2525
<None Update="log4net.config">

0 commit comments

Comments
 (0)