|
| 1 | +// Copyright (c) Files Community |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using Windows.Win32.Foundation; |
| 5 | +using Windows.Win32.UI.Shell; |
| 6 | + |
| 7 | +namespace Files.App.Storage.Storables |
| 8 | +{ |
| 9 | + public sealed partial class WindowsBulkOperations : IDisposable |
| 10 | + { |
| 11 | + private unsafe partial struct WindowsBulkOperationsSink : IFileOperationProgressSink.Interface |
| 12 | + { |
| 13 | + public HRESULT StartOperations() |
| 14 | + { |
| 15 | + return HRESULT.S_OK; |
| 16 | + } |
| 17 | + |
| 18 | + public HRESULT FinishOperations(HRESULT hrResult) |
| 19 | + { |
| 20 | + return HRESULT.S_OK; |
| 21 | + } |
| 22 | + |
| 23 | + public unsafe HRESULT PreRenameItem(uint dwFlags, IShellItem* psiItem, PCWSTR pszNewName) |
| 24 | + { |
| 25 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 26 | + { |
| 27 | + operations.ItemRenaming?.Invoke(operations, new()); |
| 28 | + return HRESULT.S_OK; |
| 29 | + } |
| 30 | + |
| 31 | + return HRESULT.E_INVALIDARG; |
| 32 | + } |
| 33 | + |
| 34 | + public unsafe HRESULT PostRenameItem(uint dwFlags, IShellItem* psiItem, PCWSTR pszNewName, HRESULT hrRename, IShellItem* psiNewlyCreated) |
| 35 | + { |
| 36 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 37 | + { |
| 38 | + operations.ItemRenamed?.Invoke(operations, new()); |
| 39 | + return HRESULT.S_OK; |
| 40 | + } |
| 41 | + |
| 42 | + return HRESULT.E_INVALIDARG; |
| 43 | + } |
| 44 | + |
| 45 | + public unsafe HRESULT PreMoveItem(uint dwFlags, IShellItem* psiItem, IShellItem* psiDestinationFolder, PCWSTR pszNewName) |
| 46 | + { |
| 47 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 48 | + { |
| 49 | + operations.ItemMoving?.Invoke(operations, new()); |
| 50 | + return HRESULT.S_OK; |
| 51 | + } |
| 52 | + |
| 53 | + return HRESULT.E_INVALIDARG; |
| 54 | + } |
| 55 | + |
| 56 | + public unsafe HRESULT PostMoveItem(uint dwFlags, IShellItem* psiItem, IShellItem* psiDestinationFolder, PCWSTR pszNewName, HRESULT hrMove, IShellItem* psiNewlyCreated) |
| 57 | + { |
| 58 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 59 | + { |
| 60 | + operations.ItemMoved?.Invoke(operations, new()); |
| 61 | + return HRESULT.S_OK; |
| 62 | + } |
| 63 | + |
| 64 | + return HRESULT.E_INVALIDARG; |
| 65 | + } |
| 66 | + |
| 67 | + public unsafe HRESULT PreCopyItem(uint dwFlags, IShellItem* psiItem, IShellItem* psiDestinationFolder, PCWSTR pszNewName) |
| 68 | + { |
| 69 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 70 | + { |
| 71 | + operations.ItemCopying?.Invoke(operations, new()); |
| 72 | + return HRESULT.S_OK; |
| 73 | + } |
| 74 | + |
| 75 | + return HRESULT.E_INVALIDARG; |
| 76 | + } |
| 77 | + |
| 78 | + public unsafe HRESULT PostCopyItem(uint dwFlags, IShellItem* psiItem, IShellItem* psiDestinationFolder, PCWSTR pszNewName, HRESULT hrCopy, IShellItem* psiNewlyCreated) |
| 79 | + { |
| 80 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 81 | + { |
| 82 | + operations.ItemCopied?.Invoke(operations, new()); |
| 83 | + return HRESULT.S_OK; |
| 84 | + } |
| 85 | + |
| 86 | + return HRESULT.E_INVALIDARG; |
| 87 | + } |
| 88 | + |
| 89 | + public unsafe HRESULT PreDeleteItem(uint dwFlags, IShellItem* psiItem) |
| 90 | + { |
| 91 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 92 | + { |
| 93 | + operations.ItemDeleting?.Invoke(operations, new()); |
| 94 | + return HRESULT.S_OK; |
| 95 | + } |
| 96 | + |
| 97 | + return HRESULT.E_INVALIDARG; |
| 98 | + } |
| 99 | + |
| 100 | + public unsafe HRESULT PostDeleteItem(uint dwFlags, IShellItem* psiItem, HRESULT hrDelete, IShellItem* psiNewlyCreated) |
| 101 | + { |
| 102 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 103 | + { |
| 104 | + operations.ItemDeleted?.Invoke(operations, new()); |
| 105 | + return HRESULT.S_OK; |
| 106 | + } |
| 107 | + |
| 108 | + return HRESULT.E_INVALIDARG; |
| 109 | + } |
| 110 | + |
| 111 | + public unsafe HRESULT PreNewItem(uint dwFlags, IShellItem* psiDestinationFolder, PCWSTR pszNewName) |
| 112 | + { |
| 113 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 114 | + { |
| 115 | + operations.ItemCreating?.Invoke(operations, new()); |
| 116 | + return HRESULT.S_OK; |
| 117 | + } |
| 118 | + |
| 119 | + return HRESULT.E_INVALIDARG; |
| 120 | + } |
| 121 | + |
| 122 | + public unsafe HRESULT PostNewItem(uint dwFlags, IShellItem* psiDestinationFolder, PCWSTR pszNewName, PCWSTR pszTemplateName, uint dwFileAttributes, HRESULT hrNew, IShellItem* psiNewItem) |
| 123 | + { |
| 124 | + if (_operationsHandle.Target is WindowsBulkOperations operations) |
| 125 | + { |
| 126 | + operations.ItemCreated?.Invoke(operations, new()); |
| 127 | + return HRESULT.S_OK; |
| 128 | + } |
| 129 | + |
| 130 | + return HRESULT.E_INVALIDARG; |
| 131 | + } |
| 132 | + |
| 133 | + public HRESULT UpdateProgress(uint iWorkTotal, uint iWorkSoFar) |
| 134 | + { |
| 135 | + return HRESULT.S_OK; |
| 136 | + } |
| 137 | + |
| 138 | + public HRESULT ResetTimer() |
| 139 | + { |
| 140 | + return HRESULT.S_OK; |
| 141 | + } |
| 142 | + |
| 143 | + public HRESULT PauseTimer() |
| 144 | + { |
| 145 | + return HRESULT.S_OK; |
| 146 | + } |
| 147 | + |
| 148 | + public HRESULT ResumeTimer() |
| 149 | + { |
| 150 | + return HRESULT.S_OK; |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | +} |
0 commit comments