@@ -60,7 +60,7 @@ public int PackFileSet(IEnumerable<IFileToAddInCab> filesToPackIn) {
6060 var fileRelativePath = fileToAddInCab . RelativePathInCab . NormalizeRelativePath ( ) ;
6161 cfCabinet . AddExternalFile ( fileToAddInCab . SourcePath , fileRelativePath ) ;
6262 nbFilesProcessed ++ ;
63- OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewCompletedFile ( cabGroupedFiles . Key , fileToAddInCab . RelativePathInCab ) ) ;
63+ OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewProcessedFile ( cabGroupedFiles . Key , fileRelativePath ) ) ;
6464 }
6565 cfCabinet . Save ( _compressionType ) ;
6666 } finally {
@@ -115,7 +115,7 @@ public int ExtractFileSet(IEnumerable<IFileInCabToExtract> filesToExtract) {
115115 var fileRelativePath = fileInCabToExtract . RelativePathInCab . NormalizeRelativePath ( ) ;
116116 if ( cfCabinet . ExtractToFile ( fileRelativePath , fileInCabToExtract . ExtractionPath ) ) {
117117 nbFilesProcessed ++ ;
118- OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewCompletedFile ( cabGroupedFiles . Key , fileInCabToExtract . RelativePathInCab ) ) ;
118+ OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewProcessedFile ( cabGroupedFiles . Key , fileRelativePath ) ) ;
119119 }
120120 }
121121 } finally {
@@ -147,7 +147,7 @@ public int DeleteFileSet(IEnumerable<IFileInCabToDelete> filesToDeleteIn) {
147147 var fileRelativePath = fileToAddInCab . RelativePathInCab . NormalizeRelativePath ( ) ;
148148 if ( cfCabinet . DeleteFile ( fileRelativePath ) ) {
149149 nbFilesProcessed ++ ;
150- OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewCompletedFile ( cabGroupedFiles . Key , fileToAddInCab . RelativePathInCab ) ) ;
150+ OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewProcessedFile ( cabGroupedFiles . Key , fileRelativePath ) ) ;
151151 }
152152 }
153153 cfCabinet . Save ( _compressionType ) ;
@@ -164,7 +164,40 @@ public int DeleteFileSet(IEnumerable<IFileInCabToDelete> filesToDeleteIn) {
164164 }
165165 return nbFilesProcessed ;
166166 }
167-
167+
168+ /// <inheritdoc cref="ICabManager.MoveFileSet"/>
169+ public int MoveFileSet ( IEnumerable < IFileInCabToMove > filesToMove ) {
170+ int nbFilesProcessed = 0 ;
171+ foreach ( var cabGroupedFiles in filesToMove . GroupBy ( f => f . CabPath ) ) {
172+ if ( ! File . Exists ( cabGroupedFiles . Key ) ) {
173+ continue ;
174+ }
175+ try {
176+ using ( var cfCabinet = new CfCabinet ( cabGroupedFiles . Key , _cancelToken ) ) {
177+ cfCabinet . OnProgress += OnProgressionEvent ;
178+ try {
179+ foreach ( var fileToAddInCab in cabGroupedFiles ) {
180+ var fileRelativePath = fileToAddInCab . RelativePathInCab . NormalizeRelativePath ( ) ;
181+ if ( cfCabinet . MoveFile ( fileRelativePath , fileToAddInCab . NewRelativePathInCab . NormalizeRelativePath ( ) ) ) {
182+ nbFilesProcessed ++ ;
183+ OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewProcessedFile ( cabGroupedFiles . Key , fileRelativePath ) ) ;
184+ }
185+ }
186+ cfCabinet . Save ( _compressionType ) ;
187+ } finally {
188+ cfCabinet . OnProgress -= OnProgressionEvent ;
189+ }
190+ }
191+ } catch ( OperationCanceledException ) {
192+ throw ;
193+ } catch ( Exception e ) {
194+ throw new CabException ( $ "Failed to move files from { cabGroupedFiles . Key } .", e ) ;
195+ }
196+ OnProgress ? . Invoke ( this , CabProgressionEventArgs . NewCompletedCabinet ( cabGroupedFiles . Key ) ) ;
197+ }
198+ return nbFilesProcessed ;
199+ }
200+
168201 /// <summary>
169202 /// Returns a string representation of a given cabinet file.
170203 /// </summary>
0 commit comments