/// <summary> /// Initializes a new instance of the /// <see cref="FileSystemSizeInfoGetter" /> class. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="searchPaths">The search paths.</param> /// <param name="excludedPaths">The excluded paths.</param> /// <param name="scope">The scope.</param> /// <param name="shouldExcludeExtensions"> /// if set to <c>true</c> /// [should exclude extensions]. /// </param> /// <param name="extensions">The extensions.</param> /// <param name="minFileSize">Minimum size of the file.</param> /// <param name="maxFileSize">Maximum size of the file.</param> /// <param name="minFolderSize">Minimum size of the folder.</param> /// <param name="maxFolderSize">Maximum size of the folder.</param> /// <param name="minFolderContents"> /// The minimum folder /// contents. /// </param> /// <param name="maxFolderContents"> /// The maximum folder /// contents. /// </param> /// TODO Edit XML Comment Template for #ctor internal FileSystemSizeInfoGetter( CancellationToken cancellationToken, IEnumerable <string> searchPaths, IEnumerable <string> excludedPaths, Scope scope, bool shouldExcludeExtensions, IEnumerable <string> extensions = null, int?minFileSize = null, int?maxFileSize = null, int?minFolderSize = null, int?maxFolderSize = null, int?minFolderContents = null, int?maxFolderContents = null) { CancellationToken = cancellationToken; foreach (var searchPath in searchPaths) { CancellationToken.ThrowIfCancellationRequested(); SearchDirectories.Add(new DirectoryInfo(searchPath)); } ExcludedPaths = excludedPaths; Scope = scope; ShouldExcludeExtensions = shouldExcludeExtensions; Extensions = extensions; MinFileSize = minFileSize * BytesInMegaByte; MaxFileSize = maxFileSize * BytesInMegaByte; MinFolderSize = minFolderSize * BytesInMegaByte; MaxFolderSize = maxFolderSize * BytesInMegaByte; MinFolderContents = minFolderContents * BytesInMegaByte; MaxFolderContents = maxFolderContents * BytesInMegaByte; }
/// <summary> /// Perform GTK-specific initialization. /// </summary> partial void OSInitialize() { ////_sortColumn = RomListColumn.None; ////_sortDirection = ListSortDirection.Ascending; var configuration = SingleInstanceApplication.Instance.GetConfiguration <RomListConfiguration>(); var romListFilePath = configuration.RomFilesPath; _filePath = romListFilePath; Model = LoadRomList(romListFilePath); Model.SaveFailed += HandleSaveFailed; ((INotifyPropertyChanged)Model).PropertyChanged += HandleProgramCollectionPropertyChanged; _searchDirectories = Properties.Settings.Default.RomListSearchDirectories; if (_searchDirectories == null) { _searchDirectories = new SearchDirectories(); Properties.Settings.Default.RomListSearchDirectories = _searchDirectories; } if (Properties.Settings.Default.RomListSearchForRomsAtStartup && CanRefreshRoms(null)) { var options = RomDiscoveryOptions.AddNewRoms; if (Properties.Settings.Default.RomListValidateAtStartup) { options |= RomDiscoveryOptions.DetectChanges | RomDiscoveryOptions.DetectMissingRoms | RomDiscoveryOptions.DetectNewRoms; } var taskData = new RomDiscoveryData(Properties.Settings.Default.RomListSearchDirectories, _programs.ModelCollection, -1, Resources.Strings.RomListViewModel_ScanningForRoms_Title, options); SingleInstanceApplication.Instance.AddStartupAction("ScanForRoms", () => RefreshRoms(taskData), StartupTaskPriority.HighestAsyncTaskPriority); } // TODO: Initialize sorting! // TODO: Drag/Drop? }
private void ExecuteSimpleSearch() { ObservableCollection <string> tmpSave = SearchDirectories; SearchDirectories.Clear(); if (IsSearchingUserData) { SearchDirectories.Add(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)); } else if (IsSearchingThisPc) { SearchDirectories.Add(Path.GetPathRoot(Environment.SystemDirectory)); } else { foreach (string drive in Environment.GetLogicalDrives()) { SearchDirectories.Add(drive); } } ExecuteAdvancedSearch(); // Restore SearchDirectories SearchDirectories = tmpSave; }
protected override OptionSet OnCreateOptions() => new OptionSet { { "a|assembly=", "One or more assemblies to merge", v => Assemblies.Add(v) }, { "o|output=", "The output path to use for the merged assembly", v => SetOutputPath(v) }, { "s|search=", "One or more search directories", v => SearchDirectories.Add(v) }, { "inject-assemblyname", "Add the assembly names to the types", _ => InjectAssemblyNames = true }, };
public DefaultNetAssemblyResolver(params string[] directories) : this() { foreach (var directory in directories) { SearchDirectories.Add(directory); } }
protected override OptionSet OnCreateOptions() => new OptionSet { { "o|output=", "The output path to use for the merged assembly", v => OutputPath = v }, { "s|search=", "One or more search directories", v => SearchDirectories.Add(v) }, { "inject-assembly-name", "Add the assembly names to the types", _ => InjectAssemblyNames = true }, { "attribute-type=", "The full name of the attribute", v => AttributeFullName = v }, { "n|assembly-name=", "The name of the merged assembly", v => AssemblyName = v }, { "inject-assemblyname", "[Obsolete] Use `--inject-assembly-name`", _ => InjectAssemblyNames = true }, };
/// <summary> /// WPF-specific implementation. /// </summary> partial void OSInitialize() { _sortColumn = RomListColumn.None; _sortDirection = ListSortDirection.Ascending; // This null check keeps the WPF XAML designer output clean. if (INTV.Shared.Utility.SingleInstanceApplication.Instance != null) { var configuration = SingleInstanceApplication.Instance.GetConfiguration <RomListConfiguration>(); var romListFilePath = configuration.RomFilesPath; _filePath = romListFilePath; Model = LoadRomList(romListFilePath); Model.SaveFailed += HandleSaveFailed; ((INotifyPropertyChanged)Model).PropertyChanged += HandleProgramCollectionPropertyChanged; Sort(Properties.Settings.Default.SortDirection, Properties.Settings.Default.SortColumn); _nameColumnWidth = Properties.Settings.Default.RomListNameColWidth; _vendorColumnWidth = Properties.Settings.Default.RomListVendorColWidth; _yearColumnWidth = Properties.Settings.Default.RomListYearColWidth; _featuresColumnWidth = Properties.Settings.Default.RomListFeaturesColWidth; _romPathColumnWidth = Properties.Settings.Default.RomListPathColWidth; _searchDirectories = Properties.Settings.Default.RomListSearchDirectories; if (_searchDirectories == null) { _searchDirectories = new SearchDirectories(); Properties.Settings.Default.RomListSearchDirectories = _searchDirectories; } _dragProgramsStartCommand = new StartDragProgramsCommand(ExecuteStartSelectedProgramsDrag); if (Properties.Settings.Default.RomListSearchForRomsAtStartup && CanRefreshRoms(null)) { var options = RomDiscoveryOptions.AddNewRoms; if (Properties.Settings.Default.RomListValidateAtStartup) { options |= RomDiscoveryOptions.DetectChanges | RomDiscoveryOptions.DetectMissingRoms | RomDiscoveryOptions.DetectNewRoms; } var taskData = new RomDiscoveryData(Properties.Settings.Default.RomListSearchDirectories, _programs.ModelCollection, -1, Resources.Strings.RomListViewModel_ScanningForRoms_Title, options); SingleInstanceApplication.Instance.AddStartupAction("ScanForRoms", () => RefreshRoms(taskData), StartupTaskPriority.HighestAsyncTaskPriority); } } else { Model = INTV.Shared.Model.Program.ProgramCollection.EmptyDummyList; _nameColumnWidth = Properties.Settings.Default.RomListNameColWidth; _vendorColumnWidth = Properties.Settings.Default.RomListVendorColWidth; _yearColumnWidth = Properties.Settings.Default.RomListYearColWidth; _featuresColumnWidth = Properties.Settings.Default.RomListFeaturesColWidth; _romPathColumnWidth = Properties.Settings.Default.RomListPathColWidth; } }
public MergeCommand() : base("merge", "Merges the various AndroidX libraries.") { Options = new OptionSet { $"usage: {Program.Name} {Name} [OPTIONS]", "", Help, "", { "a|assembly=", "One or more assemblies to merge", v => Assemblies.Add(v) }, { "o|output=", "The output path to use for the merged assembly", v => SetOutputPath(v) }, { "s|search=", "One or more search directories", v => SearchDirectories.Add(v) }, { "inject-assemblyname", "Add the assembly names to the types", _ => InjectAssemblyNames = true }, { "?|h|help", "Show this message and exit", _ => ShowHelp = true }, }; }
private void DetectMonoGacDirectories() { if (Directory.Exists("/usr/lib/mono/gac")) { GacDirectories.Add(new GacDirectory("/usr/lib/mono/gac")); } string mostRecentMonoDirectory = Directory .EnumerateDirectories("/usr/lib/mono") .Where(d => d.EndsWith("-api")) .OrderByDescending(x => x) .FirstOrDefault(); if (mostRecentMonoDirectory != null) { SearchDirectories.Add(mostRecentMonoDirectory); } }
public void Merge(IEnumerable <string> assemblies, string outputPath) { var assembliesToMerge = assemblies?.ToList() ?? throw new ArgumentNullException(nameof(assemblies)); var assemblyResolver = new DefaultAssemblyResolver(); if (SearchDirectories != null) { foreach (var dir in SearchDirectories) { assemblyResolver.AddSearchDirectory(dir); } } if (Verbose) { Console.WriteLine("Merging:"); foreach (var include in assembliesToMerge) { Console.WriteLine($" - {include}"); } } var tempRoot = Path.Combine(Path.GetTempPath(), "Mono.ApiTools", "AssemblyMerger", Guid.NewGuid().ToString()); if (InjectAssemblyNames) { if (!string.IsNullOrWhiteSpace(tempRoot) && !Directory.Exists(tempRoot)) { Directory.CreateDirectory(tempRoot); } assembliesToMerge = assembliesToMerge.ToList(); for (int i = 0; i < assembliesToMerge.Count; i++) { var ass = assembliesToMerge[i]; var temp = Path.Combine(tempRoot, Guid.NewGuid().ToString() + ".dll"); InjectAssemblyName(assemblyResolver, ass, temp); assembliesToMerge[i] = temp; } if (Verbose) { Console.WriteLine("Temporary assemblies:"); foreach (var include in assembliesToMerge) { Console.WriteLine($" - {include}"); } } } var options = new RepackOptions { InputAssemblies = assembliesToMerge.ToArray(), OutputFile = outputPath, SearchDirectories = SearchDirectories.ToArray(), CopyAttributes = true, AllowMultipleAssemblyLevelAttributes = true, LogVerbose = Verbose }; options.AllowedDuplicateTypes.Add(InjectedAttributeFullName, InjectedAttributeFullName); var repacker = new ILRepack(options); repacker.Repack(); if (InjectAssemblyNames) { if (Directory.Exists(tempRoot)) { try { Directory.Delete(tempRoot, true); } catch { } } } }
public void Merge(string outputPath) { var assemblies = Assemblies; if (Program.Verbose) { Console.WriteLine("Merging:"); foreach (var include in assemblies) { Console.WriteLine($" - {include}"); } } var tempRoot = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); if (InjectAssemblyNames) { assemblies = assemblies.ToList(); if (!Directory.Exists(tempRoot)) { Directory.CreateDirectory(tempRoot); } for (int i = 0; i < assemblies.Count; i++) { var ass = assemblies[i]; var temp = Path.Combine(tempRoot, Guid.NewGuid().ToString() + ".dll"); InjectAssemblyName(ass, temp); assemblies[i] = temp; } if (Program.Verbose) { Console.WriteLine("Temporary assemblies:"); foreach (var include in assemblies) { Console.WriteLine($" - {include}"); } } } var options = new RepackOptions { InputAssemblies = assemblies.ToArray(), OutputFile = outputPath, SearchDirectories = SearchDirectories.ToArray(), CopyAttributes = true, AllowMultipleAssemblyLevelAttributes = true, LogVerbose = Program.Verbose }; var repacker = new ILRepack(options); repacker.Repack(); if (InjectAssemblyNames) { MergeAssemblyNameAttributes(outputPath); if (Directory.Exists(tempRoot)) { Directory.Delete(tempRoot, true); } } }
public override bool Execute() { if (string.IsNullOrEmpty(OutputFileName)) { OutputFileName = InputAssemblies[0]; } if (!Directory.Exists(Path.GetDirectoryName(OutputFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(OutputFileName)); } var cleanupExcludeFile = false; if (InternalizeExclude != null && InternalizeExclude.Length > 0) { InternalizeExcludeFile = Path.GetTempFileName(); File.WriteAllLines(InternalizeExcludeFile, InternalizeExclude); cleanupExcludeFile = true; } var ilmSearchPath = Path.GetFullPath(Path.Combine(Assembly.GetExecutingAssembly().Location, "..", "..")); var ilMergePath = Directory.GetFiles(ilmSearchPath, "ilmerge.exe", SearchOption.AllDirectories).Max(); var args = new StringBuilder(); if (SearchDirectories != null && SearchDirectories.Length > 0) { args.Append(string.Join("", SearchDirectories.Select(x => string.Format(@" /lib:""{0}""", x.TrimEnd('\\'))))); } if (Log) { args.Append(" /log"); } if (!string.IsNullOrWhiteSpace(InternalizeExcludeFile)) { args.AppendFormat(@" /internalize:""{0}""", InternalizeExcludeFile); } else if (Internalize) { args.Append(" /internalize"); } if (!string.IsNullOrWhiteSpace(TargetPlatform)) { args.AppendFormat(@" /targetplatform:{0}", TargetPlatform); } if (!string.IsNullOrWhiteSpace(TargetPlatformDir)) { args.AppendFormat(@",""{0}""", TargetPlatformDir); } if (WildCards) { args.Append(" /wildcards"); } args.AppendFormat(@" /out:""{0}""", OutputFileName); args.Append(string.Join("", InputAssemblies.Select(x => @" """ + x + @""""))); var ilMergeProc = new ProcessHostRedirect() { FileName = ilMergePath, Arguments = args.ToString().Trim() }; ilMergeProc.CommandLinePrefix = ""; ilMergeProc.OutputDataHandler = (dataType, line) => { LogLine(line); }; ilMergeProc.Execute(); if (cleanupExcludeFile) { File.Delete(InternalizeExcludeFile); } return(true); }
private void RemoveSearchDirectory() { SearchDirectories.RemoveAt(SearchDirectoryRemovalIndex); SearchDirectoryRemovalIndex = -1; }
private void AddSearchDirectory() { SearchDirectories.Add(NewSearchDirectory); NewSearchDirectory = string.Empty; }