@@ -50,14 +50,14 @@ public FilesystemOperations(IShellPage associatedInstance)
50
50
51
51
#region IFilesystemOperations
52
52
53
- public async Task < ( IStorageHistory , IStorageItem ) > CreateAsync ( IStorageItemWithPath source , IProgress < FileSystemStatusCode > errorCode , CancellationToken cancellationToken )
53
+ public async Task < ( IStorageHistory , IStorageItem ) > CreateAsync ( IStorageItem source , IProgress < FileSystemStatusCode > errorCode , CancellationToken cancellationToken )
54
54
{
55
55
IStorageItem item = null ;
56
56
try
57
57
{
58
- switch ( source . ItemType )
58
+ switch ( source )
59
59
{
60
- case FilesystemItemType . File :
60
+ case IStorageFile :
61
61
{
62
62
var newEntryInfo = await RegistryHelper . GetNewContextMenuEntryForType ( Path . GetExtension ( source . Path ) ) ;
63
63
if ( newEntryInfo == null )
@@ -73,20 +73,14 @@ public FilesystemOperations(IShellPage associatedInstance)
73
73
break ;
74
74
}
75
75
76
- case FilesystemItemType . Directory :
76
+ case IStorageFolder :
77
77
{
78
78
StorageFolder folder = await associatedInstance . FilesystemViewModel . GetFolderFromPathAsync ( Path . GetDirectoryName ( source . Path ) ) ;
79
79
item = await folder . CreateFolderAsync ( Path . GetFileName ( source . Path ) ) ;
80
80
81
81
break ;
82
82
}
83
83
84
- case FilesystemItemType . Symlink :
85
- {
86
- Debugger . Break ( ) ;
87
- throw new NotImplementedException ( ) ;
88
- }
89
-
90
84
default :
91
85
Debugger . Break ( ) ;
92
86
break ;
@@ -108,21 +102,6 @@ public async Task<IStorageHistory> CopyAsync(IStorageItem source,
108
102
IProgress < float > progress ,
109
103
IProgress < FileSystemStatusCode > errorCode ,
110
104
CancellationToken cancellationToken )
111
- {
112
- return await CopyAsync ( source . FromStorageItem ( ) ,
113
- destination ,
114
- collision ,
115
- progress ,
116
- errorCode ,
117
- cancellationToken ) ;
118
- }
119
-
120
- public async Task < IStorageHistory > CopyAsync ( IStorageItemWithPath source ,
121
- string destination ,
122
- NameCollisionOption collision ,
123
- IProgress < float > progress ,
124
- IProgress < FileSystemStatusCode > errorCode ,
125
- CancellationToken cancellationToken )
126
105
{
127
106
if ( destination . StartsWith ( App . AppSettings . RecycleBinPath ) )
128
107
{
@@ -139,7 +118,7 @@ await DialogDisplayHelper.ShowDialogAsync(
139
118
IStorageItem copiedItem = null ;
140
119
//long itemSize = await FilesystemHelpers.GetItemSize(await source.ToStorageItem(associatedInstance));
141
120
142
- if ( source . ItemType == FilesystemItemType . Directory )
121
+ if ( source is IStorageFolder )
143
122
{
144
123
if ( ! string . IsNullOrWhiteSpace ( source . Path ) &&
145
124
Path . GetDirectoryName ( destination ) . IsSubPathOf ( source . Path ) ) // We check if user tried to copy anything above the source.ItemPath
@@ -216,7 +195,7 @@ await DialogDisplayHelper.ShowDialogAsync(
216
195
}
217
196
}
218
197
}
219
- else if ( source . ItemType == FilesystemItemType . File )
198
+ else if ( source is IStorageFile )
220
199
{
221
200
var fsResult = ( FilesystemResult ) await Task . Run ( ( ) => NativeFileOperationsHelper . CopyFileFromApp ( source . Path , destination , true ) ) ;
222
201
@@ -291,9 +270,7 @@ await Windows.ApplicationModel.Core.CoreApplication.MainView.DispatcherQueue.Enq
291
270
return null ; // Cannot undo overwrite operation
292
271
}
293
272
294
- var pathWithType = copiedItem . FromStorageItem ( destination , source . ItemType ) ;
295
-
296
- return new StorageHistory ( FileOperationType . Copy , source , pathWithType ) ;
273
+ return new StorageHistory ( FileOperationType . Copy , source , copiedItem ) ;
297
274
}
298
275
299
276
public async Task < IStorageHistory > MoveAsync ( IStorageItem source ,
@@ -302,21 +279,6 @@ public async Task<IStorageHistory> MoveAsync(IStorageItem source,
302
279
IProgress < float > progress ,
303
280
IProgress < FileSystemStatusCode > errorCode ,
304
281
CancellationToken cancellationToken )
305
- {
306
- return await MoveAsync ( source . FromStorageItem ( ) ,
307
- destination ,
308
- collision ,
309
- progress ,
310
- errorCode ,
311
- cancellationToken ) ;
312
- }
313
-
314
- public async Task < IStorageHistory > MoveAsync ( IStorageItemWithPath source ,
315
- string destination ,
316
- NameCollisionOption collision ,
317
- IProgress < float > progress ,
318
- IProgress < FileSystemStatusCode > errorCode ,
319
- CancellationToken cancellationToken )
320
282
{
321
283
if ( source . Path == destination )
322
284
{
@@ -348,7 +310,7 @@ await DialogDisplayHelper.ShowDialogAsync(
348
310
IStorageItem movedItem = null ;
349
311
//long itemSize = await FilesystemHelpers.GetItemSize(await source.ToStorageItem(associatedInstance));
350
312
351
- if ( source . ItemType == FilesystemItemType . Directory )
313
+ if ( source is IStorageFolder )
352
314
{
353
315
if ( ! string . IsNullOrWhiteSpace ( source . Path ) &&
354
316
Path . GetDirectoryName ( destination ) . IsSubPathOf ( source . Path ) ) // We check if user tried to move anything above the source.ItemPath
@@ -427,7 +389,7 @@ await DialogDisplayHelper.ShowDialogAsync(
427
389
errorCode ? . Report ( fsResult . ErrorCode ) ;
428
390
}
429
391
}
430
- else if ( source . ItemType == FilesystemItemType . File )
392
+ else if ( source is IStorageFile )
431
393
{
432
394
var fsResult = ( FilesystemResult ) await Task . Run ( ( ) => NativeFileOperationsHelper . MoveFileFromApp ( source . Path , destination ) ) ;
433
395
@@ -496,29 +458,14 @@ await Windows.ApplicationModel.Core.CoreApplication.MainView.DispatcherQueue.Enq
496
458
return null ; // Cannot undo overwrite operation
497
459
}
498
460
499
- var pathWithType = movedItem . FromStorageItem ( destination , source . ItemType ) ;
500
-
501
- return new StorageHistory ( FileOperationType . Move , source , pathWithType ) ;
461
+ return new StorageHistory ( FileOperationType . Move , source , movedItem ) ;
502
462
}
503
463
504
464
public async Task < IStorageHistory > DeleteAsync ( IStorageItem source ,
505
465
IProgress < float > progress ,
506
466
IProgress < FileSystemStatusCode > errorCode ,
507
467
bool permanently ,
508
468
CancellationToken cancellationToken )
509
- {
510
- return await DeleteAsync ( source . FromStorageItem ( ) ,
511
- progress ,
512
- errorCode ,
513
- permanently ,
514
- cancellationToken ) ;
515
- }
516
-
517
- public async Task < IStorageHistory > DeleteAsync ( IStorageItemWithPath source ,
518
- IProgress < float > progress ,
519
- IProgress < FileSystemStatusCode > errorCode ,
520
- bool permanently ,
521
- CancellationToken cancellationToken )
522
469
{
523
470
bool deleteFromRecycleBin = recycleBinHelpers . IsPathUnderRecycleBin ( source . Path ) ;
524
471
@@ -533,12 +480,12 @@ public async Task<IStorageHistory> DeleteAsync(IStorageItemWithPath source,
533
480
}
534
481
if ( ! fsResult )
535
482
{
536
- if ( source . ItemType == FilesystemItemType . File )
483
+ if ( source is IStorageFile )
537
484
{
538
485
fsResult = await associatedInstance . FilesystemViewModel . GetFileFromPathAsync ( source . Path )
539
486
. OnSuccess ( ( t ) => t . DeleteAsync ( permanently ? StorageDeleteOption . PermanentDelete : StorageDeleteOption . Default ) . AsTask ( ) ) ;
540
487
}
541
- else if ( source . ItemType == FilesystemItemType . Directory )
488
+ else if ( source is IStorageFolder )
542
489
{
543
490
fsResult = await associatedInstance . FilesystemViewModel . GetFolderFromPathAsync ( source . Path )
544
491
. OnSuccess ( ( t ) => t . DeleteAsync ( permanently ? StorageDeleteOption . PermanentDelete : StorageDeleteOption . Default ) . AsTask ( ) ) ;
@@ -631,15 +578,6 @@ public async Task<IStorageHistory> RenameAsync(IStorageItem source,
631
578
NameCollisionOption collision ,
632
579
IProgress < FileSystemStatusCode > errorCode ,
633
580
CancellationToken cancellationToken )
634
- {
635
- return await RenameAsync ( StorageItemHelpers . FromStorageItem ( source ) , newName , collision , errorCode , cancellationToken ) ;
636
- }
637
-
638
- public async Task < IStorageHistory > RenameAsync ( IStorageItemWithPath source ,
639
- string newName ,
640
- NameCollisionOption collision ,
641
- IProgress < FileSystemStatusCode > errorCode ,
642
- CancellationToken cancellationToken )
643
581
{
644
582
if ( Path . GetFileName ( source . Path ) == newName && collision == NameCollisionOption . FailIfExists )
645
583
{
@@ -668,7 +606,7 @@ public async Task<IStorageHistory> RenameAsync(IStorageItemWithPath source,
668
606
if ( renamed )
669
607
{
670
608
errorCode ? . Report ( FileSystemStatusCode . Success ) ;
671
- return new StorageHistory ( FileOperationType . Rename , source , renamed . Result . FromStorageItem ( ) ) ;
609
+ return new StorageHistory ( FileOperationType . Rename , source . CreateEnumerable ( ) , renamed . Result . FromStorageItem ( ) ) ;
672
610
}
673
611
else if ( renamed == FileSystemStatusCode . Unauthorized )
674
612
{
@@ -747,7 +685,7 @@ public async Task<IStorageHistory> RenameAsync(IStorageItemWithPath source,
747
685
return null ;
748
686
}
749
687
750
- public async Task < IStorageHistory > RestoreFromTrashAsync ( IStorageItemWithPath source ,
688
+ public async Task < IStorageHistory > RestoreFromTrashAsync ( IStorageItem source ,
751
689
string destination ,
752
690
IProgress < float > progress ,
753
691
IProgress < FileSystemStatusCode > errorCode ,
@@ -760,7 +698,7 @@ public async Task<IStorageHistory> RestoreFromTrashAsync(IStorageItemWithPath so
760
698
761
699
if ( ! fsResult )
762
700
{
763
- if ( source . ItemType == FilesystemItemType . Directory )
701
+ if ( source is IStorageFolder )
764
702
{
765
703
FilesystemResult < StorageFolder > sourceFolder = await associatedInstance . FilesystemViewModel . GetFolderFromPathAsync ( source . Path ) ;
766
704
FilesystemResult < StorageFolder > destinationFolder = await associatedInstance . FilesystemViewModel . GetFolderFromPathAsync ( Path . GetDirectoryName ( destination ) ) ;
@@ -953,12 +891,7 @@ public async Task<IStorageHistory> CopyItemsAsync(IEnumerable<IStorageItemWithPa
953
891
return null ;
954
892
}
955
893
956
- public async Task < IStorageHistory > MoveItemsAsync ( IEnumerable < IStorageItem > source , IEnumerable < string > destination , IEnumerable < FileNameConflictResolveOptionType > collisions , IProgress < float > progress , IProgress < FileSystemStatusCode > errorCode , CancellationToken cancellationToken )
957
- {
958
- return await MoveItemsAsync ( source . Select ( ( item ) => item . FromStorageItem ( ) ) . ToList ( ) , destination , collisions , progress , errorCode , cancellationToken ) ;
959
- }
960
-
961
- public async Task < IStorageHistory > MoveItemsAsync ( IEnumerable < IStorageItemWithPath > source , IEnumerable < string > destination , IEnumerable < FileNameConflictResolveOptionType > collisions , IProgress < float > progress , IProgress < FileSystemStatusCode > errorCode , CancellationToken token )
894
+ public async Task < IStorageHistory > MoveItemsAsync ( IEnumerable < IStorageItem > source , IEnumerable < string > destination , IEnumerable < FileNameConflictResolveOptionType > collisions , IProgress < float > progress , IProgress < FileSystemStatusCode > errorCode , CancellationToken token )
962
895
{
963
896
var rawStorageHistory = new List < IStorageHistory > ( ) ;
964
897
@@ -993,12 +926,7 @@ public async Task<IStorageHistory> MoveItemsAsync(IEnumerable<IStorageItemWithPa
993
926
return null ;
994
927
}
995
928
996
- public async Task < IStorageHistory > DeleteItemsAsync ( IEnumerable < IStorageItem > source , IProgress < float > progress , IProgress < FileSystemStatusCode > errorCode , bool permanently , CancellationToken cancellationToken )
997
- {
998
- return await DeleteItemsAsync ( source . Select ( ( item ) => item . FromStorageItem ( ) ) , progress , errorCode , permanently , cancellationToken ) ;
999
- }
1000
-
1001
- public async Task < IStorageHistory > DeleteItemsAsync ( IEnumerable < IStorageItemWithPath > source , IProgress < float > progress , IProgress < FileSystemStatusCode > errorCode , bool permanently , CancellationToken token )
929
+ public async Task < IStorageHistory > DeleteItemsAsync ( IEnumerable < IStorageItem > source , IProgress < float > progress , IProgress < FileSystemStatusCode > errorCode , bool permanently , CancellationToken token )
1002
930
{
1003
931
bool originalPermanently = permanently ;
1004
932
var rawStorageHistory = new List < IStorageHistory > ( ) ;
0 commit comments