Skip to content

Commit b80f684

Browse files
committed
- Browse zip archives as folders
- Add files to zip by drag & drop - Delete from zip - Open FTP files with double click - Search and navigation bar suggestions in FTP folders - Copy folders to/from FTP - Preview files in zip and ftp folders - Simplified FilesystemOperations
1 parent 2e6c2a1 commit b80f684

File tree

61 files changed

+3696
-660
lines changed

Some content is hidden

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

61 files changed

+3696
-660
lines changed

Files.Launcher/MessageHandlers/FileOperationsHandler.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ await Win32API.StartSTATask(() =>
158158
shellOperationResult.Items.Add(new ShellOperationItemResult()
159159
{
160160
Succeeded = e.Result.Succeeded,
161-
Source = e.SourceItem.FileSystemPath,
161+
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
162162
Destination = e.DestItem?.FileSystemPath,
163163
HRresult = (int)e.Result
164164
});
@@ -224,7 +224,7 @@ await Win32API.StartSTATask(() =>
224224
shellOperationResult.Items.Add(new ShellOperationItemResult()
225225
{
226226
Succeeded = e.Result.Succeeded,
227-
Source = e.SourceItem.FileSystemPath,
227+
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
228228
Destination = !string.IsNullOrEmpty(e.Name) ? Path.Combine(Path.GetDirectoryName(e.SourceItem.FileSystemPath), e.Name) : null,
229229
HRresult = (int)e.Result
230230
});
@@ -288,8 +288,8 @@ await Win32API.StartSTATask(() =>
288288
shellOperationResult.Items.Add(new ShellOperationItemResult()
289289
{
290290
Succeeded = e.Result.Succeeded,
291-
Source = e.SourceItem.FileSystemPath,
292-
Destination = e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
291+
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
292+
Destination = e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
293293
HRresult = (int)e.Result
294294
});
295295
};
@@ -363,8 +363,8 @@ await Win32API.StartSTATask(() =>
363363
shellOperationResult.Items.Add(new ShellOperationItemResult()
364364
{
365365
Succeeded = e.Result.Succeeded,
366-
Source = e.SourceItem.FileSystemPath,
367-
Destination = e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
366+
Source = e.SourceItem.FileSystemPath ?? e.SourceItem.ParsingName,
367+
Destination = e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null,
368368
HRresult = (int)e.Result
369369
});
370370
};
@@ -554,8 +554,8 @@ private void UpdateFileTageDb(object sender, ShellFileOperations.ShellFileOpEven
554554
{
555555
"delete" => e.DestItem?.FileSystemPath,
556556
"rename" => (!string.IsNullOrEmpty(e.Name) ? Path.Combine(Path.GetDirectoryName(e.SourceItem.FileSystemPath), e.Name) : null),
557-
"copy" => (e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null),
558-
_ => (e.DestFolder != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null)
557+
"copy" => (e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null),
558+
_ => (e.DestFolder?.FileSystemPath != null && !string.IsNullOrEmpty(e.Name) ? Path.Combine(e.DestFolder.FileSystemPath, e.Name) : null)
559559
};
560560
if (destination == null)
561561
{

Files.Launcher/Program.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Files.Common;
2-
using FilesFullTrust.Helpers;
32
using FilesFullTrust.MessageHandlers;
43
using Newtonsoft.Json;
54
using System;
@@ -235,7 +234,7 @@ private static async Task ParseArgumentsAsync(Dictionary<string, object> message
235234
{
236235
await Win32API.SendMessageAsync(connection, new ValueSet() { { "Success", -1 } }, message.Get("RequestID", (string)null));
237236
}
238-
break;
237+
break;
239238

240239
default:
241240
foreach (var mh in messageHandlers)

Files/BaseLayout.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,14 @@ protected async void FileList_DragItemsStarting(object sender, DragItemsStarting
776776
{
777777
if (item.PrimaryItemAttribute == StorageItemTypes.File)
778778
{
779-
selectedStorageItems.Add(await new FtpStorageFile(ParentShellPageInstance.FilesystemViewModel, ftpItem).ToStorageFileAsync());
779+
selectedStorageItems.Add(await new FtpStorageFile(ftpItem).ToStorageFileAsync());
780+
}
781+
else if (item.PrimaryItemAttribute == StorageItemTypes.Folder)
782+
{
783+
selectedStorageItems.Add(new FtpStorageFolder(ftpItem));
780784
}
781785
}
782-
else if (item.PrimaryItemAttribute == StorageItemTypes.File)
786+
else if (item.PrimaryItemAttribute == StorageItemTypes.File || item is ZipItem)
783787
{
784788
await ParentShellPageInstance.FilesystemViewModel.GetFileFromPathAsync(item.ItemPath)
785789
.OnSuccess(t => selectedStorageItems.Add(t));

Files/DataModels/FilesystemItemsOperationDataModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task<List<FilesystemOperationItemViewModel>> ToItems(Action updateP
6666
// Add conflicting items first
6767
foreach (var item in ConflictingItems)
6868
{
69-
var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(item.SourcePath, 64u);
69+
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(item.SourcePath, 64u, Windows.Storage.FileProperties.ThumbnailMode.ListView);
7070

7171
items.Add(new FilesystemOperationItemViewModel(updatePrimaryButtonEnabled, optionGenerateNewName, optionReplaceExisting, optionSkip)
7272
{
@@ -84,7 +84,7 @@ public async Task<List<FilesystemOperationItemViewModel>> ToItems(Action updateP
8484
// Then add non-conflicting items
8585
foreach (var item in nonConflictingItems)
8686
{
87-
var iconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(item.SourcePath, 64u);
87+
var iconData = await FileThumbnailHelper.LoadIconFromPathAsync(item.SourcePath, 64u, Windows.Storage.FileProperties.ThumbnailMode.ListView);
8888

8989
items.Add(new FilesystemOperationItemViewModel(updatePrimaryButtonEnabled, optionGenerateNewName, optionReplaceExisting, optionSkip)
9090
{

Files/DataModels/ShellNewEntry.cs

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Files.Filesystem;
2+
using Files.Filesystem.StorageItems;
23
using System;
34
using System.IO;
45
using System.Threading.Tasks;
@@ -16,19 +17,19 @@ public class ShellNewEntry
1617
public byte[] Data { get; set; }
1718
public string Template { get; set; }
1819

19-
public async Task<FilesystemResult<StorageFile>> Create(string filePath, IShellPage associatedInstance)
20+
public async Task<FilesystemResult<BaseStorageFile>> Create(string filePath, IShellPage associatedInstance)
2021
{
2122
var parentFolder = await associatedInstance.FilesystemViewModel.GetFolderFromPathAsync(Path.GetDirectoryName(filePath));
2223
if (parentFolder)
2324
{
2425
return await Create(parentFolder, Path.GetFileName(filePath));
2526
}
26-
return new FilesystemResult<StorageFile>(null, parentFolder.ErrorCode);
27+
return new FilesystemResult<BaseStorageFile>(null, parentFolder.ErrorCode);
2728
}
2829

29-
public async Task<FilesystemResult<StorageFile>> Create(StorageFolder parentFolder, string fileName)
30+
public async Task<FilesystemResult<BaseStorageFile>> Create(BaseStorageFolder parentFolder, string fileName)
3031
{
31-
FilesystemResult<StorageFile> createdFile = null;
32+
FilesystemResult<BaseStorageFile> createdFile = null;
3233
if (!fileName.EndsWith(this.Extension))
3334
{
3435
fileName += this.Extension;
@@ -39,14 +40,19 @@ public async Task<FilesystemResult<StorageFile>> Create(StorageFolder parentFold
3940
}
4041
else
4142
{
42-
createdFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Template).AsTask())
43+
createdFile = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFileFromPathAsync(Template))
4344
.OnSuccess(t => t.CopyAsync(parentFolder, fileName, NameCollisionOption.GenerateUniqueName).AsTask());
4445
}
4546
if (createdFile)
4647
{
4748
if (this.Data != null)
4849
{
49-
await FileIO.WriteBytesAsync(createdFile.Result, this.Data);
50+
//await FileIO.WriteBytesAsync(createdFile.Result, this.Data); // Calls unsupported OpenTransactedWriteAsync
51+
using (var fileStream = await createdFile.Result.OpenStreamForWriteAsync())
52+
{
53+
await fileStream.WriteAsync(Data, 0, Data.Length);
54+
await fileStream.FlushAsync();
55+
}
5056
}
5157
}
5258
return createdFile;

Files/Files.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,15 @@
178178
<Compile Include="Filesystem\Permissions\FileSystemAccessRuleForUI.cs" />
179179
<Compile Include="Filesystem\Permissions\RulesForUser.cs" />
180180
<Compile Include="Filesystem\Permissions\UserGroup.cs" />
181+
<Compile Include="Filesystem\StorageItems\BaseQueryResults.cs" />
182+
<Compile Include="Filesystem\StorageItems\BaseStorageItem.cs" />
181183
<Compile Include="Filesystem\StorageItems\FtpStorageFile.cs" />
182184
<Compile Include="Filesystem\StorageItems\FtpStorageFolder.cs" />
185+
<Compile Include="Filesystem\StorageItems\StreamWithContentType.cs" />
186+
<Compile Include="Filesystem\StorageItems\SystemStorageFile.cs" />
187+
<Compile Include="Filesystem\StorageItems\SystemStorageFolder.cs" />
188+
<Compile Include="Filesystem\StorageItems\ZipStorageFile.cs" />
189+
<Compile Include="Filesystem\StorageItems\ZipStorageFolder.cs" />
183190
<Compile Include="Helpers\FtpHelpers.cs" />
184191
<Compile Include="Helpers\ItemListDisplayHelpers\GroupedCollection.cs" />
185192
<Compile Include="Helpers\ItemListDisplayHelpers\GroupingHelper.cs" />

Files/Filesystem/FileTagsHelper.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Common;
2+
using Files.Filesystem.StorageItems;
23
using Files.Helpers;
34
using Files.Models.Settings;
45
using Microsoft.Toolkit.Uwp;
@@ -49,12 +50,12 @@ public static void WriteFileTag(string filePath, string tag)
4950

5051
public static async Task<ulong?> GetFileFRN(IStorageItem item)
5152
{
52-
if (item is StorageFolder folderItem)
53+
if (item is BaseStorageFolder folderItem && folderItem.Properties != null)
5354
{
5455
var extraProperties = await folderItem.Properties.RetrievePropertiesAsync(new string[] { "System.FileFRN" });
5556
return (ulong?)extraProperties["System.FileFRN"];
5657
}
57-
else if (item is StorageFile fileItem)
58+
else if (item is BaseStorageFile fileItem && fileItem.Properties != null)
5859
{
5960
var extraProperties = await fileItem.Properties.RetrievePropertiesAsync(new string[] { "System.FileFRN" });
6061
return (ulong?)extraProperties["System.FileFRN"];

0 commit comments

Comments
 (0)