/// <summary> /// Pulls multiple files/folders recursively. </summary> /// <param name="entries"> The list of entry to pull </param> /// <param name="localPath"> the localpath to a directory </param> /// <param name="fileListingService"> a FileListingService object to browse through remote directories. </param> /// <param name="monitor"> the progress monitor. Must be started already. /// </param> /// <exception cref="SyncException"> if file could not be pushed </exception> /// <exception cref="IOException"> in case of I/O error on the connection. </exception> /// <exception cref="TimeoutException"> in case of a timeout reading responses from the device. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void doPull(com.android.ddmlib.FileListingService.FileEntry[] entries, String localPath, FileListingService fileListingService, ISyncProgressMonitor monitor) throws SyncException, java.io.IOException, TimeoutException private void doPull(FileListingService.FileEntry[] entries, string localPath, FileListingService fileListingService, ISyncProgressMonitor monitor) { foreach (FileListingService.FileEntry e in entries) { // check if we're cancelled if (monitor.canceled == true) { throw new SyncException(SyncException.SyncError.CANCELED); } // get type (we only pull directory and files for now) int type = e.type; if (type == FileListingService.TYPE_DIRECTORY) { monitor.startSubTask(e.fullPath); var dest = Path.Combine(localPath, e.name); // make the directory Directory.CreateDirectory(dest); // then recursively call the content. Since we did a ls command // to get the number of files, we can use the cache FileListingService.FileEntry[] children = fileListingService.getChildren(e, true, null); doPull(children, dest, fileListingService, monitor); monitor.advance(1); } else if (type == FileListingService.TYPE_FILE) { monitor.startSubTask(e.fullPath); string dest = Path.Combine(localPath, e.name); doPullFile(e.fullPath, dest, monitor); } } }
/// <summary> /// compute the recursive file size of all the files in the list. Folder /// have a weight of 1. </summary> /// <param name="entries"> </param> /// <param name="fls"> /// @return </param> private int getTotalRemoteFileSize(FileListingService.FileEntry[] entries, FileListingService fls) { int count = 0; foreach (FileListingService.FileEntry e in entries) { int type = e.type; if (type == FileListingService.TYPE_DIRECTORY) { // get the children FileListingService.FileEntry[] children = fls.getChildren(e, false, null); count += getTotalRemoteFileSize(children, fls) + 1; } else if (type == FileListingService.TYPE_FILE) { count += e.sizeValue; } } return(count); }