public EcmaModule GetModuleForSimpleName(string simpleName, bool throwIfNotFound = true) { ModuleData existing; if (_simpleNameHashtable.TryGetValue(simpleName, out existing)) { return(existing.Module); } string filePath; if (!InputFilePaths.TryGetValue(simpleName, out filePath)) { if (!ReferenceFilePaths.TryGetValue(simpleName, out filePath)) { // TODO: the exception is wrong for two reasons: for one, this should be assembly full name, not simple name. // The other reason is that on CoreCLR, the exception also captures the reason. We should be passing two // string IDs. This makes this rather annoying. if (throwIfNotFound) { throw new TypeSystemException.FileNotFoundException(ExceptionStringID.FileLoadErrorGeneric, simpleName); } return(null); } } return(AddModule(filePath, simpleName)); }
public EcmaModule GetModuleForSimpleName(string simpleName, bool throwIfNotFound = true) { ModuleData existing; if (_simpleNameHashtable.TryGetValue(simpleName, out existing)) { return(existing.Module); } string filePath; if (!InputFilePaths.TryGetValue(simpleName, out filePath)) { if (!ReferenceFilePaths.TryGetValue(simpleName, out filePath)) { if (throwIfNotFound) { throw new FileNotFoundException("Assembly not found: " + simpleName); } return(null); } } return(AddModule(filePath, simpleName)); }
public ModuleDesc GetModuleForSimpleName(string simpleName, bool throwIfNotFound = true) { ModuleData existing; if (_simpleNameHashtable.TryGetValue(simpleName, out existing)) { return(existing.Module); } string filePath; if (!InputFilePaths.TryGetValue(simpleName, out filePath)) { if (!ReferenceFilePaths.TryGetValue(simpleName, out filePath)) { // We allow the CanonTypesModule to not be an EcmaModule. if (((IAssemblyDesc)CanonTypesModule).GetName().Name == simpleName) { return(CanonTypesModule); } // TODO: the exception is wrong for two reasons: for one, this should be assembly full name, not simple name. // The other reason is that on CoreCLR, the exception also captures the reason. We should be passing two // string IDs. This makes this rather annoying. if (throwIfNotFound) { ThrowHelper.ThrowFileNotFoundException(ExceptionStringID.FileLoadErrorGeneric, simpleName); } return(null); } } return(AddModule(filePath, simpleName, true)); }
private EcmaModule CreateModuleForSimpleName(string simpleName) { string filePath; if (!InputFilePaths.TryGetValue(simpleName, out filePath)) { if (!ReferenceFilePaths.TryGetValue(simpleName, out filePath)) { throw new CommandLineException("Assembly not found: " + simpleName); } } PEReader peReader = new PEReader(File.OpenRead(filePath)); EcmaModule module = EcmaModule.Create(this, peReader); MetadataReader metadataReader = module.MetadataReader; string actualSimpleName = metadataReader.GetString(metadataReader.GetAssemblyDefinition().Name); if (!actualSimpleName.Equals(simpleName, StringComparison.OrdinalIgnoreCase)) { throw new CommandLineException("Assembly name does not match filename " + filePath); } _modules.Add(simpleName, module); ModuleData moduleData = new ModuleData() { Path = filePath }; _moduleData.Add(module, moduleData); return(module); }
public EcmaModule GetModuleForSimpleName(string simpleName) { EcmaModule existingModule; if (_modules.TryGetValue(simpleName, out existingModule)) { return(existingModule); } string filePath; if (!InputFilePaths.TryGetValue(simpleName, out filePath)) { if (!ReferenceFilePaths.TryGetValue(simpleName, out filePath)) { throw new FileNotFoundException("Assembly not found: " + simpleName); } } EcmaModule module = new EcmaModule(this, new PEReader(File.OpenRead(filePath))); MetadataReader metadataReader = module.MetadataReader; string actualSimpleName = metadataReader.GetString(metadataReader.GetAssemblyDefinition().Name); if (!actualSimpleName.Equals(simpleName, StringComparison.OrdinalIgnoreCase)) { throw new FileNotFoundException("Assembly name does not match filename " + filePath); } AddModule(simpleName, filePath, module); return(module); }
private void OnExtractionFinished(object sender, EventArgs e) { SevenZipExtractor extractor = sender as SevenZipExtractor; InputFilePaths.AddRange(extractor.VolumeFileNames); // *.r01, *.r02, which will be deleted in clean up if (OverallProgress == 100) { SingleFileUnpackProgress = 0; OverallProgress = 0; CurrentProgressDescription = "Success!"; OnUnpackFinished(true); CleanUp(); } }
private void DoFindFiles(bool recursive, bool usePatterns = false) { Properties.Settings.Default.RootFolder = exportFolder.Text.Trim(); Properties.Settings.Default.Save(); fileList.Items.Clear(); StartSession(); if (!Directory.Exists(FolderPath)) { AddMessage("Folder doesn't exist. Aborting."); return; } InputFilePaths = Directory.GetFiles( FolderPath, "*.html", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly ) .Where(f => !f.Contains(_processedFolderName)) .ToList(); if (!InputFilePaths.Any()) { AddMessage($"No html files found at \"{FolderPath}\". Aborting."); return; } var prefix = $"{FolderPath}\\"; var files = InputFilePaths .Select(f => f.Replace(prefix, string.Empty)) .ToList(); InputFilePaths.ForEach(f => { var flavour = GetFileFlavour(f).ToString(); var suffix = f.Replace(prefix, string.Empty); fileList.Items.Add($"[{flavour}] {suffix}"); }); var nextButtonName = runAutomatedButton.Text; AddMessage($"Files found. Please press the '{nextButtonName}' button."); }
protected override void Execute(NativeActivityContext context) { var todayDate = DateTime.UtcNow.Date; var in_FilePaths = InputFilePaths.Get(context); var in_DestPath = DestinationPath.Get(context); // var fileName = ""; var in_ZipFolderName = ZipFolderName.Get(context); if (in_ZipFolderName.Equals("")) { in_ZipFolderName = todayDate.ToString("dd.MM.yyyy") + "_CompressFile"; } Directory.CreateDirectory(in_DestPath + "\\" + "TempFile"); var patharray = in_FilePaths.Split(','); CopyFolderFile(patharray, in_DestPath + "\\TempFile"); /* * foreach(string file in patharray) * { * * fileName = Path.GetFileName(file); * * FileAttributes fa = File.GetAttributes(file); * * if ((fa & FileAttributes.Directory) == FileAttributes.Directory) { * * * } * * File.Copy(file, in_DestPath + "\\" + "TempFile\\" +fileName,true); * * } */ ZipFile.CreateFromDirectory(in_DestPath + "\\" + "TempFile", in_DestPath + "\\" + in_ZipFolderName + ".zip"); Directory.Delete(in_DestPath + "\\" + "TempFile", true); }
protected override void UnpackImpl() { var firstFile = InputFilePaths.FirstOrDefault(); //*.rar or *.r01 if (firstFile == null) { return; } try { var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll"); SevenZip.SevenZipBase.SetLibraryPath(path); int index = PasswordIndex; SevenZipExtractor extractor; if (index == -1) { extractor = new SevenZipExtractor(firstFile); } else { var password = Properties.Settings.Default.ArchivePasswords[index]; extractor = new SevenZipExtractor(firstFile, password); } extractor.FileExtractionStarted += OnFileExtractionStarted; extractor.Extracting += OnExtracting; extractor.FileExtractionFinished += OnFileExtractionFinished; extractor.ExtractionFinished += OnExtractionFinished; extractor.BeginExtractArchive(TargetExtractionFolder); } catch (Exception ex) { CurrentProgressDescription = ex.Message; } }
protected override void UnpackImpl() { var firstFile = InputFilePaths.FirstOrDefault(); //*.rar or *.r01 if (firstFile == null) { return; } //Path.GetDirectoryName(firstFile) ; var options = new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }; using (var archive = ArchiveFactory.Open(firstFile)) { if (archive is RarArchive) { RarArchive rar = archive as RarArchive; if (rar.IsMultipartVolume() && !rar.IsFirstVolume()) { var path = rar.Volumes.FirstOrDefault(); CurrentProgressDescription = "Please Unpack from the 1st volume"; OnUnpackFinished(false); return; } } else //Zip or 7z { } if (!archive.IsComplete) { CurrentProgressDescription = "Incomplete files: some files are missing."; OnUnpackFinished(false); return; } bytesUnpacked = 0; archive.EntryExtractionBegin += OnEntryExtractionBegin; archive.EntryExtractionEnd += OnEntryExtractionEnd; archive.CompressedBytesRead += OnBytesRead; bool bSingleChildFolderExists = CheckSingleSubFolderExists(archive); if (bSingleChildFolderExists) { single_child_folder_to_unpack_to = Path.Combine(TargetExtractionFolder, single_child_folder_to_unpack_to); } bool bShouldExtractHere = bSingleChildFolderExists || archive.Entries.Count() == 1; if (!bShouldExtractHere) { TargetExtractionFolder = Path.Combine(TargetExtractionFolder, Title); } foreach (var entry in archive.Entries) { if (!entry.IsDirectory) { entry.WriteToDirectory(TargetExtractionFolder, options); } } } }