//}}HDN================================================== ///// <summary> ///// Extracts The PDB Guid From The Provided PE File, And Saves It To The Target Path ///// </summary> ///// <param name="targetPath">Location To Save The PDB Found.</param> ///// <returns></returns> //public bool DownloadPDBFromServer(string targetPath) //{ // bool allOk = false; // try // { // targetPath = Utility.CleanupPath(targetPath); // if (!System.IO.Directory.Exists(targetPath)) // { // System.IO.Directory.CreateDirectory(targetPath); // } // PDBWebClient pdbDownloader = GetWebClientWithCookie(); // string targetFile = this.PdbFileName; // targetFile = String.Format("{0}{1}/{2}/{3}", // this.SymbolServerUrl, targetFile, this.PdbVersion, targetFile.Replace(".pdb", ".pd_")); // string compressedFileName = targetPath + this.PdbFileName.Replace(".pdb", ".pd_"); // System.Diagnostics.Debug.WriteLine("Pdb Location For Retrieval:" + targetFile); // if (pdbDownloader.DownloadFileWithProgress(targetFile, compressedFileName)) { // if (Decompressor.ExpandSourceFileToTarget(compressedFileName, targetPath, this.PdbFileName)) // { // allOk = true; // } // } // if (this.CleanupTempCompressedSymbols) { // if (File.Exists( compressedFileName )) { // File.Delete( compressedFileName ); // } // } // } // catch (Exception ex) // { // System.Diagnostics.Debug.Write(ex.Message + "targetPath download failed"); // throw; // } // return allOk; //} public bool DownloadPDBFromServer(string targetPath) { bool allOk = false; try { targetPath = Utility.CleanupPath(targetPath); if (!System.IO.Directory.Exists(targetPath)) { System.IO.Directory.CreateDirectory(targetPath); } PDBWebClient pdbDownloader = GetWebClientWithCookie(); string targetFile = this.PdbFileName; if (FrameworkVersionData.RelevantVersionData.SPLevel == 0) { targetFile = String.Format("{0}{1}/{2}/{3}", this.SymbolServerUrl, targetFile, this.PdbVersion, targetFile.Replace(".pdb", ".pd_")); string compressedFileName = targetPath + this.PdbFileName.Replace(".pdb", ".pd_"); System.Diagnostics.Debug.WriteLine("Pdb Location For Retrieval:" + targetFile); if (pdbDownloader.DownloadFileWithProgress(targetFile, compressedFileName)) { if (Decompressor.ExpandSourceFileToTarget(compressedFileName, targetPath, this.PdbFileName)) { allOk = true; } } if (this.CleanupTempCompressedSymbols) { if (File.Exists(compressedFileName)) { File.Delete(compressedFileName); } } } else { targetFile = String.Format("{0}{1}/{2}/{3}", this.SymbolServerUrl, targetFile, this.PdbVersion, targetFile); string compressedFileName = targetPath + this.PdbFileName; if (pdbDownloader.DownloadFileWithProgress(targetFile, compressedFileName)) { allOk = true; } } } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.Message + "targetPath download failed"); throw; } return(allOk); }
public static PDBWebClient GetWebClientWithCookie(Match ProxyMatch) { PDBWebClient specialWebClient = (ProxyMatch != null? new PDBWebClient(ProxyMatch.Groups["proxyAddress"].Value, ProxyMatch.Groups["username"].Value, ProxyMatch.Groups["password"].Value, (ProxyMatch.Groups["domain"] != null?ProxyMatch.Groups["domain"].Value:String.Empty)):new PDBWebClient()); AddHeadersIfNecessary(specialWebClient); return(specialWebClient); }
public bool DownloadWholeFiles(string targetPath) { List <SrcSrvDownloadAbleFile> pdbResults = RetrieveFileRelationsExtended(targetPath); List <SrcSrvDownloadAbleFile> .Enumerator tempEnum = pdbResults.GetEnumerator(); int i = 1; while (tempEnum.MoveNext()) { PDBWebClient tempClient = GetWebClientWithCookie(); string directoryName = String.Empty; try { if (UseSourceFilePath) { directoryName = System.IO.Path.GetDirectoryName(tempEnum.Current.LocalFileTargetAlternative); } else { directoryName = System.IO.Path.GetDirectoryName(tempEnum.Current.LocalFileTarget); } DirectoryInfo createdDirectory = null; if (!System.IO.Directory.Exists(directoryName)) { createdDirectory = Directory.CreateDirectory(directoryName); } else { createdDirectory = new DirectoryInfo(directoryName); } //{{HDN================================================== DownloadFileEventArgs args = new DownloadFileEventArgs(); args.TargetFilePath = UseSourceFilePath ? tempEnum.Current.LocalFileTargetAlternative : tempEnum.Current.LocalFileTarget; if (_skipExistingSourceFiles) { if (File.Exists(args.TargetFilePath) || Path.GetExtension(args.TargetFilePath) == ".h") { continue; } } OnBeginDownloadSourceFile(this, args); byte[] downloadedData = new byte[] {}; bool downloadOk = tempClient.DownloadDataWithProgress( tempEnum.Current.UrlToBeRequested, out downloadedData); if (!downloadOk) { createdDirectory.Delete(true); continue; } //}}HDN================================================== EulaRequestEvent eulaEventArg = null; if (tempClient.IsEulaResponse) { eulaEventArg = new EulaRequestEvent(new EulaContents(tempClient.EulaBody)); OnEulaAcceptRequested(eulaEventArg); if (!eulaEventArg.EulaAccepted) { throw new EulaNotAcceptedException(); } else { //{{HDN================================================== OnDownloadSourceFileAfterEulaAccepted(this, args); downloadOk = tempClient.DownloadDataWithProgress( tempEnum.Current.UrlToBeRequested + "?" + eulaEventArg.EulaContent.AcceptCmdKey, out downloadedData); if (!downloadOk) { continue; } //}}HDN================================================== } } if (UseSourceFilePath) { System.IO.File.WriteAllBytes(tempEnum.Current.LocalFileTargetAlternative, downloadedData); if (tempClient.HasLastFileWriteTimeOnServer) { File.SetLastAccessTimeUtc(tempEnum.Current.LocalFileTargetAlternative, tempClient.LastFileWriteTimeOnServer); } } else { System.IO.File.WriteAllBytes(tempEnum.Current.LocalFileTarget, downloadedData); if (tempClient.HasLastFileWriteTimeOnServer) { File.SetLastAccessTimeUtc(tempEnum.Current.LocalFileTarget, tempClient.LastFileWriteTimeOnServer); } } OnSourceFileDownloaded(new SourceFileLoadEventArg((UseSourceFilePath?tempEnum.Current.LocalFileTargetAlternative:tempEnum.Current.LocalFileTarget), tempEnum.Current.UrlToBeRequested, i.ToString() + "/" + pdbResults.Count)); } catch (Exception ex) { if (ex is EulaNotAcceptedException) { throw; } OnSourceFileDownloaded(new SourceFileLoadEventArg((UseSourceFilePath ? tempEnum.Current.LocalFileTargetAlternative : tempEnum.Current.LocalFileTarget), tempEnum.Current.LocalFileTarget, i.ToString() + "/" + pdbResults.Count, ex)); } i++; } return(true); }